Skip to content

Commit

Permalink
Hopefully final version of village
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieisjelly committed Jan 9, 2024
1 parent 092d3da commit 39e3ca5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -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);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Binary file modified src/main/resources/data/sabotage/map_templates/village.nbt
Binary file not shown.

0 comments on commit 39e3ca5

Please sign in to comment.