Class PlacementHandlers
java.lang.Object
com.ldtteam.structurize.placement.handlers.placement.PlacementHandlers
Class containing all placement handler implementations.
We suppress warning squid:S2972 which handles the max size of internal classes. This doesn't apply here since it wouldn't make sense extracting all of those in separate classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic classstatic classstatic classstatic classstatic interfaceHandler for placing the block down into the world.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classmojang abusing lazyupdates, this modification always happens, but we need it now, not laterstatic classstatic classstatic class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(IPlacementHandler handler) Adds a handler to the start of the handlers list, right after the air, solid and light placeholder handlers.static voidadd(IPlacementHandler handler, Class<?> override) Allows for adding new handlers without having to clear the list in other mods just to override onestatic voidadd(IPlacementHandler handler, Class<?> override, PlacementHandlers.AddType addType) Allows for Adding a Handler before, after or instead of another one.static IPlacementHandlergetHandler(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos worldPos, net.minecraft.world.level.block.state.BlockState newState) Finds the appropriateIPlacementHandlerfor the given location.static List<net.minecraft.world.item.ItemStack>getItemsFromTileEntity(net.minecraft.nbt.CompoundTag tileEntityData, net.minecraft.world.level.block.state.BlockState blockState) Gets the list of items from a possible tileEntity.static List<net.minecraft.world.item.ItemStack>getRequiredItemsForState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag data, IPlacementContext placementContext) Get the required items for this state.static booleanhandleBlockPlacement(@NotNull PlacementHandlers.BlockPlacementFunction placementFunction, @NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState blockState, int flags, @Nullable RotationMirror settings, @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Handles block placement.static booleanhandleBlockPlacement(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState blockState) Handles block placement.static booleanhandleBlockPlacement(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState blockState, @Nullable RotationMirror settings, @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Handles block placement.static voidhandleTileEntityPlacement(@Nullable net.minecraft.nbt.CompoundTag tileEntityData, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, RotationMirror settings) Handles tileEntity placement.simplePlacement(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState blockState, @Nullable RotationMirror settings, @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Simple block placement that only overwrites the block if the same block is not already present.
-
Field Details
-
handlers
-
-
Method Details
-
add
Allows for adding new handlers without having to clear the list in other mods just to override one- Parameters:
handler- the new handler to addoverride- the class to override if it can be found
-
add
public static void add(IPlacementHandler handler, Class<?> override, PlacementHandlers.AddType addType) Allows for Adding a Handler before, after or instead of another one.- Parameters:
handler- the new handler to addoverride- the class to match.addType- if before/after/replace.
-
add
Adds a handler to the start of the handlers list, right after the air, solid and light placeholder handlers. This may effectively override existing ones with similar 'canHandle' functions because this one will evaluate before them.- Parameters:
handler-
-
getHandler
public static IPlacementHandler getHandler(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos worldPos, net.minecraft.world.level.block.state.BlockState newState) Finds the appropriateIPlacementHandlerfor the given location.- Parameters:
world- the world.worldPos- the world position.newState- the blockstate being placed or removed.- Returns:
- the appropriate handler.
-
handleBlockPlacement
public static boolean handleBlockPlacement(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState) Handles block placement.- Parameters:
world- the world.pos- the position.blockState- the block state of the block about to be placed.- Returns:
- true if successfully placed.
-
handleBlockPlacement
public static boolean handleBlockPlacement(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState, @Nullable @Nullable RotationMirror settings, @Nullable @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Handles block placement.- Parameters:
world- the world.pos- the position.blockState- the block state of the block about to be placed.settings- the rotation and mirroring settings.- Returns:
- true if successfully placed.
-
handleBlockPlacement
public static boolean handleBlockPlacement(@NotNull @NotNull PlacementHandlers.BlockPlacementFunction placementFunction, @NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState, int flags, @Nullable @Nullable RotationMirror settings, @Nullable @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Handles block placement.- Parameters:
world- the world.pos- the position.blockState- the block state of the block about to be placed.settings- the rotation and mirroring settings.- Returns:
- true if successfully placed.
-
handleTileEntityPlacement
public static void handleTileEntityPlacement(@Nullable @Nullable net.minecraft.nbt.CompoundTag tileEntityData, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, RotationMirror settings) Handles tileEntity placement.- Parameters:
tileEntityData- the data of the tile entity.world- the world.pos- the position.settings- the placement settings.
-
getRequiredItemsForState
public static List<net.minecraft.world.item.ItemStack> getRequiredItemsForState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag data, IPlacementContext placementContext) Get the required items for this state.- Parameters:
world- the world it will be placed in.pos- the pos to place it at.state- the state to place.data- its TE data.placementContext- the placement context.- Returns:
- the required items.
-
getItemsFromTileEntity
public static List<net.minecraft.world.item.ItemStack> getItemsFromTileEntity(net.minecraft.nbt.CompoundTag tileEntityData, net.minecraft.world.level.block.state.BlockState blockState) Gets the list of items from a possible tileEntity.- Parameters:
tileEntityData- the data.blockState- the block.- Returns:
- the required list.
-
simplePlacement
public static IPlacementHandler.ActionProcessingResult simplePlacement(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockState, @Nullable @Nullable RotationMirror settings, @Nullable @Nullable net.minecraft.nbt.CompoundTag tileEntityData) Simple block placement that only overwrites the block if the same block is not already present. If the block is already present, the tile entity data is updated if necessary. If the block is not present, the block is placed down and the tile entity is set down too.- Parameters:
world- receives the world.pos- the position.blockState- the blockState.settings- the settings to use to rotate or mirror it.tileEntityData- the placer of the block.- Returns:
- ACCEPT, DENY or IGNORE.
-