Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- I thought this could be a way to set NBT of a block like command blocks?
- Anyway, here you go!
- public static void setNBT(final World world, final BlockPos pos, final NBTTagCompound nbt)
- {
- final TileEntity te = world.getTileEntity(pos);
- if (te == null)
- return;
- nbt.setInteger("x", pos.getX());
- nbt.setInteger("y", pos.getY());
- nbt.setInteger("z", pos.getZ());
- te.readFromNBT(nbt);
- te.markDirty();
- world.markBlockForUpdate(pos);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement