Interface IDecayBlock
- All Superinterfaces:
IBlockItemPropertiesProvider
,IDecayBlockIdentifier
- All Known Implementing Classes:
DecayBlockBase
,DecayDirtMyceliumBlock
,DecayLiquidBlock
,DecayLogBase
,DecayLogBlock
,DecayPlantMatterBlock
,DecayStrippedLogBlock
,DecaySurfaceMyceliumBlock
An extension to
Blocks implementing IDecayBlock are implicitly classified as decay blocks (for obvious reasons), but also contain the more aggressive behaviors of The Decay in that they will spread and infect nearby blocks. The blocks that it can spread to and infect depend on the implementation of the block itself.
IDecayBlockIdentifier
that goes beyond the mere definition of being a Decay block.Blocks implementing IDecayBlock are implicitly classified as decay blocks (for obvious reasons), but also contain the more aggressive behaviors of The Decay in that they will spread and infect nearby blocks. The blocks that it can spread to and infect depend on the implementation of the block itself.
- Author:
- Eti
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
defaultNeighborChanged
(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.Block blockIn, net.minecraft.world.level.block.state.BlockState fromState, net.minecraft.core.BlockPos fromPos, boolean isMoving) The default logic for when a neighbor of this decay block is changed.default void
defaultOnEntityWalked
(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.Entity entityIn) The default logic for when an entity walks on this decay block.default void
defaultRandomTick
(net.minecraft.world.level.block.state.BlockState state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default behavior that should generally occur on a random tick for a decay block.default void
doAdjacentSpread
(net.minecraft.world.level.block.state.StateHolder<?, ?> state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default routine for spreading to / infecting adjacent blocks.default void
doDiagonalSpread
(net.minecraft.world.level.block.state.StateHolder<?, ?> state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default routine for spreading to / infecting diagonally oriented blocks (2D or 3D).default net.minecraft.world.level.block.state.StateHolder<?,
?> getDecayReplacementFor
(net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) When Decay blocks are registered, they define which block states or fluid states they replace, and what state to replace those with.
This method can be used to look up what a block's block replacement is, e.g.static net.minecraft.world.level.block.state.StateHolder<?,
?> getDefaultDecayReplacementFor
(net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) When Decay blocks are registered, they define which block or fluid states they replace, and what state to replace those with.
This method can be used to look up what a block's replacement is, e.g.default boolean[]
getNonDecayableAdjacents
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Returns an array of 6 boolean values mapping in the order of: EAST, WEST, UP, DOWN, NORTH, SOUTH
A given boolean is true if the corresponding block has no decay replacement.default boolean
hasDecayReplacementFor
(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos at, net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) Returns whether or not a replacement for the given state exists.net.minecraft.world.level.block.state.BlockState
healsInto
(net.minecraft.world.level.block.state.BlockState thisState) When this Decay block is cured, this is theBlockState
(of some vanilla or mod block) that it should heal into.default net.minecraft.world.level.block.state.StateHolder<?,
?> mutateReplacementState
(net.minecraft.world.level.block.state.StateHolder<?, ?> originalState, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos replacingBlockAt) Provides a means of altering the given state.default boolean
needsToDoEdgeCheck
(net.minecraft.util.RandomSource rng, int edgeDetectionRarity, int denominatorOfMinChance) Checks if this tick operation should be changed into an edge check.default boolean
needsToSpread
(net.minecraft.world.level.block.state.StateHolder<?, ?> decayBlock) Returns whether or not this decay block needs to spread because one or more of its adjacent blocks is not a decay block.default net.minecraft.core.BlockPos
randomUnoccupiedDiagonal
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos originalPos, net.minecraft.util.RandomSource rng) Returns one of the (up to) 20 possible diagonal adjacent directions that are occupied by a block that can decay.default net.minecraft.core.BlockPos
randomUnoccupiedDirection
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos originalPos, net.minecraft.util.RandomSource rng) Returns a random unoccupied adjacent block.static void
registerAllStatesFor
(List<net.minecraft.world.level.block.state.StateHolder<?, ?>> blocksToReplaceWithSelf, net.minecraft.world.level.block.Block from) When given a list of BlockStates and a Block instance, this will iterate through all of its states and put them into the list.void
registerReplacements
(List<net.minecraft.world.level.block.state.StateHolder<?, ?>> blocksToReplaceWithSelf) Register all of the blocks or fluids that this decay block will replace with itself once those blocks are infected.default boolean
shouldSpreadByRNG
(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos at) Returns whether or not this should be allowed to spread in general.Methods inherited from interface etithespirit.orimod.common.block.decay.IDecayBlockIdentifier
getPropertiesOfItem
-
Method Details
-
registerAllStatesFor
static void registerAllStatesFor(List<net.minecraft.world.level.block.state.StateHolder<?, ?>> blocksToReplaceWithSelf, net.minecraft.world.level.block.Block from) When given a list of BlockStates and a Block instance, this will iterate through all of its states and put them into the list.- Parameters:
blocksToReplaceWithSelf
- This is a list storing all block states that can be replaced by this Decay block.from
- All states of this block will be registered as replacable by this Decay block.
-
getDecayReplacementFor
@Nullable default net.minecraft.world.level.block.state.StateHolder<?,?> getDecayReplacementFor(net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) When Decay blocks are registered, they define which block states or fluid states they replace, and what state to replace those with.
This method can be used to look up what a block's block replacement is, e.g. pass inBlocks.STONE.getDefaultState()
to receive the Decay-equivalent of stone.
Returns null if there is no substitute.
This is a per-instance sensitive variant of the function and should always be called if an instance of the spreading Decay block is available.- Parameters:
existingBlock
- The block that will be replaced.- Returns:
- The replacement blockstate, or null if there is no replacement.
-
getDefaultDecayReplacementFor
@Nullable static net.minecraft.world.level.block.state.StateHolder<?,?> getDefaultDecayReplacementFor(net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) When Decay blocks are registered, they define which block or fluid states they replace, and what state to replace those with.
This method can be used to look up what a block's replacement is, e.g. pass inBlocks.STONE.getDefaultState()
to receive the Decay-equivalent of stone.
Returns null if there is no substitute.
This should only be called if there is no spreading Decay block to call thegetDecayReplacementFor(StateHolder)
method on, as this does not respect per-block custom behavior.- Parameters:
existingBlock
- The block that will be replaced.- Returns:
- The replacement blockstate, or null if there is no replacement.
-
hasDecayReplacementFor
default boolean hasDecayReplacementFor(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos at, net.minecraft.world.level.block.state.StateHolder<?, ?> existingBlock) Returns whether or not a replacement for the given state exists. This works for block and fluid states.- Parameters:
worldIn
- TheLevel
that this block exists in.at
- The location of this block in the world.existingBlock
- The block that may be replaced.- Returns:
- Whether or not this block actually has a replacement.
-
needsToSpread
default boolean needsToSpread(net.minecraft.world.level.block.state.StateHolder<?, ?> decayBlock) Returns whether or not this decay block needs to spread because one or more of its adjacent blocks is not a decay block. This works for blocks and fluids.- Parameters:
decayBlock
- The block that should be checked for spreadability.- Returns:
- Whether or not this block should spread.
-
shouldSpreadByRNG
default boolean shouldSpreadByRNG(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos at) Returns whether or not this should be allowed to spread in general.- Parameters:
worldIn
- The world to check in.at
- The location of this block.- Returns:
- True if this decay block should spread now, false if it should try again on the next random tick.
-
needsToDoEdgeCheck
default boolean needsToDoEdgeCheck(net.minecraft.util.RandomSource rng, int edgeDetectionRarity, int denominatorOfMinChance) Checks if this tick operation should be changed into an edge check.- Parameters:
rng
- A randomizeredgeDetectionRarity
- The denominator of the current detection rarity.denominatorOfMinChance
- The denominator of the lowest possible chance that can ever occur.- Returns:
- Whether or not this block needs to do an edge check on this tick.
-
mutateReplacementState
default net.minecraft.world.level.block.state.StateHolder<?,?> mutateReplacementState(net.minecraft.world.level.block.state.StateHolder<?, ?> originalState, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos replacingBlockAt) Provides a means of altering the given state. The input state is the state of this block when it replaces a non-decay block.- Parameters:
originalState
- The default state of this decay blockworld
- The world that the state is being placed into.replacingBlockAt
- THe location of the block that is being replaced in the world.- Returns:
- The state of the decay block when replacing a given block.
-
getNonDecayableAdjacents
default boolean[] getNonDecayableAdjacents(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Returns an array of 6 boolean values mapping in the order of: EAST, WEST, UP, DOWN, NORTH, SOUTH
A given boolean is true if the corresponding block has no decay replacement. Note that decay blocks are not decayable either. As such, this method better describes when a block is stopping decay spread.- Parameters:
world
- TheLevel
that this block exists in.pos
- The location of this block in the level it exits in.- Returns:
- Six boolean values in the order of EAST, WEST, UP, DOWN, NORTH, SOUTH that represents whether or not the given adjacent block in that direction can be mutated.
-
randomUnoccupiedDirection
default net.minecraft.core.BlockPos randomUnoccupiedDirection(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos originalPos, net.minecraft.util.RandomSource rng) Returns a random unoccupied adjacent block. "Unoccupied" refers to meaning that the adjacent space has a valid decay block replacement.- Parameters:
world
- The world to check in.originalPos
- The position of this block.rng
- A randomizer used to select a random direction.- Returns:
- An adjacent
BlockPos
in a random cardinal direction that is able to decay.
-
randomUnoccupiedDiagonal
default net.minecraft.core.BlockPos randomUnoccupiedDiagonal(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos originalPos, net.minecraft.util.RandomSource rng) Returns one of the (up to) 20 possible diagonal adjacent directions that are occupied by a block that can decay.- Parameters:
world
- The world to test in.originalPos
- The location of this block.rng
- A randomizer used to select a random diagonal.- Returns:
- One of the (up to) 20 possible diagonal adjacent directions that are occupied by a block that can decay.
-
healsInto
net.minecraft.world.level.block.state.BlockState healsInto(net.minecraft.world.level.block.state.BlockState thisState) When this Decay block is cured, this is theBlockState
(of some vanilla or mod block) that it should heal into.- Returns:
- The vanilla or mod block that this decay block turns into once cured.
-
defaultRandomTick
default void defaultRandomTick(net.minecraft.world.level.block.state.BlockState state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default behavior that should generally occur on a random tick for a decay block.- Parameters:
state
- The block that is ticking.worldIn
- TheLevel
that this block is ticking in.pos
- The location at which this block is ticking.random
- The pseudorandomizer of this world.
-
doAdjacentSpread
default void doAdjacentSpread(net.minecraft.world.level.block.state.StateHolder<?, ?> state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default routine for spreading to / infecting adjacent blocks.- Parameters:
state
- The block that is responsible for the spreading.worldIn
- TheLevel
that this spread is occurring in.pos
- The location at which this block exists.random
- The pseudorandomizer of this world.
-
doDiagonalSpread
default void doDiagonalSpread(net.minecraft.world.level.block.state.StateHolder<?, ?> state, net.minecraft.server.level.ServerLevel worldIn, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random) The default routine for spreading to / infecting diagonally oriented blocks (2D or 3D). This can be imagined with the current block being the center of a 3x3x3 cube. It applies to all blocks that are not directly adjacent to one of the six faces of this block.- Parameters:
state
- The block that is responsible for the spreading.worldIn
- TheLevel
that this spread is occurring in.pos
- The location at which this block exists.random
- The pseudorandomizer of this world.
-
registerReplacements
void registerReplacements(List<net.minecraft.world.level.block.state.StateHolder<?, ?>> blocksToReplaceWithSelf) Register all of the blocks or fluids that this decay block will replace with itself once those blocks are infected.- Parameters:
blocksToReplaceWithSelf
- A list of every block that is replaced by this upon infection.
-
defaultNeighborChanged
default void defaultNeighborChanged(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.Block blockIn, net.minecraft.world.level.block.state.BlockState fromState, net.minecraft.core.BlockPos fromPos, boolean isMoving) The default logic for when a neighbor of this decay block is changed.- Parameters:
state
- This block's state.worldIn
- TheLevel
in which this change is occurring.pos
- The location at which this change is occurring.blockIn
- The block itself.fromState
- The state of the block that changed.fromPos
- The location of the block that changed.isMoving
- Whether or not this change is the result of a piston.
-
defaultOnEntityWalked
default void defaultOnEntityWalked(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.Entity entityIn) The default logic for when an entity walks on this decay block.- Parameters:
worldIn
- TheLevel
in which this occurred.pos
- The location of the block that was walked on.entityIn
- The entity that walked on the block.
-