From d6b07db3d6213bf9b6f7139c4cc42389230854cf Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Mar 2014 17:18:47 -0400 Subject: [PATCH] Fixed Conflict with Witchery Mod * Changed DDTeleporter to stop us from generating exits to Witchery's Spirit World - this would cause people to lose their items upon leaving the dimension. * Changed GatewayGenerator to stop us from generating gateways or rift clusters in the Spirit World --- .../mod_pocketDim/core/DDTeleporter.java | 18 +++++++++++++++--- .../world/gateways/GatewayGenerator.java | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java index 7c7bb6ce..0c95b061 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java @@ -46,6 +46,7 @@ public class DDTeleporter private static final int MAX_ROOT_SHIFT_CHANCE = 100; private static final int START_ROOT_SHIFT_CHANCE = 0; private static final int ROOT_SHIFT_CHANCE_PER_LEVEL = 5; + private static final String SPIRIT_WORLD_NAME = "Spirit World"; public static int cooldown = 0; @@ -644,9 +645,7 @@ public class DDTeleporter for (int attempts = 0; attempts < 10; attempts++) { NewDimData selection = roots.get( random.nextInt(roots.size()) ); - if (selection.id() != END_DIMENSION_ID && - selection.id() != properties.LimboDimensionID && - selection != current.root()) + if (selection != current.root() && isValidForDungeonExit(selection, properties)) { return generateSafeExit(selection, link, properties); } @@ -657,6 +656,19 @@ public class DDTeleporter return generateSafeExit(current.root(), link, properties); } + private static boolean isValidForDungeonExit(NewDimData destination, DDProperties properties) + { + // Prevent exits to The End and Limbo + if (destination.id() == END_DIMENSION_ID || destination.id() == properties.LimboDimensionID) + { + return false; + } + // Prevent exits to Witchery's Spirit World; we need to load the dimension to retrieve its name. + // This is okay because the dimension would have to be loaded subsequently by generateSafeExit(). + World world = PocketManager.loadDimension(destination.id()); + return (world != null && !SPIRIT_WORLD_NAME.equals(world.provider.getDimensionName())); + } + private static boolean generateSafeExit(NewDimData destinationDim, DimLink link, DDProperties properties) { // A safe exit attempts to place a Warp Door in a dimension with diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayGenerator.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayGenerator.java index d2d9c0f3..dfd855a3 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayGenerator.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayGenerator.java @@ -32,6 +32,7 @@ public class GatewayGenerator implements IWorldGenerator private static final int OVERWORLD_DIMENSION_ID = 0; private static final int NETHER_DIMENSION_ID = -1; private static final int END_DIMENSION_ID = 1; + private static final String SPIRIT_WORLD_NAME = "Spirit World"; private ArrayList gateways; private BaseGateway defaultGateway; @@ -58,12 +59,14 @@ public class GatewayGenerator implements IWorldGenerator public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { // Don't generate rifts or gateways if the current world is a pocket dimension or the world is remote. - // Also don't generate anything in the Nether or The End. + // Also don't generate anything in the Nether, The End, or in Witchery's Spirit World. + // We only match against Spirit World using hashing to speed up the process a little (hopefully). int dimensionID = world.provider.dimensionId; if (world.isRemote || (world.provider instanceof PocketProvider) || (dimensionID == END_DIMENSION_ID) - || (dimensionID == NETHER_DIMENSION_ID)) + || (dimensionID == NETHER_DIMENSION_ID) + || (world.provider.getDimensionName().hashCode() == SPIRIT_WORLD_NAME.hashCode())) { return; }