Posted January 1, 201510 yr Read The Below to understand Solution BLOCK Class package com.kitsu.medievalcraft.block.wood; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import com.kitsu.medievalcraft.Main; import com.kitsu.medievalcraft.block.ModBlocks; import com.kitsu.medievalcraft.item.ModItems; import com.kitsu.medievalcraft.renderer.RenderId; import com.kitsu.medievalcraft.tileents.TileEntitySmallLid; import com.kitsu.medievalcraft.tileents.ingots.TileEntityDamascusIngot; import com.kitsu.medievalcraft.util.CustomTab; public class SmallBarrelLid extends BlockContainer { public SmallBarrelLid(String unlocalizedName, Material material) { super(material); this.setBlockName(unlocalizedName); this.setBlockTextureName(Main.MODID + ":" + unlocalizedName); this.setCreativeTab(CustomTab.MedievalCraftTab); this.setHardness(1.0F); this.setResistance(1.0F); this.setHarvestLevel(null, 0); this.setStepSound(soundTypeWood); //xmin, ymin, zmin, //xmax, ymax, zmax //this.setBlockBounds(0.17F, 0.0F, 0.315F, // 0.8F, 0.15F, 0.725F); } public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) { if(!world.isRemote){ TileEntitySmallLid tileLid = (TileEntitySmallLid) world.getTileEntity(x, y, z); if(player.inventory.getCurrentItem()!=null){ if((player.getCurrentEquippedItem().getItem().equals(ModItems.splitBoard))){ if(tileLid.nbt.getInteger("LOGS")<{ player.inventory.decrStackSize(player.inventory.currentItem, 1); tileLid.nbt.setInteger("LOGS", tileLid.nbt.getInteger("LOGS")+1); world.markBlockForUpdate(x, y, z); return true; } } } if(player.inventory.getCurrentItem()!=null){ if((player.getCurrentEquippedItem().getItem().equals(ModItems.saplingRing))){ if(tileLid.nbt.getInteger("LOGS")=={ player.inventory.decrStackSize(player.inventory.currentItem, 1); tileLid.nbt.setInteger("RING", tileLid.nbt.getInteger("RING")+1); world.markBlockForUpdate(x, y, z); if(tileLid.nbt.getInteger("RING")==2){ if(!world.isRemote){ world.setBlock(x, y, z, ModBlocks.smallBarrel, 0, 2); return true; } } } } } } return false; } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntitySmallLid(); } @Override public int getRenderType() { return RenderId.smallLidID; } @Override public boolean renderAsNormalBlock() { return false; } @Override public boolean isOpaqueCube() { return false; } } TILE ENTITY Class package com.kitsu.medievalcraft.tileents; import com.kitsu.medievalcraft.block.ModBlocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class TileEntitySmallLid extends TileEntity { private String smallLidName; private int logs; private int ring; //public static boolean hitGood = false; public NBTTagCompound nbt = new NBTTagCompound(); public void smallLidName(String string){ this.smallLidName = string; } @Override public void updateEntity() { World world = this.getWorldObj(); int x = this.xCoord; int y = this.yCoord; int z = this.zCoord; if(!world.isRemote){ if(nbt.getInteger("RINGS")==2){ world.setBlock(x, y, z, ModBlocks.smallBarrel, 0, 2); } } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasKey("CustomName", ) { this.smallLidName = nbt.getString("CustomName"); } this.logs = nbt.getInteger("LOGS"); this.ring = nbt.getInteger("RING"); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("LOGS", logs); nbt.setInteger("RING", ring); } @Override public Packet getDescriptionPacket() { //NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 10, nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } //func_148857_g() }
January 1, 201510 yr Author Remove the NBTTagCompound field from your TE. It should not be there. How do i change the NBT of the tileEntity then from the block class? do i need to declare a NBTTagCompound nbt = new NBTTagCompound();
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.