From c0d27e671fa84b8a2e5a85f28aa539fd22829ac3 Mon Sep 17 00:00:00 2001 From: Simon - fantomitechno Date: Wed, 3 Jan 2024 21:17:48 +0100 Subject: [PATCH] :bug: smh more bug fixes with the 0 0 0 thing --- gradle.properties | 2 +- .../java/dev/renoux/enderrelay/blocks/EnderRelayBlock.java | 7 ++++++- .../enderrelay/blocks/entity/EnderRelayBlockEntity.java | 4 ++-- src/main/resources/assets/enderrelay/lang/en_us.json | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 927cab3..66e3207 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel = true # Mod Properties -version = 0.1.4 +version = 0.1.5 # Notes: when debugging, use rc's, so it would become: 0.X.X-rc.X maven_group = dev.renoux archives_base_name = enderrelay diff --git a/src/main/java/dev/renoux/enderrelay/blocks/EnderRelayBlock.java b/src/main/java/dev/renoux/enderrelay/blocks/EnderRelayBlock.java index 3da7f86..118cb18 100644 --- a/src/main/java/dev/renoux/enderrelay/blocks/EnderRelayBlock.java +++ b/src/main/java/dev/renoux/enderrelay/blocks/EnderRelayBlock.java @@ -111,6 +111,11 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player if (name.equals(Items.COMPASS.getName(itemStack))) { name = Component.literal(compassPos.getX() + "/" + compassPos.getY() + "/" + compassPos.getZ()); } + + if (name.equals(Component.literal("null"))) { + player.sendSystemMessage(Component.translatable("block.enderrelay.not_this_name_please")); + return InteractionResult.CONSUME; + } player.sendSystemMessage(Component.translatable("block.enderrelay.set_teleport", name)); blentity.load(compassPos, name); blentity.setChanged(); @@ -118,7 +123,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player ServerPlayer serverPlayer = (ServerPlayer) player; EnderRelayBlockEntity blentity = (EnderRelayBlockEntity) world.getBlockEntity(pos); if (serverPlayer.isCrouching()) { - if (blentity.getName() != null) + if (blentity.getName().equals(Component.literal("null"))) serverPlayer.displayClientMessage(Component.translatable("block.enderrelay.teleport_to", blentity.getName()), true); else serverPlayer.displayClientMessage(Component.translatable("block.enderrelay.nowhere"), true); diff --git a/src/main/java/dev/renoux/enderrelay/blocks/entity/EnderRelayBlockEntity.java b/src/main/java/dev/renoux/enderrelay/blocks/entity/EnderRelayBlockEntity.java index 0aa387b..534b015 100644 --- a/src/main/java/dev/renoux/enderrelay/blocks/entity/EnderRelayBlockEntity.java +++ b/src/main/java/dev/renoux/enderrelay/blocks/entity/EnderRelayBlockEntity.java @@ -80,7 +80,7 @@ public EnderRelayBlockEntity(BlockPos blockPos, BlockState blockState) { @Override protected void saveAdditional(CompoundTag compoundTag) { super.saveAdditional(compoundTag); - if (!this.teleportPlace.equals(new BlockPos(0, 0, 0))) { + if (!this.name.equals(Component.literal("null"))) { compoundTag.put("teleportPlace", NbtUtils.writeBlockPos(this.teleportPlace)); compoundTag.putString("name", Component.Serializer.toJson(this.name)); } @@ -98,7 +98,7 @@ public void load(BlockPos pos, Component name) { } public static void teleportPlayer(Level world, BlockPos pos, BlockState state, ServerPlayer player, EnderRelayBlockEntity blockEntity) { - if (blockEntity.teleportPlace.equals(new BlockPos(0, 0, 0))) { + if (blockEntity.name.equals(Component.literal("null"))) { player.displayClientMessage(Component.translatable("block.enderrelay.nowhere"), true); return; } diff --git a/src/main/resources/assets/enderrelay/lang/en_us.json b/src/main/resources/assets/enderrelay/lang/en_us.json index 45c36b3..dc01780 100644 --- a/src/main/resources/assets/enderrelay/lang/en_us.json +++ b/src/main/resources/assets/enderrelay/lang/en_us.json @@ -4,5 +4,6 @@ "block.enderrelay.obstructed": "Your lodestone is obstructed or destroyed", "block.enderrelay.nowhere": "This Ender Relay is leading nowhere", "block.enderrelay.teleport_to": "This Ender Relay is teleporting you to %s", - "item.minecraft.lodestone_compass.nowhere": "This Lodestone Compass is leading nowhere" + "item.minecraft.lodestone_compass.nowhere": "This Lodestone Compass is leading nowhere", + "block.enderrelay.not_this_name_please": "A compass named \"null\" can broke the mod, please don't use that :/" } \ No newline at end of file