Advertisement
Creepinson

For Phoenix SC

Aug 29th, 2017
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. I found this method on a java code example website, credit goes to whoever made this: https://www.programcreek.com/java-api-examples/index.php?source_dir=NewCommands-master/Common/src/net/minecraft/command/CommandUtilities.java
  2. I thought this could be a way to set NBT of a block like command blocks?
  3. Anyway, here you go!
  4.  
  5. public static void setNBT(final World world, final BlockPos pos, final NBTTagCompound nbt)
  6. {
  7. final TileEntity te = world.getTileEntity(pos);
  8.  
  9. if (te == null)
  10. return;
  11.  
  12. nbt.setInteger("x", pos.getX());
  13. nbt.setInteger("y", pos.getY());
  14. nbt.setInteger("z", pos.getZ());
  15.  
  16. te.readFromNBT(nbt);
  17.  
  18. te.markDirty();
  19. world.markBlockForUpdate(pos);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement