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);
|
TileEntity savedTile = world.getTileEntity(savedPos);
|
||||||
int distanceSq = (int)savedPos.distanceSq(pos);
|
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)){
|
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)savedTile).sendUpdate();
|
||||||
((TileEntityLaserRelay)tile).sendUpdate();
|
((TileEntityLaserRelay)tile).sendUpdate();
|
||||||
|
@ -71,7 +71,7 @@ public class ItemLaserWrench extends ItemBase{
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".laser.cantConnect.desc"));
|
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;
|
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
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||||
|
|
|
@ -62,8 +62,13 @@ public class ItemPhantomConnector extends ItemBase{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearStorage(ItemStack stack){
|
public static void clearStorage(ItemStack stack, String... keys){
|
||||||
stack.setTagCompound(new NBTTagCompound());
|
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){
|
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){
|
if(tile instanceof TileEntityBase){
|
||||||
((TileEntityBase)tile).sendUpdate();
|
((TileEntityBase)tile).sendUpdate();
|
||||||
}
|
}
|
||||||
clearStorage(stack);
|
clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
||||||
player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".phantom.connected.desc"));
|
player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".phantom.connected.desc"));
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -126,13 +131,6 @@ public class ItemPhantomConnector extends ItemBase{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
|
||||||
if(getStoredPosition(stack) == null){
|
|
||||||
clearStorage(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
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);
|
EntityPlayer player = world.getPlayerEntityByUUID(id);
|
||||||
if(player != null){
|
if(player != null){
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
stack.setTagCompound(new NBTTagCompound());
|
ItemPhantomConnector.clearStorage(stack, "UUID", "Name");
|
||||||
entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.1"));
|
entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.1"));
|
||||||
player.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.notice"));
|
player.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.notice"));
|
||||||
TheAchievements.GET_UNPROBED.get(player);
|
TheAchievements.GET_UNPROBED.get(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
stack.setTagCompound(new NBTTagCompound());
|
ItemPhantomConnector.clearStorage(stack, "UUID", "Name");
|
||||||
entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.2"));
|
entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class ItemPlayerProbe extends ItemBase{
|
||||||
face.markDirty();
|
face.markDirty();
|
||||||
face.sendUpdate();
|
face.sendUpdate();
|
||||||
|
|
||||||
stack.setTagCompound(new NBTTagCompound());
|
ItemPhantomConnector.clearStorage(stack, "UUID", "Name");
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ItemSpawnerChanger extends ItemBase{
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
world.notifyBlockUpdate(pos, state, state, 3);
|
world.notifyBlockUpdate(pos, state, state, 3);
|
||||||
|
|
||||||
ItemPhantomConnector.clearStorage(stack);
|
ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||||
|
|
||||||
if(!player.capabilities.isCreativeMode){
|
if(!player.capabilities.isCreativeMode){
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
|
|
Loading…
Reference in a new issue