@AutoLoad public class BlockDataHandler extends java.lang.Object
BlockDataHandler handles custom data being stored for a specific BlockPos.
Custom data is identified by a String identifier, and a way to convert from and into a ByteBuf using
registerBlockData(String, Function, Function).
Custom data is then stored and retreived using setData(String, IBlockAccess, BlockPos, Object),
getData(String, IBlockAccess, BlockPos) and removeData(String, IBlockAccess, BlockPos) with the corresponding
identifier.
| Modifier and Type | Method and Description |
|---|---|
static BlockDataHandler |
get() |
static <T> T |
getData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos)
Gets the custom data stored at the
BlockPos for the specified identifier. |
void |
onChunkWatched(net.minecraftforge.event.world.ChunkWatchEvent.Watch event)
Server only.
|
void |
onDataLoad(net.minecraftforge.event.world.ChunkDataEvent.Load event)
Saves the data in NBT for the
Chunk. |
void |
onDataSave(net.minecraftforge.event.world.ChunkDataEvent.Save event)
On data save.
|
void |
onDataUnload(net.minecraftforge.event.world.ChunkEvent.Unload event)
Unloads the data for the
Chunk. |
static <T> void |
registerBlockData(java.lang.String identifier,
com.google.common.base.Function<io.netty.buffer.ByteBuf,T> from,
com.google.common.base.Function<T,io.netty.buffer.ByteBuf> to)
Registers a custom block data with the specified identifier.
|
static <T> void |
removeData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos)
Removes the custom data stored at the
BlockPos for the specified identifier. |
static <T> void |
setData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos,
T data)
Sets the custom data to be stored at the
BlockPos for the specified identifier. |
public void onDataLoad(net.minecraftforge.event.world.ChunkDataEvent.Load event)
Chunk.Chunk is marked as unloaded.event - the eventpublic void onDataSave(net.minecraftforge.event.world.ChunkDataEvent.Save event)
event - the eventpublic void onDataUnload(net.minecraftforge.event.world.ChunkEvent.Unload event)
Chunk.event - the eventpublic void onChunkWatched(net.minecraftforge.event.world.ChunkWatchEvent.Watch event)
event - the eventpublic static <T> void registerBlockData(java.lang.String identifier,
com.google.common.base.Function<io.netty.buffer.ByteBuf,T> from,
com.google.common.base.Function<T,io.netty.buffer.ByteBuf> to)
T - the generic typeidentifier - the identifierfrom - the fromto - the topublic static <T> T getData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos)
BlockPos for the specified identifier.T - the generic typeidentifier - the identifierworld - the worldpos - the pospublic static <T> void setData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos,
T data)
BlockPos for the specified identifier.T - the generic typeidentifier - the identifierworld - the worldpos - the posdata - the datapublic static <T> void removeData(java.lang.String identifier,
net.minecraft.world.IBlockAccess world,
net.minecraft.util.math.BlockPos pos)
BlockPos for the specified identifier.T - the generic typeidentifier - the identifierworld - the worldpos - the pospublic static BlockDataHandler get()