Package codechicken.multipart.util
Class MultipartPlaceContext
java.lang.Object
net.minecraft.world.item.context.UseOnContext
net.minecraft.world.item.context.BlockPlaceContext
codechicken.multipart.util.MultipartPlaceContext
public class MultipartPlaceContext
extends net.minecraft.world.item.context.BlockPlaceContext
-
Field Summary
Fields inherited from class net.minecraft.world.item.context.BlockPlaceContext
replaceClicked -
Constructor Summary
ConstructorsConstructorDescriptionMultipartPlaceContext(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) MultipartPlaceContext(net.minecraft.world.item.context.UseOnContext context) -
Method Summary
Modifier and TypeMethodDescriptionPuts this placement into offset modebooleancanPlacePart(MultiPart part) Checks if part can be added to the world.net.minecraft.core.BlockPosdoubleDistance from the clicked face to that same face of the enclosing block space.booleanisOffset()False when placement is being run inside the clicked block, true when it is offset by one block.Methods inherited from class net.minecraft.world.item.context.BlockPlaceContext
at, canPlace, getNearestLookingDirection, getNearestLookingDirections, getNearestLookingVerticalDirection, replacingClickedOnBlockMethods inherited from class net.minecraft.world.item.context.UseOnContext
getClickedFace, getClickLocation, getHand, getHitResult, getHorizontalDirection, getItemInHand, getLevel, getPlayer, getRotation, isInside, isSecondaryUseActive
-
Constructor Details
-
MultipartPlaceContext
public MultipartPlaceContext(net.minecraft.world.item.context.UseOnContext context) -
MultipartPlaceContext
public MultipartPlaceContext(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit)
-
-
Method Details
-
applyOffset
Puts this placement into offset mode- Returns:
- this
-
getHitDepth
public double getHitDepth()Distance from the clicked face to that same face of the enclosing block space. -
isOffset
public boolean isOffset()False when placement is being run inside the clicked block, true when it is offset by one block. -
canPlacePart
Checks if part can be added to the world. Useful for cases where your part can optionally be altered if its initially calculated placement state cannot be placed.For example, Lever parts are rectangular with a long and short side. Occlusion may allow placement in one orientation but not another. The initial placement state can be run through this method, and then rotated if placement is not possible.
Note that this method does not need to be used if conditional placement states are not required. This is explicitly re-checked once you return your candidate part.
- Parameters:
part- The part to test- Returns:
- True if placement is possible (either the space is empty, or occlusion allows placement)
-
getClickedPos
public net.minecraft.core.BlockPos getClickedPos()- Overrides:
getClickedPosin classnet.minecraft.world.item.context.BlockPlaceContext
-