Fixed model setting and client synchronisation

This commit is contained in:
Goodbird committed 2024-01-21 23:38:06 +03:00
1 parent 34cc0fecdf
commit ed3028561b
2 files changed
+11 -2

No files matched your search

@@ -106,7 +106,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
}
public void setDisplayNBT(NBTTagCompound compound){
itemModel = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ScriptBlockModel"));
if(itemModel.stackSize == 0)
if(itemModel==null || itemModel.stackSize == 0)
itemModel = new ItemStack(Item.getItemFromBlock(CustomItems.scripted));
if(compound.hasKey("ScriptBlockModelBlock"))
blockModel = Block.getBlockFromName(compound.getString("ScriptBlockModelBlock"));
@@ -215,6 +215,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
ticksExisted = 0;
if(needsClientUpdate){
markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,getBlockType(),3);
needsClientUpdate = false;
}
@@ -36,7 +36,15 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
tile.setItemModel(null, null);
else{
Block block = Block.getBlockFromName(name);
tile.setItemModel(new ItemStack(Item.getItemFromBlock(block)), block);
if(block!=null) {
tile.setItemModel(new ItemStack(Item.getItemFromBlock(block)), block);
}else{
if(Item.itemRegistry.containsKey(name)) {
tile.setItemModel(new ItemStack((Item) Item.itemRegistry.getObject(name)), null);
}else{
tile.setItemModel(null, null);
}
}
}
}