More dynamic rendering!

This commit is contained in:
Aidan Brady 2013-08-05 16:59:22 -04:00
parent 4e35a9f6d5
commit bf500ae6dc
2 changed files with 17 additions and 6 deletions

View file

@ -46,7 +46,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
if (tileEntity.structure.inventory.remove(itemStack))
{
entityPlayer.dropPlayerItem(itemStack);
tileEntity.updateInventory();
tileEntity.updateAllClients();
}
}
}
@ -73,7 +73,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
tileEntity.structure.inventory.add(entityPlayer.getCurrentEquippedItem());
tileEntity.structure.sortInventory();
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
tileEntity.updateInventory();
tileEntity.updateAllClients();
}
/**

View file

@ -18,6 +18,7 @@ import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.ListUtil;
import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
import resonantinduction.tesla.TeslaGrid;
import com.google.common.io.ByteArrayDataInput;
@ -61,6 +62,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
structure.inventory.add(structure.visibleInventory[0]);
structure.visibleInventory[0] = null;
structure.sortInventory();
updateAllClients();
}
}
@ -95,7 +97,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
player.closeScreen();
}
updateInventory();
updateClient();
}
prevStructure = structure;
@ -105,15 +107,24 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
if(playersUsing.size() > 0)
{
updateInventory();
updateClient();
}
}
}
public void updateInventory()
public void updateClient()
{
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
}
public void updateAllClients()
{
for(Vector3 vec : structure.locations)
{
TileEntityBattery battery = (TileEntityBattery)vec.getTileEntity(worldObj);
PacketHandler.sendTileEntityPacketToClients(battery, battery.getNetworkedData(new ArrayList()).toArray());
}
}
@Override
public void validate()