From 3c25f5f079babbec5c95401c18570d4d7b447f0e Mon Sep 17 00:00:00 2001 From: lars Date: Wed, 23 Oct 2024 13:55:39 +0200 Subject: [PATCH] changed player spawn position --- .../stateless/types/tetris/game/Playfield.java | 7 +++++-- .../stateless/types/tetris/game/Tetromino.java | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Playfield.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Playfield.java index bc11e86..fd8fec0 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Playfield.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Playfield.java @@ -25,8 +25,8 @@ public class Playfield { } public Pos getPlayerSpawnPosition() { -// return this.lowerLeftCorner.add(6.5, 9+((double) 3/16), 20.5).withView(180, 0); - return this.lowerLeftCorner.add(6.5, 9, 20.5).withView(180, 0); +// return this.lowerLeftCorner.add(6, 9+((double) 3/16), 20).withView(180, 0); + return this.lowerLeftCorner.add(6, 9, 20).withView(180, 0); } public Pos getTetrominoSpawnPosition() { @@ -80,6 +80,9 @@ public class Playfield { } batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 0), Block.STONE); + batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 0), Block.STONE); + batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 1), Block.STONE); + batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 1), Block.STONE); // batch.setBlock(getPlayerSpawnPosition(), Block.IRON_TRAPDOOR.withProperty("half", "bottom")); // batch.setBlock(getPlayerSpawnPosition().add(0, 1, 0), Block.IRON_TRAPDOOR.withProperty("half", "top")); diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Tetromino.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Tetromino.java index e41a57a..b921a09 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Tetromino.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game/Tetromino.java @@ -10,6 +10,7 @@ import net.minestom.server.instance.block.Block; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.UUID; public class Tetromino { public final Shape shape; @@ -18,6 +19,7 @@ public class Tetromino { private Pos position; private int[][] shapeArray; private final static EntityType ghostEntityType = EntityType.FALLING_BLOCK; + private final UUID uuid; public enum Shape { I, @@ -33,6 +35,7 @@ public class Tetromino { this.instance = instance; this.shape = shape; this.playfield = playfield; + this.uuid = UUID.randomUUID(); switch (this.shape) { case I -> shapeArray = new int[][]{{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}}; @@ -88,16 +91,29 @@ public class Tetromino { getBlockPositions().forEach(pos -> { Entity ghostBlock = new Entity(ghostEntityType); ((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getGhostBlock()); +// ((BlockDisplayMeta) ghostBlock.getEntityMeta()).setBlockState(this.getGhostBlock()); ghostBlock.setNoGravity(true); ghostBlock.setGlowing(true); - ghostBlock.setInvisible(true); ghostBlock.setInstance(this.instance, pos.sub(positionChange).add(0.5, 0, 0.5)); +// ghostBlock.setInstance(this.instance, pos.sub(positionChange).add(1, 0, 1)); }); } getBlockPositions().forEach(pos -> this.instance.setBlock(pos, this.getColoredBlock())); } + public void drawAsEntities() { + getBlockPositions().forEach(pos -> { + Entity ghostBlock = new Entity(ghostEntityType); + ((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getGhostBlock()); +// ((BlockDisplayMeta) ghostBlock.getEntityMeta()).setBlockState(this.getGhostBlock()); + ghostBlock.setNoGravity(true); + ghostBlock.setGlowing(true); + ghostBlock.setInstance(this.instance, pos.add(0.5, 0, 0.5)); +// ghostBlock.setInstance(this.instance, pos.sub(positionChange).add(1, 0, 1)); + }); + } + public void remove() { this.getBlockPositions().forEach(pos -> this.instance.setBlock(pos, Block.AIR)); }