diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java index 4fcbbf3a3..a2121d4c5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java @@ -62,7 +62,7 @@ public class ItemLaserWrench extends ItemBase{ TileEntity savedTile = world.getTileEntity(savedPos); int distanceSq = (int)savedPos.distanceSq(pos); if(ItemPhantomConnector.getStoredWorld(stack) == world && savedTile instanceof TileEntityLaserRelay && ((TileEntityLaserRelay)savedTile).isItem == ((TileEntityLaserRelay)tile).isItem && distanceSq <= TileEntityLaserRelay.MAX_DISTANCE*TileEntityLaserRelay.MAX_DISTANCE && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, world)){ - ItemPhantomConnector.clearStorage(stack); + ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); ((TileEntityLaserRelay)savedTile).sendUpdate(); ((TileEntityLaserRelay)tile).sendUpdate(); @@ -71,7 +71,7 @@ public class ItemLaserWrench extends ItemBase{ } else{ player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".laser.cantConnect.desc")); - ItemPhantomConnector.clearStorage(stack); + ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); } } } @@ -109,13 +109,6 @@ public class ItemLaserWrench extends ItemBase{ return true; } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - if(ItemPhantomConnector.getStoredPosition(stack) == null){ - ItemPhantomConnector.clearStorage(stack); - } - } - @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java index 89d423448..ca63ea232 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java @@ -62,8 +62,13 @@ public class ItemPhantomConnector extends ItemBase{ return null; } - public static void clearStorage(ItemStack stack){ - stack.setTagCompound(new NBTTagCompound()); + public static void clearStorage(ItemStack stack, String... keys){ + if(stack.hasTagCompound()){ + NBTTagCompound compound = stack.getTagCompound(); + for(String key : keys){ + compound.removeTag(key); + } + } } public static void storeConnection(ItemStack stack, int x, int y, int z, World world){ @@ -94,7 +99,7 @@ public class ItemPhantomConnector extends ItemBase{ if(tile instanceof TileEntityBase){ ((TileEntityBase)tile).sendUpdate(); } - clearStorage(stack); + clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".phantom.connected.desc")); return EnumActionResult.SUCCESS; } @@ -126,13 +131,6 @@ public class ItemPhantomConnector extends ItemBase{ return true; } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - if(getStoredPosition(stack) == null){ - clearStorage(stack); - } - } - @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java index c34fb0930..56c92f3e4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java @@ -50,14 +50,14 @@ public class ItemPlayerProbe extends ItemBase{ EntityPlayer player = world.getPlayerEntityByUUID(id); if(player != null){ if(player.isSneaking()){ - stack.setTagCompound(new NBTTagCompound()); + ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.1")); player.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.notice")); TheAchievements.GET_UNPROBED.get(player); } } else{ - stack.setTagCompound(new NBTTagCompound()); + ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.2")); } } @@ -79,7 +79,7 @@ public class ItemPlayerProbe extends ItemBase{ face.markDirty(); face.sendUpdate(); - stack.setTagCompound(new NBTTagCompound()); + ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); } return EnumActionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java index 712ae6643..cce98e4d9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java @@ -81,7 +81,7 @@ public class ItemSpawnerChanger extends ItemBase{ IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 3); - ItemPhantomConnector.clearStorage(stack); + ItemPhantomConnector.clearStorage(stack, "Entity"); if(!player.capabilities.isCreativeMode){ stack.stackSize--;