changed player spawn position

This commit is contained in:
Lars Neuhaus 2024-10-23 13:55:39 +02:00
parent 179fa2e4d7
commit 3c25f5f079
2 changed files with 22 additions and 3 deletions
src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/tetris/game

@ -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"));

@ -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));
}