public abstract class AbstractConverter extends java.lang.Object implements Converter
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConverter(java.util.UUID uuid) |
| 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.
|
protected abstract boolean |
canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state) |
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.
|
protected net.minecraft.block.state.IBlockState |
getBlockState(net.minecraft.nbt.NBTBase data)
Get the block state serialized in the specified data.
|
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.
|
protected net.minecraftforge.fluids.FluidStack |
getFluidStack(net.minecraft.nbt.NBTBase data)
Get the fluid stack required as materials to deserialize the block stored
in 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.
|
protected net.minecraft.item.ItemStack |
getItemStack(net.minecraft.item.Item item,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTBase data)
Resolve an item to an actual item stack.
|
protected net.minecraft.item.ItemStack |
getItemStack(net.minecraft.nbt.NBTBase data)
Get the item stack required as materials to deserialize the block stored
in 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.
|
protected void |
postDeserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTTagCompound data)
Allows hooking into the deserialization process, applying further changes
to the deserialized block.
|
protected void |
postSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTTagCompound data)
Allows hooking into the serialization process, adding additional NBT
data to the tag compound returned from the basic serialization.
|
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.
|
protected abstract boolean canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state)
public java.util.UUID getUUID()
ConverterThis is used to look up a converter for deserialization, so the returned value must be the same across any number of game starts.
public java.lang.Iterable<net.minecraft.item.ItemStack> getItemCosts(net.minecraft.nbt.NBTBase data)
Converter
The data passed along is guaranteed to be a value that was previously
produced by this converter's Converter.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.
getItemCosts in interface Converterdata - the data to get the costs for.public java.lang.Iterable<net.minecraftforge.fluids.FluidStack> getFluidCosts(net.minecraft.nbt.NBTBase data)
Converter
The data passed along is guaranteed to be a value that was previously
produced by this converter's Converter.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.
getFluidCosts in interface Converterdata - the data to get the costs for.public int getSortIndex(net.minecraft.nbt.NBTBase data)
ConverterBlocks 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).
getSortIndex in interface Converterdata - the serialized representation of the block in question.SortIndexpublic boolean canSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
ConvertercanSerialize in interface Converterworld - 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;public net.minecraft.nbt.NBTBase serialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Converter
This is guaranteed to only called if Converter.canSerialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) returned
true for the passed parameters.
public 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)
Converter
The passed NBTBase passed along is guaranteed to be a value that
was previously produced by this converter's Converter.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.
preDeserialize in interface ConvertermaterialSource - 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 void deserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
Converter
The passed NBTBase passed along is guaranteed to be a value that
was previously produced by this converter's Converter.serialize(net.minecraft.world.World, net.minecraft.util.math.BlockPos) method.
deserialize in interface Converterworld - 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.public void cancelDeserialization(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.Rotation rotation,
net.minecraft.nbt.NBTBase data)
Converter
This is called if the location to deserialize into has become occupied
after Converter.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 Converter.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.
cancelDeserialization in interface Converterworld - 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.protected void postSerialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTTagCompound data)
Note that the tags name and meta will already
be set in the passed NBTTagCompound, and should usually not be
overwritten.
world - the world the block to serialize lives in.pos - the position of the block to serialize.state - the block state of the block to serialize.data - the tag generated from the serialization process so far.protected void postDeserialize(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTTagCompound data)
world - the world the block is being deserialized into.pos - the position the block is being deserialized at.state - the block state of the deserialized block.data - the serialized representation of the block to@Nullable protected net.minecraft.block.state.IBlockState getBlockState(net.minecraft.nbt.NBTBase data)
data - the serialized representation of the block.protected net.minecraft.item.ItemStack getItemStack(net.minecraft.nbt.NBTBase data)
data - the serialized representation of the block.protected net.minecraft.item.ItemStack getItemStack(net.minecraft.item.Item item,
net.minecraft.block.state.IBlockState state,
net.minecraft.nbt.NBTBase data)
item - the item to create an item stack for.state - the block state based on which to create the item.data - the serialized representation of the block.@Nullable protected net.minecraftforge.fluids.FluidStack getFluidStack(net.minecraft.nbt.NBTBase data)
data - the serialized representation of the block.