|
81 | 81 | import net.minecraft.world.phys.Vec2; |
82 | 82 | import org.jetbrains.annotations.Nullable; |
83 | 83 | import org.joml.Matrix3x2f; |
| 84 | +import org.joml.Vector2f; |
84 | 85 |
|
85 | 86 | import java.lang.foreign.Arena; |
86 | 87 | import java.lang.foreign.MemoryLayout; |
|
98 | 99 | import java.util.function.IntSupplier; |
99 | 100 | import java.util.function.ToIntBiFunction; |
100 | 101 | import java.util.stream.IntStream; |
| 102 | +import java.util.stream.Stream; |
101 | 103 |
|
102 | 104 | import static dev.xpple.seedmapper.util.ChatBuilder.*; |
103 | 105 |
|
@@ -466,19 +468,25 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
466 | 468 | int playerMaxY = playerMinY + 20; |
467 | 469 | if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this.seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this.seedMapHeight) { |
468 | 470 | PlayerFaceRenderer.draw(guiGraphics, this.minecraft.player.getSkin(), playerMinX, playerMinY, 20); |
469 | | - } |
470 | 471 |
|
471 | | - // draw player direction arrow |
472 | | - guiGraphics.pose().pushMatrix(); |
473 | | - guiGraphics.pose() // transformations are applied in reverse order |
474 | | - .translate(10, 10) |
475 | | - .translate(playerMinX, playerMinY) |
476 | | - .rotate((float) (Math.toRadians(this.playerRotation.y) + Math.PI)) |
477 | | - .translate(-10, -10) |
478 | | - .translate(0, -30) |
479 | | - ; |
480 | | - drawIcon(guiGraphics, DIRECTION_ARROW_TEXTURE, 0, 0, 20, 20, 0xFF_FFFFFF); |
481 | | - guiGraphics.pose().popMatrix(); |
| 472 | + // draw player direction arrow |
| 473 | + guiGraphics.pose().pushMatrix(); |
| 474 | + Matrix3x2f transform = guiGraphics.pose() // transformations are applied in reverse order |
| 475 | + .translate(10, 10) |
| 476 | + .translate(playerMinX, playerMinY) |
| 477 | + .rotate((float) (Math.toRadians(this.playerRotation.y) + Math.PI)) |
| 478 | + .translate(-10, -10) |
| 479 | + .translate(0, -30) |
| 480 | + ; |
| 481 | + boolean withinBounds = Stream.of(new Vector2f(20, 0), new Vector2f(20, 20), new Vector2f(0, 20), new Vector2f(0, 0)) |
| 482 | + .map(transform::transformPosition) |
| 483 | + .allMatch(v -> v.x >= HORIZONTAL_PADDING && v.x <= HORIZONTAL_PADDING + this.seedMapWidth && |
| 484 | + v.y >= VERTICAL_PADDING && v.y <= VERTICAL_PADDING + this.seedMapHeight); |
| 485 | + if (withinBounds) { |
| 486 | + drawIcon(guiGraphics, DIRECTION_ARROW_TEXTURE, 0, 0, 20, 20, 0xFF_FFFFFF); |
| 487 | + } |
| 488 | + guiGraphics.pose().popMatrix(); |
| 489 | + } |
482 | 490 | } |
483 | 491 |
|
484 | 492 | // calculate spawn point |
|
0 commit comments