-
Notifications
You must be signed in to change notification settings - Fork 6
BME-100 Make waypoint keybind create a waypoint at cursor position in world map #89
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
base: mc-1.18.2-v0.8.0-overhaul
Are you sure you want to change the base?
BME-100 Make waypoint keybind create a waypoint at cursor position in world map #89
Conversation
| ChunkPos chunkPos = new ChunkPos(position); | ||
|
|
||
| // Attempt to get y actual level from MDCache | ||
| ChunkMDCache mdCache = ClientEngine.getMDCache(chunkPos); |
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.
This Client stuff might not be available when the player's connected to a server. Would need to validate it doesn't break when that's the case
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.
Unless I'm forgetting something, all this should be available at all times in the client, regardless of what the server is.
| if (mdCache != null) { | ||
| ChunkMDCacheView mdView = new ChunkMDCacheView().setSource(mdCache); | ||
| Set<BlazeRegistry.Key<DataType>> filterKeys = new HashSet<>(); | ||
| filterKeys.add(UnsafeGenerics.stripKey(BlazeMapReferences.MasterData.TERRAIN_HEIGHT)); | ||
| mdView.setFilter(filterKeys); | ||
|
|
||
| TerrainHeightMD heightMD = (TerrainHeightMD) mdView.get(BlazeMapReferences.MasterData.TERRAIN_HEIGHT); | ||
|
|
||
| if (heightMD != null) { | ||
| int chunkX = SectionPos.sectionRelative(position.getX()); | ||
| int chunkZ = SectionPos.sectionRelative(position.getZ()); | ||
| posY = heightMD.heightmap[chunkX][chunkZ]; | ||
| position = position.atY(posY); | ||
| } | ||
| } |
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.
It definitely feels like there should be a nicer way to do this. We might need to fix this problem at a different level of abstraction, making it easier to query the MD from elsewhere within the code
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.
This looks more or less like I would expect. Not a huge fan of the call to SectionPos but it's inconsequential.
src/main/java/com/eerussianguy/blazemap/feature/maps/WorldMapGui.java
Outdated
Show resolved
Hide resolved
src/main/java/com/eerussianguy/blazemap/feature/maps/WorldMapGui.java
Outdated
Show resolved
Hide resolved
| @Override | ||
| public void render(PoseStack stack, boolean hasMouse, int mouseX, int mouseY) { | ||
| this.lastMouseX = mouseX; | ||
| this.lastMouseY = mouseY; | ||
| super.render(stack, hasMouse, mouseX, mouseY); | ||
| } |
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.
should I be calling setMouse() here instead? I think that it would be required for BME-216 to work anyway
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.
We only need to call setMouse when there is mouse input. On render the values are the same as the last frame that the mouse had just moved.
Unless something is broken?
|
|
||
| @Override | ||
| public boolean keyPressed(int key, int scancode, int modifiers) { | ||
| setMouse(lastMouseX, lastMouseY); |
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.
Also here, we should just keep the same values from the last change. This does nothing unless you have run into a bug.
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.
It didn't work without me adding this, I am pretty sure that the mouseMoved() method is broken or only works on drag or something. Before adding this it would only update the mouse coords after clicking on something and moving the map around
No description provided.