mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Fixed some items removing the entire NBT tag once clearing the storage
Closes #200
This commit is contained in:
parent
8707f0c96c
commit
35aae43d21
4 changed files with 14 additions and 23 deletions
|
@ -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){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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--;
|
||||
|
|
Loading…
Reference in a new issue