Class VerticalPortalFrameTester
java.lang.Object
tech.anonymoushacker1279.openportals.portal.frame.PortalFrameTester
tech.anonymoushacker1279.openportals.portal.frame.VerticalPortalFrameTester
- All Implemented Interfaces:
PortalBuilder, PortalTeleporter, PortalValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final intprotected final intprotected net.minecraft.core.Direction.Axisprotected intFields inherited from class PortalFrameTester
foundPortalBlocks, levelAccessor, lowerCorner, VALID_FRAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanHoldPortal(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) voidcreatePortal(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.BlockPosdoesPortalFitAt(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.Vec3getEntityOffsetInPortal(net.minecraft.util.BlockUtil.FoundRectangle arg, net.minecraft.world.entity.Entity entity) Calculate the entity's offset within the source portal.@Nullable PortalValidatorgetNewPortal(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 PortalValidatorgetOrEmpty(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.FoundRectangleGet the rectangular bounds of the validated portal frame.net.minecraft.world.level.portal.TeleportTransitiongetTeleportTargetInPortal(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.booleanCheck if the portal frame is already lit (contains portal blocks).protected booleanisEmptySpace(net.minecraft.world.level.block.state.BlockState blockState) booleanisRequestedSize(int attemptWidth, int attemptHeight) Check if the portal frame matches the requested size constraints.booleanCheck if the current portal frame structure is valid.voidlightPortal(net.minecraft.world.level.block.Block frameBlock) Light the portal by filling it with portal blocks.Methods inherited from class PortalFrameTester
blockWithAxis, checkForValidFrame, countExistingPortalBlocks, fillAirAroundPortal, getLimitForAxis, getLowerCorner, getSize, placeLandingPad, validStateInsidePortal
-
Field Details
-
maxWidth
protected final int maxWidth- See Also:
-
maxHeight
protected final int maxHeight- See Also:
-
portalAxis
protected net.minecraft.core.Direction.Axis portalAxis -
height
protected int height -
width
protected int width
-
-
Constructor Details
-
VerticalPortalFrameTester
public VerticalPortalFrameTester()
-
-
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:PortalValidatorInitialize the validator with the given parameters and scan for a valid portal frame.- Specified by:
initin interfacePortalValidator- Specified by:
initin classPortalFrameTester- Parameters:
level- the level to scan inblockPos- the starting position to checkaxis- the axis along which the portal is orientedfoundations- the blocks that can serve as portal frame blocks- Returns:
- this validator instance for method chaining
-
getRectangle
@Nullable public net.minecraft.util.BlockUtil.FoundRectangle getRectangle()Description copied from interface:PortalValidatorGet the rectangular bounds of the validated portal frame.- Specified by:
getRectanglein interfacePortalValidator- Specified by:
getRectanglein classPortalFrameTester- Returns:
- the portal rectangle, or null if no valid frame was found
-
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:PortalFrameTesterTry to find a new, unlit portal frame at the given position.- Specified by:
getNewPortalin classPortalFrameTester- 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:PortalFrameTesterTry to find a portal frame matching the given predicate.- Specified by:
getOrEmptyin classPortalFrameTester- Returns:
- this validator if a matching portal is found, null otherwise
-
isAlreadyLitPortalFrame
public boolean isAlreadyLitPortalFrame()Description copied from interface:PortalValidatorCheck if the portal frame is already lit (contains portal blocks).- Specified by:
isAlreadyLitPortalFramein interfacePortalValidator- Specified by:
isAlreadyLitPortalFramein classPortalFrameTester- Returns:
- true if the portal is already lit
-
isValidFrame
public boolean isValidFrame()Description copied from interface:PortalValidatorCheck if the current portal frame structure is valid.- Specified by:
isValidFramein interfacePortalValidator- Specified by:
isValidFramein classPortalFrameTester- Returns:
- true if the frame is valid
-
isRequestedSize
public boolean isRequestedSize(int attemptWidth, int attemptHeight) Description copied from interface:PortalValidatorCheck if the portal frame matches the requested size constraints.- Specified by:
isRequestedSizein interfacePortalValidator- Specified by:
isRequestedSizein classPortalFrameTester- 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
-
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:PortalValidatorCheck if a portal of the appropriate size can fit at the given position.- Specified by:
doesPortalFitAtin interfacePortalValidator- Specified by:
doesPortalFitAtin classPortalFrameTester- Parameters:
level- the level to check inattemptPos- the position to attempt portal placementaxis- the axis along which the portal should be oriented- Returns:
- the position where the portal can fit, or null if it cannot
-
isEmptySpace
protected boolean isEmptySpace(net.minecraft.world.level.block.state.BlockState blockState) -
canHoldPortal
protected boolean canHoldPortal(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) -
getEntityOffsetInPortal
public net.minecraft.world.phys.Vec3 getEntityOffsetInPortal(net.minecraft.util.BlockUtil.FoundRectangle arg, net.minecraft.world.entity.Entity entity) Description copied from interface:PortalTeleporterCalculate the entity's offset within the source portal. This is used to preserve relative position when teleporting.- Specified by:
getEntityOffsetInPortalin interfacePortalTeleporter- Specified by:
getEntityOffsetInPortalin classPortalFrameTester- Parameters:
arg- the rectangular bounds of the portalentity- 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:PortalTeleporterCalculate the teleportation target within the destination portal.- Specified by:
getTeleportTargetInPortalin interfacePortalTeleporter- Specified by:
getTeleportTargetInPortalin classPortalFrameTester- Parameters:
serverLevel- the destination levelportalRect- the rectangular bounds of the destination portalportalAxis- the axis of the portalprevOffset- the entity's offset from the source portalentity- the entity being teleportedlink- the portal configuration link- Returns:
- the teleport transition describing the destination
-
lightPortal
public void lightPortal(net.minecraft.world.level.block.Block frameBlock) Description copied from interface:PortalBuilderLight the portal by filling it with portal blocks.- Specified by:
lightPortalin interfacePortalBuilder- Specified by:
lightPortalin classPortalFrameTester- 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:PortalBuilderCreate a complete portal structure at the given position. This includes placing the frame and portal blocks.- Specified by:
createPortalin interfacePortalBuilder- Specified by:
createPortalin classPortalFrameTester- Parameters:
level- the level to create the portal inpos- the position to create the portal atframeBlock- the block state to use for the frameaxis- the axis along which the portal should be oriented
-