Class PortalLinkingStorage
java.lang.Object
net.minecraft.world.level.saveddata.SavedData
tech.anonymoushacker1279.openportals.portal.linking.PortalLinkingStorage
public class PortalLinkingStorage
extends net.minecraft.world.level.saveddata.SavedData
Stores bidirectional links between portal locations across dimensions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<PortalLinkingStorage> static final net.minecraft.world.level.saveddata.SavedDataType<PortalLinkingStorage> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcleanupOrphanedLinks(net.minecraft.server.MinecraftServer server) Clean up orphaned links.voidcreateLink(net.minecraft.core.BlockPos portalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> fromDim, net.minecraft.core.BlockPos destPortalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> destDim) Create a bidirectional link between two portals.@Nullable DimensionalBlockPosgetDestination(net.minecraft.core.BlockPos portalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Get the destination for a portal at the given position.Methods inherited from class net.minecraft.world.level.saveddata.SavedData
isDirty, setDirty, setDirty
-
Field Details
-
CODEC
-
TYPE
-
-
Constructor Details
-
PortalLinkingStorage
public PortalLinkingStorage() -
PortalLinkingStorage
-
-
Method Details
-
getDimensionLinks
-
getDestination
@Nullable public @Nullable DimensionalBlockPos getDestination(net.minecraft.core.BlockPos portalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Get the destination for a portal at the given position.- Parameters:
portalFramePos- the position of the portal framedim- the dimension of the portal- Returns:
- the destination position, or null if no link exists
-
createLink
public void createLink(net.minecraft.core.BlockPos portalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> fromDim, net.minecraft.core.BlockPos destPortalFramePos, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> destDim) Create a bidirectional link between two portals. Only adds a single link object that works in both directions.- Parameters:
portalFramePos- the position of the source portal framefromDim- the dimension of the source portaldestPortalFramePos- the position of the destination portal framedestDim- the dimension of the destination portal
-
cleanupOrphanedLinks
public int cleanupOrphanedLinks(net.minecraft.server.MinecraftServer server) Clean up orphaned links.- Parameters:
server- the server to check dimensions- Returns:
- the number of links removed
-