This commit is contained in:
Ellpeck 2015-10-18 15:31:01 +02:00
parent 2c763c9199
commit 3278cf9d3f
16 changed files with 94 additions and 95 deletions

View file

@ -76,8 +76,6 @@ public abstract class TileEntityBase extends TileEntity{
this.writeSyncableNBT(compound, false); this.writeSyncableNBT(compound, false);
} }
public abstract void readSyncableNBT(NBTTagCompound compound, boolean isForSync);
public abstract void writeSyncableNBT(NBTTagCompound compound, boolean isForSync); public abstract void writeSyncableNBT(NBTTagCompound compound, boolean isForSync);
@Override @Override
@ -97,6 +95,8 @@ public abstract class TileEntityBase extends TileEntity{
return !(oldBlock.isAssociatedBlock(newBlock)); return !(oldBlock.isAssociatedBlock(newBlock));
} }
public abstract void readSyncableNBT(NBTTagCompound compound, boolean isForSync);
protected void sendUpdate(){ protected void sendUpdate(){
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} }

View file

@ -88,13 +88,6 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
this.currentTime = compound.getInteger("CurrentTime");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
@ -102,6 +95,13 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
compound.setInteger("CurrentTime", this.currentTime); compound.setInteger("CurrentTime", this.currentTime);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
this.currentTime = compound.getInteger("CurrentTime");
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return false; return false;

View file

@ -79,14 +79,6 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
return this.currentProcessTime*i/ConfigIntValues.BARREL_PROCESSING_TIME.getValue(); return this.currentProcessTime*i/ConfigIntValues.BARREL_PROCESSING_TIME.getValue();
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentProcessTime = compound.getInteger("ProcessTime");
this.canolaTank.readFromNBT(compound);
this.oilTank.readFromNBT((NBTTagCompound)compound.getTag("OilTank"));
super.readSyncableNBT(compound, sync);
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("ProcessTime", this.currentProcessTime); compound.setInteger("ProcessTime", this.currentProcessTime);
@ -97,6 +89,14 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentProcessTime = compound.getInteger("ProcessTime");
this.canolaTank.readFromNBT(compound);
this.oilTank.readFromNBT((NBTTagCompound)compound.getTag("OilTank"));
super.readSyncableNBT(compound, sync);
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.bucket); return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.bucket);

View file

@ -28,14 +28,13 @@ public class TileEntityFishingNet extends TileEntityBase{
public int timeUntilNextDrop; public int timeUntilNextDrop;
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop);
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeToNBT(compound); this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop");
compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop);
} }
@Override @Override

View file

@ -158,13 +158,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
return this.tank.getFluidAmount()*i/this.tank.getCapacity(); return this.tank.getFluidAmount()*i/this.tank.getCapacity();
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
this.tank.readFromNBT(compound);
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
@ -172,6 +165,13 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
this.tank.writeToNBT(compound); this.tank.writeToNBT(compound);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
this.tank.readFromNBT(compound);
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
if(i == 0){ if(i == 0){

View file

@ -42,13 +42,13 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound); this.storage.writeToNBT(compound);
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound); this.storage.readFromNBT(compound);
} }
@Override @Override

View file

@ -64,13 +64,13 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
return null; return null;
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
compound.setInteger("Time", this.timeUntilNextFert);
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
this.timeUntilNextFert = compound.getInteger("Time"); this.timeUntilNextFert = compound.getInteger("Time");
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
compound.setInteger("Time", this.timeUntilNextFert);
}
} }

View file

@ -79,13 +79,13 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
return from == ForgeDirection.UP; return from == ForgeDirection.UP;
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
this.storage.readFromNBT(compound);
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
this.storage.readFromNBT(compound);
}
} }

View file

@ -31,22 +31,6 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
this.slots = new ItemStack[itemAmount]; this.slots = new ItemStack[itemAmount];
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
if(!isForSync){
if(this.slots.length > 0){
NBTTagList tagList = compound.getTagList("Items", 10);
for(int i = 0; i < tagList.tagCount(); i++){
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
byte slotIndex = tagCompound.getByte("Slot");
if(slotIndex >= 0 && slotIndex < slots.length){
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
}
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
if(!isForSync){ if(!isForSync){
@ -65,6 +49,22 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
} }
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
if(!isForSync){
if(this.slots.length > 0){
NBTTagList tagList = compound.getTagList("Items", 10);
for(int i = 0; i < tagList.tagCount(); i++){
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
byte slotIndex = tagCompound.getByte("Slot");
if(slotIndex >= 0 && slotIndex < slots.length){
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
}
}
@Override @Override
public int[] getAccessibleSlotsFromSide(int side){ public int[] getAccessibleSlotsFromSide(int side){
if(this.slots.length > 0){ if(this.slots.length > 0){

View file

@ -30,18 +30,18 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
public EnergyStorage storage = new EnergyStorage(3000000); public EnergyStorage storage = new EnergyStorage(3000000);
private int currentWorkTime; private int currentWorkTime;
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
this.currentWorkTime = compound.getInteger("WorkTime");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
compound.setInteger("WorkTime", this.currentWorkTime); compound.setInteger("WorkTime", this.currentWorkTime);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
this.currentWorkTime = compound.getInteger("WorkTime");
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){

View file

@ -29,13 +29,13 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
private int nextUseCounter; private int nextUseCounter;
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound); this.storage.writeToNBT(compound);
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound); this.storage.readFromNBT(compound);
} }
@Override @Override

View file

@ -20,12 +20,12 @@ public class TileEntityPhantomBooster extends TileEntityBase{
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
} }
} }

View file

@ -137,6 +137,18 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
return this.range; return this.range;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("Time", currentTime);
if(this.hasBoundPosition()){
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
}
}
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync); super.readSyncableNBT(compound, sync);
@ -150,18 +162,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("Time", currentTime);
if(this.hasBoundPosition()){
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
}
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return !this.isBreaker; return !this.isBreaker;

View file

@ -74,18 +74,18 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
return !this.isWhitelist; return !this.isWhitelist;
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.isWhitelist = compound.getBoolean("Whitelist");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
compound.setBoolean("Whitelist", this.isWhitelist); compound.setBoolean("Whitelist", this.isWhitelist);
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.isWhitelist = compound.getBoolean("Whitelist");
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return false; return false;

View file

@ -27,11 +27,6 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
public int flyHeight; public int flyHeight;
private String nameBefore; private String nameBefore;
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.name = compound.getString("Name");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
if(this.name != null){ if(this.name != null){
@ -39,6 +34,11 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
} }
} }
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.name = compound.getString("Name");
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
if(!worldObj.isRemote){ if(!worldObj.isRemote){