Class AlterGroundEvent
AlterGroundDecorator.placeBlockAt(TreeDecorator.Context, BlockPos)
attempts to alter a ground block when generating a feature.An example of this would be large spruce trees converting grass blocks into podzol.
This event is not
invalid reference
cancellable
This event is fired on the main Forge event bus only on the logical server.
This event is fired on worker threads, meaning it is unsafe to access external global state.
Doing so may induce ConcurrentModificationException
or deadlocks.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate final TreeDecorator.Context
private AlterGroundEvent.StateProvider
-
Constructor Summary
ConstructorDescriptionAlterGroundEvent
(TreeDecorator.Context ctx, List<BlockPos> positions, AlterGroundEvent.StateProvider provider) -
Method Summary
Modifier and TypeMethodDescriptionGets the tree decoration context for the current alteration.The list of positions that are considered roots is different depending on if the context has roots, logs, or both.Gets the currentBlockStateProvider
that will be used by theAlterGroundDecorator
.void
Sets theBlockStateProvider
that will be used by theAlterGroundDecorator
.
Because this may be modified by multiple mods, it is advisable to wrap the current provider.
-
Field Details
-
ctx
-
positions
-
provider
-
-
Constructor Details
-
AlterGroundEvent
@Internal public AlterGroundEvent(TreeDecorator.Context ctx, List<BlockPos> positions, AlterGroundEvent.StateProvider provider)
-
-
Method Details
-
getContext
Gets the tree decoration context for the current alteration. -
getPositions
The list of positions that are considered roots is different depending on if the context has roots, logs, or both.If roots are not present, this list is equivalent to the logs.
If there are roots, and the roots have the same y-level as the lowest log, both this list is the union of both lists.
Otherwise, this list is equal to only the roots.In either case, only positions which match the y-level of the zeroth element will be used during placement.
This list is immutable.
- Returns:
- The list of positions that will be used for alteration placement.
-
getStateProvider
Gets the currentBlockStateProvider
that will be used by theAlterGroundDecorator
.- Returns:
- The (possibly event-modified) state provider.
-
setStateProvider
Sets theBlockStateProvider
that will be used by theAlterGroundDecorator
.
Because this may be modified by multiple mods, it is advisable to wrap the current provider.An example of wrapping the current provider is shown below:
StateProvider old = event.getStateProvider(); event.setStateProvider((rand, pos) -> { BlockState state = old.getState(rand, pos); return state.is(Blocks.PODZOL) ? Blocks.REDSTONE_BLOCK.defaultBlockState() : state; });
- Parameters:
provider
- The new state provider.
-