protected final void processDrop(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable T te, @Nonnull ItemStack drop) { if (te != null) { te.writeCustomNBT(drop); } }
/** * SERVER: Called when being written to the save file. */ @Override public final @Nonnull NBTTagCompound writeToNBT(@Nonnull NBTTagCompound root) { super.writeToNBT(root); writeCustomNBT(NBTAction.SAVE, root); return root; }
@Deprecated protected abstract void writeCustomNBT(@Nonnull NBTAction action, @Nonnull NBTTagCompound root);
/** * Called when the chunk data is sent (client receiving chunks from server). Must have x/y/z tags. */ @Override public final @Nonnull NBTTagCompound getUpdateTag() { NBTTagCompound tag = super.getUpdateTag(); writeCustomNBT(NBTAction.CLIENT, tag); if (isProgressTile) { // TODO: nicer way to do this? This is needed so players who enter a chunk get a correct progress. tag.setFloat("tileprogress", ((IProgressTile) this).getProgress()); } return tag; }
/** * SERVER: Called when block data is sent (client receiving blocks from server, via notifyBlockUpdate). No need for x/y/z tags. */ @Override public final SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); writeCustomNBT(NBTAction.CLIENT, tag); if (isProgressTile) { // TODO: nicer way to do this? This is needed so players who enter a chunk get a correct progress. tag.setFloat("tileprogress", ((IProgressTile) this).getProgress()); } return new SPacketUpdateTileEntity(getPos(), 1, tag); }