public final class ConverterAPI
extends java.lang.Object
Converters.
When trying to serialize a block in the world, all registered converters will
be queried, until one returns something not null from their
Converter.serialize(World, BlockPos) method.
This is made available in the init phase, so you'll either have to (soft) depend on the mod, or you must not make calls to this before the init phase.
| Modifier and Type | Method and Description |
|---|---|
static void |
addConverter(Converter converter)
Register the specified converter.
|
static boolean |
canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Checks if the block at the specified world position can be serialized.
|
static void |
deserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTTagCompound data)
Deserialize the specified serialized block data into the world at the
specified world position.
|
static java.lang.Iterable<net.minecraftforge.fluids.FluidStack> |
getFluidCosts(net.minecraft.nbt.NBTTagCompound data)
Get a list of materials required to deserialize the block described by
the specified data.
|
static java.lang.Iterable<net.minecraft.item.ItemStack> |
getItemCosts(net.minecraft.nbt.NBTTagCompound data)
Get a list of materials required to deserialize the block described by
the specified data.
|
static int |
getSortIndex(net.minecraft.nbt.NBTTagCompound data)
A sort index used to control in which order blocks are deserialized.
|
static net.minecraft.block.state.IBlockState |
mapToBlock(net.minecraft.block.state.IBlockState state)
Map a block to a potential replacement, based on current mapping
configuration.
|
static net.minecraft.item.Item |
mapToItem(net.minecraft.block.Block block)
Get the item associated with the specified block.
|
static boolean |
preDeserialize(MaterialSource itemSource,
net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTTagCompound data)
Called when a job for deserialization should be created.
|
static net.minecraft.nbt.NBTTagCompound |
serialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Creates a serialized representation of the block at the specified world
position.
|
public static void addConverter(Converter converter)
converter - the converter to register.@Nullable public static net.minecraft.block.state.IBlockState mapToBlock(net.minecraft.block.state.IBlockState state)
lit_furnace to
furnace.state - the block state to resolve the mapping for.@Nullable public static net.minecraft.item.Item mapToItem(net.minecraft.block.Block block)
Item.getItemFromBlock(Block).block - the block to get the item for.public static java.lang.Iterable<net.minecraft.item.ItemStack> getItemCosts(net.minecraft.nbt.NBTTagCompound data)
The data passed along is guaranteed to be a value that was previously
produced by this converter's serialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) method.
This will typically return a singleton list or an empty list, but for more complex converters, e.g. ones handling multi-part blocks this returns an iterable.
This is not used for logic, purely for user feedback, e.g. in tooltips.
data - the data to get the costs for.public static java.lang.Iterable<net.minecraftforge.fluids.FluidStack> getFluidCosts(net.minecraft.nbt.NBTTagCompound data)
The data passed along is guaranteed to be a value that was previously
produced by this converter's serialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) method.
This will typically return a singleton list or an empty list, but for more complex converters, e.g. ones handling multi-part blocks this returns an iterable.
This is not used for logic, purely for user feedback, e.g. in tooltips.
data - the data to get the costs for.public static int getSortIndex(net.minecraft.nbt.NBTTagCompound data)
Blocks being deserialized using converters that provide lower numbers here will be processed first.
This allows deserialization of solid blocks (e.g. cobble) before non- solid blocks (e.g. levers, water).
data - the serialized representation of the block in question.SortIndexpublic static boolean canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
world - the world containing the block to serialize.pos - the position of the block to serialize.true if the block can be serialized;
false otherwise.@Nullable
public static net.minecraft.nbt.NBTTagCompound serialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
world - the world containing the block to serialize.pos - the position of the block to serialize.public static boolean preDeserialize(MaterialSource itemSource, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, net.minecraft.util.Rotation rotation, net.minecraft.nbt.NBTTagCompound data)
The passed NBTBase passed along is guaranteed to be a value that
was previously produced by this converter's serialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) method.
This serves as a filter for which blocks in a blueprint actually can be
deserialized, in particular with respect to available materials which
are consumed from the specified IItemHandler.
itemSource - access to building materials available for deserialization.world - the world into which to deserialize the block.pos - the position at which to deserialize the block.rotation - the rotation to deserialize with.data - the serialized representation of the block to deserialize.true if the data can be deserialized;
false otherwise.public static void deserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTTagCompound data)
The passed NBTBase passed along is guaranteed to be a value that
was previously produced by this converter's serialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) method.
world - the world to deserialize the block into.pos - the position to deserialize the block at.rotation - the rotation to deserialize with.data - the serialized representation of the block to deserialize.