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

    Constructors
    Constructor
    Description
    MultipartPlaceContext(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 Type
    Method
    Description
    Puts this placement into offset mode
    boolean
    Checks if part can be added to the world.
    net.minecraft.core.BlockPos
     
    double
    Distance from the clicked face to that same face of the enclosing block space.
    boolean
    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, replacingClickedOnBlock

    Methods inherited from class net.minecraft.world.item.context.UseOnContext

    getClickedFace, getClickLocation, getHand, getHitResult, getHorizontalDirection, getItemInHand, getLevel, getPlayer, getRotation, isInside, isSecondaryUseActive

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      @Contract("-> this") public MultipartPlaceContext 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

      public boolean canPlacePart(MultiPart part)
      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:
      getClickedPos in class net.minecraft.world.item.context.BlockPlaceContext