Interface ImmersiveLogicHelpers

All Known Subinterfaces:
ImmersiveClientLogicHelpers
All Known Implementing Classes:
ImmersiveClientLogicHelpersImpl, ImmersiveLogicHelpersImpl

public interface ImmersiveLogicHelpers
Contains helpful methods that ensure the ImmersiveMC "style" is kept throughout API-implementors that wish to implement it, while also making the life of API-implementors easier.
These functions may be useful on the client and/or the server.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.core.Direction
    getHorizontalBlockForward(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos blockPos)
    Given a player and the position of an immersive block, returns the best direction the block should face to be looking towards the player.
    List<net.minecraft.world.phys.Vec3>
    getVerticesOfAABB(net.minecraft.world.phys.AABB box)
    Gets the vertices of the provided AABB as an 8-element list.
     
    void
    startTrackingOnServer(PlayerAttachmentImmersiveHandler<?> handler, net.minecraft.world.entity.player.Player player)
    Begins tracking the provided PlayerAttachmentImmersiveHandler, that is NOT client authoritative, with an owner and tracker of the provided player.
    void
    stopTrackingOnServer(PlayerAttachmentImmersiveHandler<?> handler, net.minecraft.world.entity.player.Player player)
    Stops tracking the provided PlayerAttachmentImmersiveHandler, that is NOT client authoritative, with an owner of the provided player for all trackers.
    swapItems(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, ItemSwapAmount swapAmount, net.minecraft.world.entity.player.Player player)
    Gets the result of a swap action between a player and an Immersive where the player may place items into and take items out of a slot, such as the input slots of a furnace.
    swapItems(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, ItemSwapAmount swapAmount, net.minecraft.world.entity.player.Player player, int forcedMaxImmersiveStackSize)
    Gets the result of a swap action between a player and an Immersive where the player may place items into and take items out of a slot, such as the input slots of a furnace.
    swapItemsWithOutput(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, net.minecraft.world.entity.player.Player player)
    Gets the result of a swap action between a player and an Immersive where the player may place items only into a slot, such as the output slot of a furnace.
  • Method Details

    • instance

      static ImmersiveLogicHelpers instance()
      Returns:
      An ImmersiveLogicHelpers instance to access API functions. All details of this object not mentioned in this file are assumed to be an implementation detail, and may change at any time.
    • getHorizontalBlockForward

      net.minecraft.core.Direction getHorizontalBlockForward(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos blockPos)
      Given a player and the position of an immersive block, returns the best direction the block should face to be looking towards the player. This is most commonly used for blocks like the crafting table which don't face a direction to come up with a good estimation. This method will always return NORTH, EAST, SOUTH, or WEST.
      Parameters:
      player - The player
      blockPos - The block to determine the facing direction of.
      Returns:
      A direction the block is facing, excluding UP and DOWN.
    • swapItems

      SwapResult swapItems(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, ItemSwapAmount swapAmount, net.minecraft.world.entity.player.Player player)
      Gets the result of a swap action between a player and an Immersive where the player may place items into and take items out of a slot, such as the input slots of a furnace.
      Parameters:
      stackFromPlayer - The ItemStack currently in the player's hand.
      stackInImmersive - The ItemStack currently in the slot of the Immersive the player is interacting with.
      swapAmount - The ItemSwapAmount that is determining the settings for how many items to swap.
      Returns:
      A SwapResult containing the ItemStacks that should be placed in the player's hand, be placed into the slot of the Immersive being interacted with, and the leftovers that should be given to the player some other way.
    • swapItems

      SwapResult swapItems(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, ItemSwapAmount swapAmount, net.minecraft.world.entity.player.Player player, int forcedMaxImmersiveStackSize)
      Gets the result of a swap action between a player and an Immersive where the player may place items into and take items out of a slot, such as the input slots of a furnace.
      Parameters:
      stackFromPlayer - The ItemStack currently in the player's hand.
      stackInImmersive - The ItemStack currently in the slot of the Immersive the player is interacting with.
      swapAmount - The ItemSwapAmount that is determining the settings for how many items to swap.
      player - The player performing the swap.
      forcedMaxImmersiveStackSize - A forced maximum stack size for the slot in the Immersive, or -1 to use the item's stack size.
      Returns:
      A SwapResult containing the ItemStacks that should be placed in the player's hand, be placed into the slot of the Immersive being interacted with, and the leftovers that should be given to the player some other way.
    • swapItemsWithOutput

      SwapResult swapItemsWithOutput(net.minecraft.world.item.ItemStack stackFromPlayer, net.minecraft.world.item.ItemStack stackInImmersive, net.minecraft.world.entity.player.Player player)
      Gets the result of a swap action between a player and an Immersive where the player may place items only into a slot, such as the output slot of a furnace.
      Parameters:
      stackFromPlayer - The ItemStack currently in the player's hand.
      stackInImmersive - The ItemStack currently in the output slot of the Immersive the player is interacting with.
      player - The player performing the swap.
      Returns:
      A SwapResult containing the ItemStacks that should be placed in the player's hand, be placed into the slot of the Immersive being interacted with, and the leftovers that should be given to the player some other way.
    • getVerticesOfAABB

      List<net.minecraft.world.phys.Vec3> getVerticesOfAABB(net.minecraft.world.phys.AABB box)
      Gets the vertices of the provided AABB as an 8-element list. This is equivalent to BoundingBox.vertices(BoundingBox) with explicitly an AABB provided. See the aforementioned method for more details.
      Parameters:
      box - The AABB to get the vertices of.
      Returns:
      The vertices of the provided AABB as described in the aforementioned method.
    • startTrackingOnServer

      void startTrackingOnServer(PlayerAttachmentImmersiveHandler<?> handler, net.minecraft.world.entity.player.Player player) throws IllegalArgumentException
      Begins tracking the provided PlayerAttachmentImmersiveHandler, that is NOT client authoritative, with an owner and tracker of the provided player.

      This method may be called on either the server or client.

      If you are attempting to begin tracking a BlockBasedImmersiveHandler, you should instead provide an implementation of BlockBasedImmersiveHandler.isValidBlock(BlockPos, Level) that would begin the tracking under the condition you desire.

      Parameters:
      handler - The handler to begin tracking for.
      player - The player who will be the owner and tracker of the Immersive instance.
      Throws:
      IllegalArgumentException - If the provided handler is client authoritative.
    • stopTrackingOnServer

      void stopTrackingOnServer(PlayerAttachmentImmersiveHandler<?> handler, net.minecraft.world.entity.player.Player player) throws IllegalArgumentException
      Stops tracking the provided PlayerAttachmentImmersiveHandler, that is NOT client authoritative, with an owner of the provided player for all trackers.
      Parameters:
      handler - The handler to stop tracking for.
      player - The player who is no longer having this Immersive tracked for them.
      Throws:
      IllegalArgumentException - If the provided handler is client authoritative.