public interface IMixinBlock
Block
such that their
acceptable BlockState
s can be created, manipulated, and applied
with the safety of using these instance checks of the IMixinBlock
.
The advantage of this is that a simple cast from Block
to a
particular IMixinBlock
to take advantage of particular Value
types, are really simple to perform.
It is important to note that when using this level of implementation,
it is already guaranteed that a particular IMixinBlock
is capable
of a particular type thanks to Mixin
s. All that is needed to handle
a particular type of Value
or ImmutableDataManipulator
is a
simple cast. This is particularly useful for BlockState
s as
they already know the type they need to focus on.
Modifier and Type | Method and Description |
---|---|
org.spongepowered.api.block.BlockState |
getDefaultBlockState()
Gets the default
BlockState as an api representation. |
List<org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?>> |
getManipulators(net.minecraft.block.state.IBlockState blockState)
Gets all the
ImmutableDataManipulator s for the provided
IBlockState . |
Optional<org.spongepowered.api.block.BlockState> |
getStateWithData(net.minecraft.block.state.IBlockState blockState,
org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?> manipulator)
Again, another delegate method directly to the block, usually not all
required, but it does help if the block does support the manipulator
in the first place.
|
<E> Optional<org.spongepowered.api.block.BlockState> |
getStateWithValue(net.minecraft.block.state.IBlockState blockState,
org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<E>> key,
E value)
Instead of delegating to a block processor, we can delegate to the block
to retrieve the correct
BlockState if supported. |
boolean |
isFlammable(net.minecraft.world.IBlockAccess blockAccess,
net.minecraft.util.BlockPos pos,
net.minecraft.util.EnumFacing facing) |
boolean |
supports(Class<? extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?>> immutable)
A simple check whether the class is supported by the block or not.
|
List<org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?>> getManipulators(net.minecraft.block.state.IBlockState blockState)
ImmutableDataManipulator
s for the provided
IBlockState
.blockState
- The block state being passed inboolean supports(Class<? extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?>> immutable)
immutable
- The immutable class<E> Optional<org.spongepowered.api.block.BlockState> getStateWithValue(net.minecraft.block.state.IBlockState blockState, org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<E>> key, E value)
BlockState
if supported. Considering
block processors would require to know of the blocks themselves, it is
easier to use the block to understand what data is being offered,
and the current block state being used. Since all of the data is already
relatively kept in the block state instance, it is therefor very well
possible to cycle according to the block instance.E
- The type of value, for type checkingblockState
- The block state to use as a basekey
- The key to the datavalue
- The valueOptional<org.spongepowered.api.block.BlockState> getStateWithData(net.minecraft.block.state.IBlockState blockState, org.spongepowered.api.data.manipulator.ImmutableDataManipulator<?,?> manipulator)
blockState
- The block state to base off ofmanipulator
- The manipulator being offeredorg.spongepowered.api.block.BlockState getDefaultBlockState()
BlockState
as an api representation.boolean isFlammable(net.minecraft.world.IBlockAccess blockAccess, net.minecraft.util.BlockPos pos, net.minecraft.util.EnumFacing facing)