diff --git a/src/main/java/me/ellieis/Sabotage/game/custom/blocks/TesterSign.java b/src/main/java/me/ellieis/Sabotage/game/custom/blocks/TesterSign.java index 3659853..c685337 100644 --- a/src/main/java/me/ellieis/Sabotage/game/custom/blocks/TesterSign.java +++ b/src/main/java/me/ellieis/Sabotage/game/custom/blocks/TesterSign.java @@ -32,12 +32,11 @@ public Block getPolymerBlock(BlockState state) { } @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - // to-do: tester functionality if (!world.isClient()) { ServerPlayerEntity plr = (ServerPlayerEntity) player; for (SabotageActive game : Sabotage.activeGames) { if (game.getWorld().equals(world)) { - if (!game.testEntity(plr)) { + if (!game.testEntity(plr, hit.getBlockPos())) { plr.sendMessage(Text.translatable("sabotage.tester.fail").formatted(Formatting.YELLOW)); } break; diff --git a/src/main/java/me/ellieis/Sabotage/game/custom/blocks/WallTesterSign.java b/src/main/java/me/ellieis/Sabotage/game/custom/blocks/WallTesterSign.java index 46504ef..a8de13e 100644 --- a/src/main/java/me/ellieis/Sabotage/game/custom/blocks/WallTesterSign.java +++ b/src/main/java/me/ellieis/Sabotage/game/custom/blocks/WallTesterSign.java @@ -16,6 +16,7 @@ import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.DyeColor; +import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -35,11 +36,13 @@ public Block getPolymerBlock(BlockState state) { } @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - // to-do: tester functionality if (!world.isClient()) { + ServerPlayerEntity plr = (ServerPlayerEntity) player; for (SabotageActive game : Sabotage.activeGames) { if (game.getWorld().equals(world)) { - game.testEntity((ServerPlayerEntity) player); + if (!game.testEntity(plr, hit.getBlockPos())) { + plr.sendMessage(Text.translatable("sabotage.tester.fail").formatted(Formatting.YELLOW)); + } break; } } @@ -62,7 +65,6 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi SignBlockEntity be = (SignBlockEntity) world.getBlockEntity(pos); Text[] text = {Text.literal("Click this"), Text.literal("sign to"), Text.literal("start the"), Text.literal("test")}; be.setText(new SignText(text, text, DyeColor.RED, true), true); - } } } diff --git a/src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java b/src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java index 5e15242..f16b406 100644 --- a/src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java +++ b/src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java @@ -371,13 +371,14 @@ public void testEntity(ServerPlayerEntity plr, LivingEntity entity) { } // tester only - public boolean testEntity(ServerPlayerEntity plr) { + public boolean testEntity(ServerPlayerEntity plr, BlockPos pos) { if (plr.isSpectator()) return true; if (gameState == GameStates.ACTIVE) { if (isTesterOnCooldown) { return false; } isTesterOnCooldown = true; + plr.teleport(pos.getX(), pos.getY(), pos.getZ()); plr.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100)); plr.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 200)); for (BlockPos blockPos : map.getTesterCloseRegion().getBounds()) { diff --git a/src/main/resources/data/sabotage/map_templates/village.nbt b/src/main/resources/data/sabotage/map_templates/village.nbt index 9649a2b..bb93524 100644 Binary files a/src/main/resources/data/sabotage/map_templates/village.nbt and b/src/main/resources/data/sabotage/map_templates/village.nbt differ