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
This commit is contained in:
SenseiKiwi 2014-03-23 17:18:47 -04:00
parent e5adb43f77
commit d6b07db3d6
2 changed files with 20 additions and 5 deletions

View file

@ -46,6 +46,7 @@ public class DDTeleporter
private static final int MAX_ROOT_SHIFT_CHANCE = 100; private static final int MAX_ROOT_SHIFT_CHANCE = 100;
private static final int START_ROOT_SHIFT_CHANCE = 0; private static final int START_ROOT_SHIFT_CHANCE = 0;
private static final int ROOT_SHIFT_CHANCE_PER_LEVEL = 5; private static final int ROOT_SHIFT_CHANCE_PER_LEVEL = 5;
private static final String SPIRIT_WORLD_NAME = "Spirit World";
public static int cooldown = 0; public static int cooldown = 0;
@ -644,9 +645,7 @@ public class DDTeleporter
for (int attempts = 0; attempts < 10; attempts++) for (int attempts = 0; attempts < 10; attempts++)
{ {
NewDimData selection = roots.get( random.nextInt(roots.size()) ); NewDimData selection = roots.get( random.nextInt(roots.size()) );
if (selection.id() != END_DIMENSION_ID && if (selection != current.root() && isValidForDungeonExit(selection, properties))
selection.id() != properties.LimboDimensionID &&
selection != current.root())
{ {
return generateSafeExit(selection, link, properties); return generateSafeExit(selection, link, properties);
} }
@ -657,6 +656,19 @@ public class DDTeleporter
return generateSafeExit(current.root(), link, properties); 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) private static boolean generateSafeExit(NewDimData destinationDim, DimLink link, DDProperties properties)
{ {
// A safe exit attempts to place a Warp Door in a dimension with // A safe exit attempts to place a Warp Door in a dimension with

View file

@ -32,6 +32,7 @@ public class GatewayGenerator implements IWorldGenerator
private static final int OVERWORLD_DIMENSION_ID = 0; private static final int OVERWORLD_DIMENSION_ID = 0;
private static final int NETHER_DIMENSION_ID = -1; private static final int NETHER_DIMENSION_ID = -1;
private static final int END_DIMENSION_ID = 1; private static final int END_DIMENSION_ID = 1;
private static final String SPIRIT_WORLD_NAME = "Spirit World";
private ArrayList<BaseGateway> gateways; private ArrayList<BaseGateway> gateways;
private BaseGateway defaultGateway; 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) 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. // 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; int dimensionID = world.provider.dimensionId;
if (world.isRemote if (world.isRemote
|| (world.provider instanceof PocketProvider) || (world.provider instanceof PocketProvider)
|| (dimensionID == END_DIMENSION_ID) || (dimensionID == END_DIMENSION_ID)
|| (dimensionID == NETHER_DIMENSION_ID)) || (dimensionID == NETHER_DIMENSION_ID)
|| (world.provider.getDimensionName().hashCode() == SPIRIT_WORLD_NAME.hashCode()))
{ {
return; return;
} }