From 06cf72f9f73fd058099e63a589d13ff72a74ede9 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sat, 5 Jul 2014 21:28:10 -0400 Subject: [PATCH] Fixed Flawed Link Redirection Fixed the way in which we handle redirecting links to blacklisted dimensions. The previous method always converted links into safe exits. This lead to strange situations that could be seen as bugs. For instance, using a dungeon entrance in a root dimension would generate an exit door and a supporting platform directly above the entrance door. That also meant that any visited dungeons would be unusable if they were reset. We now do different things depending on the location of the link and its type. If the link is a dungeon link, then its destination is reset to allow a new dungeon to form. For other link types, if the link is in a pocket dimension, then it becomes a safe exit link, because it could be the only way out. If it's in a root dimension, then there are no reasonable destinations, so the teleport request is cancelled. --- .../mod_pocketDim/core/DDTeleporter.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java index fc793e50..f8f7bc10 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java @@ -484,10 +484,31 @@ public class DDTeleporter { if (PocketManager.isBlackListed(link.destination().getDimension())) { - // Overwrite this link to a blacklisted destination with a safe exit link - // We don't need to change 'link' to a different reference. - // NewDimData will overwrite the existing link in-place. - PocketManager.getDimensionData(link.source().getDimension()).createLink(link.source(), LinkTypes.SAFE_EXIT, link.orientation()); + // This link leads to a dimension that has been blacklisted. + // That means that it was a pocket and it was deleted. + // Depending on the link type, we must overwrite it or cancel + // the teleport operation. We don't need to assign 'link' with + // a different value. NewDimData will overwrite it in-place. + NewDimData start = PocketManager.getDimensionData(link.source().getDimension()); + if (link.linkType() == LinkTypes.DUNGEON) + { + // Ovewrite the link into a dungeon link with no destination + start.createLink(link.source(), LinkTypes.DUNGEON, link.orientation()); + } + else + { + if (start.isPocketDimension()) + { + // Ovewrite the link into a safe exit link, because + // this could be the only way out from a pocket. + start.createLink(link.source(), LinkTypes.SAFE_EXIT, link.orientation()); + } + else + { + // Cancel the teleport attempt + return false; + } + } } else {