diff --git a/src/main/java/cech12/usefulhats/item/EnderHelmetItem.java b/src/main/java/cech12/usefulhats/item/EnderHelmetItem.java index 27e7ba4..fe07aad 100644 --- a/src/main/java/cech12/usefulhats/item/EnderHelmetItem.java +++ b/src/main/java/cech12/usefulhats/item/EnderHelmetItem.java @@ -47,9 +47,7 @@ public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @N BlockPos pos = getPosition(stack); this.addTextLineToTooltip(tooltip, new TranslationTextComponent("item.usefulhats.ender_helmet.desc.teleport").mergeStyle(TextFormatting.BLUE)); this.addTextLineToTooltip(tooltip, new TranslationTextComponent("item.usefulhats.ender_helmet.desc.teleport_position", pos.getX(), pos.getY(), pos.getZ()).mergeStyle(TextFormatting.BLUE)); - if (worldIn == null || !isRightDimension(worldIn, stack)) { - this.addTextLineToTooltip(tooltip, new StringTextComponent(getDimensionString(stack)).mergeStyle(TextFormatting.BLUE)); - } + this.addTextLineToTooltip(tooltip, new StringTextComponent(getDimensionString(stack)).mergeStyle(TextFormatting.BLUE)); } } @@ -61,7 +59,7 @@ private static void setPosition(@Nonnull ItemStack stack, @Nonnull World world, positionNBT.putInt("Y", pos.getY()); positionNBT.putInt("Z", pos.getZ()); positionNBT.putString("dimKey", world.func_234923_W_().getRegistryName().toString()); //dimension registry key - positionNBT.putString("dimValue", world.func_234923_W_().func_240901_a_().toString()); //dimension name + positionNBT.putString("dimName", world.func_234923_W_().func_240901_a_().toString()); //dimension name nbt.put(TELEPORT_POSITION_ID, positionNBT); stack.setTag(nbt); } @@ -82,14 +80,15 @@ private static BlockPos getPosition(@Nonnull ItemStack stack) { @OnlyIn(Dist.CLIENT) private String getDimensionString(@Nonnull ItemStack stack) { if (hasPosition(stack)) { - return stack.getOrCreateTag().getCompound(TELEPORT_POSITION_ID).getString("dimValue"); + return stack.getOrCreateTag().getCompound(TELEPORT_POSITION_ID).getString("dimName"); } return "?"; } private static boolean equalsWorldAndNBT(World world, CompoundNBT positionNBT) { - return world.func_234923_W_().getRegistryName().toString().equals(positionNBT.getString("dimKey")) - && world.func_234923_W_().func_240901_a_().toString().equals(positionNBT.getString("dimValue")); + return (!positionNBT.contains("dimKey") //to be compatible with older versions + || world.func_234923_W_().getRegistryName().toString().equals(positionNBT.getString("dimKey"))) + && world.func_234923_W_().func_240901_a_().toString().equals(positionNBT.getString("dimName")); } private ServerWorld getWorld(@Nonnull MinecraftServer server, @Nonnull ItemStack stack) {