From eff5e36987fee3aaa0636b2d127c7221d13ed100 Mon Sep 17 00:00:00 2001 From: lars Date: Wed, 15 Oct 2025 21:26:02 +0200 Subject: [PATCH] solved some pr comments --- .../types/turtleGame/TurtleGame.java | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/turtleGame/TurtleGame.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/turtleGame/TurtleGame.java index fdaa064..47d7754 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/turtleGame/TurtleGame.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/turtleGame/TurtleGame.java @@ -48,10 +48,6 @@ class TurtleGame extends StatelessGame { @Override protected void onLoad(@NotNull CompletableFuture callback) { - this.generatePlatform(); - } - - private void generatePlatform() { for(int x = -this.radius - 1; x <= this.radius + 1; x++) { for(int z = -this.radius - 1; z <= this.radius + 1; z++) { double distance = new Pos(x, 0, z).distance(new Pos(0, 0, 0)); @@ -116,8 +112,7 @@ class TurtleGame extends StatelessGame { protected void eat(Player p, Entity snack) { p.playSound(Sound.sound(SoundEvent.ENTITY_GENERIC_EAT, Sound.Source.MASTER, 1f, 1f), snack.getPosition()); - Material snackMaterial = this.snackBlock.registry().material(); - if(snackMaterial == null) snackMaterial = Material.DIRT; + Material snackMaterial = Objects.requireNonNull(this.snackBlock.registry().material()); p.sendPacket(new ParticlePacket(Particle.ITEM.withItem(ItemStack.of(snackMaterial)), p.getPosition(), new Pos(0.5, 0.5, 0.5), 0, 8)); this.snacks.remove(snack); snack.remove(); @@ -184,16 +179,15 @@ class TurtleGame extends StatelessGame { private void generateNewSnack() { Entity snack = new Entity(EntityType.FALLING_BLOCK); FallingBlockMeta meta = (FallingBlockMeta) snack.getEntityMeta(); - meta.setBlock(this.snackBlock.withProperty("half", "upper")); - meta.setCustomName(Component.text("Snack").color(NamedTextColor.WHITE)); + meta.setBlock(this.snackBlock); + meta.setCustomName(Component.text("Snack")); meta.setCustomNameVisible(true); - snack.setInstance(this); Pos spawnPosition = this.newSpawnPosition(snack); if(spawnPosition == null) { snack.remove(); return; } - snack.teleport(spawnPosition); + snack.setInstance(this, spawnPosition); this.snacks.add(snack); } @@ -209,30 +203,25 @@ class TurtleGame extends StatelessGame { meta.setBlock(Block.TNT); meta.setCustomName(Component.text("Bomb").color(NamedTextColor.RED).decorate(TextDecoration.BOLD)); meta.setCustomNameVisible(true); - bomb.setInstance(this); Pos spawnPosition = this.newSpawnPosition(bomb, false); if(spawnPosition == null) { bomb.remove(); return; } - bomb.teleport(spawnPosition); + bomb.setInstance(this, spawnPosition); this.bombs.add(bomb); } - @Nullable - private Pos newSpawnPosition(Entity entity) { + private @Nullable Pos newSpawnPosition(Entity entity) { return this.newSpawnPosition(entity, true); } - @Nullable - private Pos newSpawnPosition(Entity entity, boolean nearPlayers) { + private @Nullable Pos newSpawnPosition(Entity entity, boolean nearPlayers) { Pos spawnPosition; int counter = 0; boolean isInRadius, collides; do { - if(counter > 200) { - return null; - } + if(counter > 200) return null; int x = this.rnd.nextInt(-this.radius+2, this.radius-2); int z = this.rnd.nextInt(-this.radius+2, this.radius-2); spawnPosition = new Pos(x, 1, z).add(0.5, 0, 0.5);