mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Workaround for a bug that broke the packet handling
This commit is contained in:
parent
dbf8093ea0
commit
85428e885d
2 changed files with 43 additions and 30 deletions
|
@ -39,6 +39,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
private boolean activateOnceWithSignal;
|
private boolean activateOnceWithSignal;
|
||||||
private int oldEnergy;
|
private int oldEnergy;
|
||||||
|
|
||||||
|
public boolean syncSlotsNextTime;
|
||||||
|
|
||||||
public TileEntityAtomicReconstructor(){
|
public TileEntityAtomicReconstructor(){
|
||||||
super(1, "reconstructor");
|
super(1, "reconstructor");
|
||||||
}
|
}
|
||||||
|
@ -109,11 +111,12 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
super.writeSyncableNBT(compound, sync);
|
super.writeSyncableNBT(compound, sync);
|
||||||
compound.setInteger("CurrentTime", this.currentTime);
|
compound.setInteger("CurrentTime", this.currentTime);
|
||||||
this.storage.writeToNBT(compound);
|
this.storage.writeToNBT(compound);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if(this.syncSlotsNextTime){
|
||||||
public boolean shouldSyncSlots(){
|
this.writeSlotsToCompound(compound);
|
||||||
return true;
|
compound.setBoolean("ShouldSync", true);
|
||||||
|
this.syncSlotsNextTime = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,16 +124,22 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
super.readSyncableNBT(compound, sync);
|
super.readSyncableNBT(compound, sync);
|
||||||
this.currentTime = compound.getInteger("CurrentTime");
|
this.currentTime = compound.getInteger("CurrentTime");
|
||||||
this.storage.readFromNBT(compound);
|
this.storage.readFromNBT(compound);
|
||||||
|
|
||||||
|
if(compound.getBoolean("ShouldSync")){
|
||||||
|
this.readSlotsFromCompound(compound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int i, ItemStack stack){
|
public void setInventorySlotContents(int i, ItemStack stack){
|
||||||
super.setInventorySlotContents(i, stack);
|
super.setInventorySlotContents(i, stack);
|
||||||
|
this.syncSlotsNextTime = true;
|
||||||
this.sendUpdate();
|
this.sendUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int i, int j){
|
public ItemStack decrStackSize(int i, int j){
|
||||||
|
this.syncSlotsNextTime = true;
|
||||||
this.sendUpdate();
|
this.sendUpdate();
|
||||||
return super.decrStackSize(i, j);
|
return super.decrStackSize(i, j);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,38 +41,42 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||||
super.writeSyncableNBT(compound, isForSync);
|
super.writeSyncableNBT(compound, isForSync);
|
||||||
if(!isForSync || this.shouldSyncSlots()){
|
if(!isForSync){
|
||||||
if(this.slots.length > 0){
|
this.writeSlotsToCompound(compound);
|
||||||
NBTTagList tagList = new NBTTagList();
|
|
||||||
for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){
|
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
|
||||||
tagCompound.setByte("Slot", (byte)currentIndex);
|
|
||||||
if(slots[currentIndex] != null){
|
|
||||||
slots[currentIndex].writeToNBT(tagCompound);
|
|
||||||
}
|
|
||||||
tagList.appendTag(tagCompound);
|
|
||||||
}
|
|
||||||
compound.setTag("Items", tagList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSyncSlots(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||||
super.readSyncableNBT(compound, isForSync);
|
super.readSyncableNBT(compound, isForSync);
|
||||||
if(!isForSync || this.shouldSyncSlots()){
|
if(!isForSync){
|
||||||
if(this.slots.length > 0){
|
this.readSlotsFromCompound(compound);
|
||||||
NBTTagList tagList = compound.getTagList("Items", 10);
|
}
|
||||||
for(int i = 0; i < tagList.tagCount(); i++){
|
}
|
||||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
|
||||||
byte slotIndex = tagCompound.getByte("Slot");
|
public void writeSlotsToCompound(NBTTagCompound compound){
|
||||||
if(slotIndex >= 0 && slotIndex < slots.length){
|
if(this.slots.length > 0){
|
||||||
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
NBTTagList tagList = new NBTTagList();
|
||||||
}
|
for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){
|
||||||
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
|
tagCompound.setByte("Slot", (byte)currentIndex);
|
||||||
|
if(slots[currentIndex] != null){
|
||||||
|
slots[currentIndex].writeToNBT(tagCompound);
|
||||||
|
}
|
||||||
|
tagList.appendTag(tagCompound);
|
||||||
|
}
|
||||||
|
compound.setTag("Items", tagList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readSlotsFromCompound(NBTTagCompound compound){
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue