Interface MountedDispenseBehavior

All Known Implementing Classes:
DefaultMountedDispenseBehavior, MountedProjectileDispenseBehavior, OptionalMountedDispenseBehavior
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface MountedDispenseBehavior
A parallel to DispenseItemBehavior, for use by mounted dispensers. Create will attempt to wrap existing DispenseItemBehaviors, but this interface can be used to provide better or fixed behavior.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SimpleRegistry<net.minecraft.world.item.Item,MountedDispenseBehavior>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
    dispense(net.minecraft.world.item.ItemStack stack, MovementContext context, net.minecraft.core.BlockPos pos)
    Dispense the given stack into the world.
    static net.minecraft.core.Direction
    getClosestFacingDirection(net.minecraft.world.phys.Vec3 facing)
     
    static net.minecraft.world.phys.Vec3
     
    static void
    placeItemInInventory(net.minecraft.world.item.ItemStack stack, MovementContext context, net.minecraft.core.BlockPos pos)
    Attempt to place an item back into the inventory.
  • Field Details

  • Method Details

    • dispense

      net.minecraft.world.item.ItemStack dispense(net.minecraft.world.item.ItemStack stack, MovementContext context, net.minecraft.core.BlockPos pos)
      Dispense the given stack into the world.
      Parameters:
      stack - the stack to dispense. Safe to modify, behaviors are given a copy
      context - the MovementContext of the dispenser
      pos - the BlockPos being visited by the dispenser
      Returns:
      the remaining stack after dispensing one item
    • getDispenserNormal

      static net.minecraft.world.phys.Vec3 getDispenserNormal(MovementContext ctx)
    • getClosestFacingDirection

      static net.minecraft.core.Direction getClosestFacingDirection(net.minecraft.world.phys.Vec3 facing)
    • placeItemInInventory

      static void placeItemInInventory(net.minecraft.world.item.ItemStack stack, MovementContext context, net.minecraft.core.BlockPos pos)
      Attempt to place an item back into the inventory. This is used in the case of item overflow, such as a stack of buckets becoming two separate stacks when one is filled with water.

      First tries to insert directly into the dispenser inventory. If that fails, it then tries the contraption's whole inventory. If that still fails, the stack is dispensed into the world with the default behavior.

      Parameters:
      stack - the stack to store in the inventory
      context - the MovementContext given to the behavior
      pos - the position given to the behavior