Only prevent syncing when first loading the world
This commit is contained in:
@@ -41,6 +41,9 @@ public class TileEntityArcaneWorkbench extends TileEntity implements IInventory,
|
|||||||
|
|
||||||
public TileEntityArcaneWorkbench(){
|
public TileEntityArcaneWorkbench(){
|
||||||
inventory = NonNullList.withSize(ContainerArcaneWorkbench.UPGRADE_SLOT + 1, ItemStack.EMPTY);
|
inventory = NonNullList.withSize(ContainerArcaneWorkbench.UPGRADE_SLOT + 1, ItemStack.EMPTY);
|
||||||
|
// Prevent sync() happening when loading from NBT the first time or weirdness ensues when loading a world
|
||||||
|
// Normally I'd pass this as a flag to setInventorySlotContents but we can't change the method signature
|
||||||
|
this.doNotSync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,6 +59,8 @@ public class TileEntityArcaneWorkbench extends TileEntity implements IInventory,
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
|
this.doNotSync = false;
|
||||||
|
|
||||||
ItemStack stack = this.getStackInSlot(ContainerArcaneWorkbench.CENTRE_SLOT);
|
ItemStack stack = this.getStackInSlot(ContainerArcaneWorkbench.CENTRE_SLOT);
|
||||||
|
|
||||||
// Decrements wand damage (increases mana) every 1.5 seconds if it has a condenser upgrade
|
// Decrements wand damage (increases mana) every 1.5 seconds if it has a condenser upgrade
|
||||||
@@ -185,10 +190,6 @@ public class TileEntityArcaneWorkbench extends TileEntity implements IInventory,
|
|||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound){
|
public void readFromNBT(NBTTagCompound tagCompound){
|
||||||
|
|
||||||
// Prevent sync() happening when loading from NBT or weirdness ensues when loading a world
|
|
||||||
// Normally I'd pass this as a flag to setInventorySlotContents but we can't change the method signature
|
|
||||||
this.doNotSync = true;
|
|
||||||
|
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
|
||||||
NBTTagList tagList = tagCompound.getTagList("Inventory", NBT.TAG_COMPOUND);
|
NBTTagList tagList = tagCompound.getTagList("Inventory", NBT.TAG_COMPOUND);
|
||||||
@@ -199,8 +200,6 @@ public class TileEntityArcaneWorkbench extends TileEntity implements IInventory,
|
|||||||
setInventorySlotContents(slot, new ItemStack(tag));
|
setInventorySlotContents(slot, new ItemStack(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doNotSync = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,15 +28,19 @@ public class TileEntityBookshelf extends TileEntity implements IInventory, ITick
|
|||||||
|
|
||||||
public TileEntityBookshelf(){
|
public TileEntityBookshelf(){
|
||||||
inventory = NonNullList.withSize(BlockBookshelf.SLOT_COUNT, ItemStack.EMPTY);
|
inventory = NonNullList.withSize(BlockBookshelf.SLOT_COUNT, ItemStack.EMPTY);
|
||||||
|
// Prevent sync() happening when loading from NBT or weirdness ensues when loading a world
|
||||||
|
// Normally I'd pass this as a flag to setInventorySlotContents but we can't change the method signature
|
||||||
|
this.doNotSync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called to manually sync the tile entity with clients. */
|
/** Called to manually sync the tile entity with clients. */
|
||||||
public void sync(){
|
public void sync(){
|
||||||
if(!doNotSync) this.world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
if(!this.doNotSync) this.world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
this.doNotSync = false;
|
||||||
// Nothing here for now
|
// Nothing here for now
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,10 +143,6 @@ public class TileEntityBookshelf extends TileEntity implements IInventory, ITick
|
|||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound){
|
public void readFromNBT(NBTTagCompound tagCompound){
|
||||||
|
|
||||||
// Prevent sync() happening when loading from NBT or weirdness ensues when loading a world
|
|
||||||
// Normally I'd pass this as a flag to setInventorySlotContents but we can't change the method signature
|
|
||||||
this.doNotSync = true;
|
|
||||||
|
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
|
||||||
NBTTagList tagList = tagCompound.getTagList("Inventory", NBT.TAG_COMPOUND);
|
NBTTagList tagList = tagCompound.getTagList("Inventory", NBT.TAG_COMPOUND);
|
||||||
@@ -153,8 +153,6 @@ public class TileEntityBookshelf extends TileEntity implements IInventory, ITick
|
|||||||
setInventorySlotContents(slot, new ItemStack(tag));
|
setInventorySlotContents(slot, new ItemStack(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doNotSync = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user