-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add seen waypoint #1108
Open
kevinthegreat1
wants to merge
4
commits into
SkyblockerMod:master
Choose a base branch
from
kevinthegreat1:seen-waypoint
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add seen waypoint #1108
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/de/hysky/skyblocker/utils/waypoint/SeenWaypoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package de.hysky.skyblocker.utils.waypoint; | ||
|
||
import de.hysky.skyblocker.utils.Tickable; | ||
import de.hysky.skyblocker.utils.render.FrustumUtils; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.hit.HitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.RaycastContext; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* A waypoint that renders without beacon beams and does not render through walls until it is seen. | ||
* <p>After being seen, it will render through walls and optionally render beacon beams based on the waypoint type. | ||
* It is the caller's responsibility to call {@link #tick(MinecraftClient)} to check if the waypoint is seen. | ||
*/ | ||
public class SeenWaypoint extends Waypoint implements Tickable { | ||
private boolean seen = false; | ||
|
||
public SeenWaypoint(BlockPos pos, Type type, float[] colorComponents) { | ||
super(pos, type, colorComponents); | ||
} | ||
|
||
public SeenWaypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents) { | ||
super(pos, typeSupplier, colorComponents); | ||
} | ||
|
||
public boolean isSeen() { | ||
return seen; | ||
} | ||
|
||
@Override | ||
public Type getRenderType() { | ||
return seen ? super.getRenderType() : super.getRenderType().withoutBeacon(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderThroughWalls() { | ||
return seen; | ||
} | ||
|
||
@Override | ||
public void tick(MinecraftClient client) { | ||
if (!seen && shouldRender() && client.world != null && client.player != null && FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { | ||
BlockHitResult blockHitResult = client.world.raycast(new RaycastContext(client.player.getEyePos(), Vec3d.ofCenter(pos), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, client.player)); | ||
if (blockHitResult.getType() == HitResult.Type.MISS || blockHitResult.getBlockPos().equals(pos)) { | ||
seen = true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it should have to be seen for a certain number of seconds to count, too often with egg waypoints I spin my camera briefly not even noticing the egg and it shows me the waypoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that could be added at a later point. I made it like this since it's supposed to help you see things.