Class FlatPortalFrameTester

java.lang.Object
tech.anonymoushacker1279.openportals.portal.frame.PortalFrameTester
tech.anonymoushacker1279.openportals.portal.frame.FlatPortalFrameTester
All Implemented Interfaces:
PortalBuilder, PortalTeleporter, PortalValidator

public class FlatPortalFrameTester extends PortalFrameTester
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
    protected final int
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createPortal(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState frameBlock, net.minecraft.core.Direction.Axis axis)
    Create a complete portal structure at the given position.
    @Nullable net.minecraft.core.BlockPos
    doesPortalFitAt(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos attemptPos, net.minecraft.core.Direction.Axis axis)
    Check if a portal of the appropriate size can fit at the given position.
    net.minecraft.world.phys.Vec3
    getEntityOffsetInPortal(net.minecraft.util.BlockUtil.FoundRectangle rect, net.minecraft.world.entity.Entity entity)
    Calculate the entity's offset within the source portal.
    @Nullable PortalValidator
    getNewPortal(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
    Try to find a new, unlit portal frame at the given position.
    @Nullable PortalValidator
    getOrEmpty(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, Predicate<PortalFrameTester> predicate, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
    Try to find a portal frame matching the given predicate.
    net.minecraft.util.BlockUtil.FoundRectangle
    Get the rectangular bounds of the validated portal frame.
    net.minecraft.world.level.portal.TeleportTransition
    getTeleportTargetInPortal(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.util.BlockUtil.FoundRectangle portalRect, net.minecraft.core.Direction.Axis portalAxis, net.minecraft.world.phys.Vec3 prevOffset, net.minecraft.world.entity.Entity entity, PortalLink link)
    Calculate the teleportation target within the destination portal.
    init(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
    Initialize the validator with the given parameters and scan for a valid portal frame.
    boolean
    Check if the portal frame is already lit (contains portal blocks).
    boolean
    isRequestedSize(int attemptWidth, int attemptHeight)
    Check if the portal frame matches the requested size constraints.
    boolean
    Check if the current portal frame structure is valid.
    void
    lightPortal(net.minecraft.world.level.block.Block frameBlock)
    Light the portal by filling it with portal blocks.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • FlatPortalFrameTester

      public FlatPortalFrameTester()
  • Method Details

    • init

      public PortalValidator init(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
      Description copied from interface: PortalValidator
      Initialize the validator with the given parameters and scan for a valid portal frame.
      Specified by:
      init in interface PortalValidator
      Specified by:
      init in class PortalFrameTester
      Parameters:
      level - the level to scan in
      blockPos - the starting position to check
      axis - the axis along which the portal is oriented
      foundations - the blocks that can serve as portal frame blocks
      Returns:
      this validator instance for method chaining
    • getNewPortal

      @Nullable public @Nullable PortalValidator getNewPortal(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
      Description copied from class: PortalFrameTester
      Try to find a new, unlit portal frame at the given position.
      Specified by:
      getNewPortal in class PortalFrameTester
      Returns:
      this validator if a valid unlit portal is found, null otherwise
    • getOrEmpty

      @Nullable public @Nullable PortalValidator getOrEmpty(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos blockPos, Predicate<PortalFrameTester> predicate, net.minecraft.core.Direction.Axis axis, net.minecraft.world.level.block.Block... foundations)
      Description copied from class: PortalFrameTester
      Try to find a portal frame matching the given predicate.
      Specified by:
      getOrEmpty in class PortalFrameTester
      Returns:
      this validator if a matching portal is found, null otherwise
    • isAlreadyLitPortalFrame

      public boolean isAlreadyLitPortalFrame()
      Description copied from interface: PortalValidator
      Check if the portal frame is already lit (contains portal blocks).
      Specified by:
      isAlreadyLitPortalFrame in interface PortalValidator
      Specified by:
      isAlreadyLitPortalFrame in class PortalFrameTester
      Returns:
      true if the portal is already lit
    • isValidFrame

      public boolean isValidFrame()
      Description copied from interface: PortalValidator
      Check if the current portal frame structure is valid.
      Specified by:
      isValidFrame in interface PortalValidator
      Specified by:
      isValidFrame in class PortalFrameTester
      Returns:
      true if the frame is valid
    • lightPortal

      public void lightPortal(net.minecraft.world.level.block.Block frameBlock)
      Description copied from interface: PortalBuilder
      Light the portal by filling it with portal blocks.
      Specified by:
      lightPortal in interface PortalBuilder
      Specified by:
      lightPortal in class PortalFrameTester
      Parameters:
      frameBlock - the block that serves as the portal frame
    • createPortal

      public void createPortal(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState frameBlock, net.minecraft.core.Direction.Axis axis)
      Description copied from interface: PortalBuilder
      Create a complete portal structure at the given position. This includes placing the frame and portal blocks.
      Specified by:
      createPortal in interface PortalBuilder
      Specified by:
      createPortal in class PortalFrameTester
      Parameters:
      level - the level to create the portal in
      pos - the position to create the portal at
      frameBlock - the block state to use for the frame
      axis - the axis along which the portal should be oriented
    • isRequestedSize

      public boolean isRequestedSize(int attemptWidth, int attemptHeight)
      Description copied from interface: PortalValidator
      Check if the portal frame matches the requested size constraints.
      Specified by:
      isRequestedSize in interface PortalValidator
      Specified by:
      isRequestedSize in class PortalFrameTester
      Parameters:
      attemptWidth - the required width (0 for no constraint)
      attemptHeight - the required height (0 for no constraint)
      Returns:
      true if the size matches the constraints
    • getRectangle

      @Nullable public net.minecraft.util.BlockUtil.FoundRectangle getRectangle()
      Description copied from interface: PortalValidator
      Get the rectangular bounds of the validated portal frame.
      Specified by:
      getRectangle in interface PortalValidator
      Specified by:
      getRectangle in class PortalFrameTester
      Returns:
      the portal rectangle, or null if no valid frame was found
    • doesPortalFitAt

      @Nullable public @Nullable net.minecraft.core.BlockPos doesPortalFitAt(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos attemptPos, net.minecraft.core.Direction.Axis axis)
      Description copied from interface: PortalValidator
      Check if a portal of the appropriate size can fit at the given position.
      Specified by:
      doesPortalFitAt in interface PortalValidator
      Specified by:
      doesPortalFitAt in class PortalFrameTester
      Parameters:
      level - the level to check in
      attemptPos - the position to attempt portal placement
      axis - the axis along which the portal should be oriented
      Returns:
      the position where the portal can fit, or null if it cannot
    • getEntityOffsetInPortal

      public net.minecraft.world.phys.Vec3 getEntityOffsetInPortal(net.minecraft.util.BlockUtil.FoundRectangle rect, net.minecraft.world.entity.Entity entity)
      Description copied from interface: PortalTeleporter
      Calculate the entity's offset within the source portal. This is used to preserve relative position when teleporting.
      Specified by:
      getEntityOffsetInPortal in interface PortalTeleporter
      Specified by:
      getEntityOffsetInPortal in class PortalFrameTester
      Parameters:
      rect - the rectangular bounds of the portal
      entity - the entity entering the portal
      Returns:
      the entity's offset within the portal
    • getTeleportTargetInPortal

      public net.minecraft.world.level.portal.TeleportTransition getTeleportTargetInPortal(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.util.BlockUtil.FoundRectangle portalRect, net.minecraft.core.Direction.Axis portalAxis, net.minecraft.world.phys.Vec3 prevOffset, net.minecraft.world.entity.Entity entity, PortalLink link)
      Description copied from interface: PortalTeleporter
      Calculate the teleportation target within the destination portal.
      Specified by:
      getTeleportTargetInPortal in interface PortalTeleporter
      Specified by:
      getTeleportTargetInPortal in class PortalFrameTester
      Parameters:
      serverLevel - the destination level
      portalRect - the rectangular bounds of the destination portal
      portalAxis - the axis of the portal
      prevOffset - the entity's offset from the source portal
      entity - the entity being teleported
      link - the portal configuration link
      Returns:
      the teleport transition describing the destination