public interface Converter
A converter must always provide a way to serialize and deserialize a block to avoid creation of blueprints that can no longer be deserialized and other potentially unexpected behavior. A converter may however support any number of blocks, as long as this rule is not violated.
| Modifier and Type | Method and Description |
|---|---|
void |
cancelDeserialization(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
Cancel a pending deserialization that has already been prepared.
|
boolean |
canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Checks if this converter can be used to serialize the block at the
specified world position.
|
void |
deserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
Deserialize the specified serialized block data into the world at the
specified world position.
|
java.lang.Iterable<net.minecraftforge.fluids.FluidStack> |
getFluidCosts(net.minecraft.nbt.NBTBase data)
Get a list of materials required to deserialize the block described by
the specified data.
|
java.lang.Iterable<net.minecraft.item.ItemStack> |
getItemCosts(net.minecraft.nbt.NBTBase data)
Get a list of materials required to deserialize the block described by
the specified data.
|
int |
getSortIndex(net.minecraft.nbt.NBTBase data)
A sort index used to control in which order blocks are deserialized.
|
java.util.UUID |
getUUID()
A constant UUID representing this converter.
|
boolean |
preDeserialize(MaterialSource materialSource,
net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
Called when a job for deserialization should be created.
|
net.minecraft.nbt.NBTBase |
serialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Creates a serialized representation of the block at the specified world
position.
|
java.util.UUID getUUID()
This is used to look up a converter for deserialization, so the returned value must be the same across any number of game starts.
java.lang.Iterable<net.minecraft.item.ItemStack> getItemCosts(net.minecraft.nbt.NBTBase 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.java.lang.Iterable<net.minecraftforge.fluids.FluidStack> getFluidCosts(net.minecraft.nbt.NBTBase 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.int getSortIndex(net.minecraft.nbt.NBTBase 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.SortIndexboolean 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 converter can serialize the block;
false otherwise;net.minecraft.nbt.NBTBase serialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
This is guaranteed to only called if canSerialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) returned
true for the passed parameters.
world - the world containing the block to serialize.pos - the position of the block to serialize.boolean preDeserialize(MaterialSource materialSource, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, net.minecraft.util.Rotation rotation, net.minecraft.nbt.NBTBase 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.
materialSource - 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.void deserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase 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.void cancelDeserialization(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
This is called if the location to deserialize into has become occupied
after preDeserialize(li.cil.architect.api.converter.MaterialSource, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.Rotation, net.minecraft.nbt.NBTBase) was called, but before deserialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.Rotation, net.minecraft.nbt.NBTBase)
could be called.
To avoid destruction of materials consumed in pre-deserialization, this
method should spawn the consumed materials as EntityItems
in the world, preferably at or around the location the deserialization
would have taken place at.
world - the world the deserialization would have occurred in.pos - the position the deserialization would have occurred at.rotation - the rotation the deserialization would have occurred
with.data - the serialized representation of the block that would
have been deserialized.