Skip to content

Instantly share code, notes, and snippets.

@dazsim
Created July 18, 2016 11:49
Show Gist options
  • Save dazsim/efcf1c3dca01cb228e97da14b1924ceb to your computer and use it in GitHub Desktop.
Save dazsim/efcf1c3dca01cb228e97da14b1924ceb to your computer and use it in GitHub Desktop.
this is the onBlockPlacedBy code
@Override
public void onBlockPlacedBy(World worldIn,BlockPos pos,IBlockState state,EntityLivingBase placer,ItemStack stack)
{
//grab settings from itemstack
if (worldIn == null)
{
System.out.println("EMPTY WORLD");
return;
}
if (pos == null)
{
System.out.println("EMPTY POS");
return;
}
if (stack == null)
{
System.out.println("EMPTY STACK");
return;
}
Boolean c,f;
NBTTagCompound n = new NBTTagCompound();
stack.readFromNBT(n);
c = n.getBoolean("comp");
f = n.getBoolean("frame");
TileEntityBarrel t;
TileEntity t1;
try {
t1 = (worldIn.getTileEntity(pos));
}
catch (NullPointerException e)
{
return;
}
if (t1!=null)
{
t = (TileEntityBarrel)t1;
if (t!=null)
{
t.init(c,f);
this.updateBarrel((TileEntityBarrel)worldIn.getTileEntity(pos));
}
}
//worldIn.getTileEntity(pos).init(stack.nbt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment