Rearranged dd-rift Workflow
Changed dd-rift and dd-random so that rifts are only placed after a dungeon is generated successfully. We also delete the link if generation fails to clean up after ourselves. Also changed PocketBuilder.generateSelectedDungeonPocket() so that its checks are stricter and we validate dungeons before allocating a dimension. This resolves one of our old issues: "Rearrange workflow in dd-rift to prevent rifts from being created if no dungeon gets loaded and to prevent dimension registration if the dimension cannot be populated"
This commit is contained in:
parent
3966f420db
commit
f4b619635e
4 changed files with 48 additions and 26 deletions
|
@ -63,15 +63,24 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||
{
|
||||
result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
|
||||
}
|
||||
//Check if we found any matches
|
||||
|
||||
// Check if we found any matches
|
||||
if (result != null)
|
||||
{
|
||||
//Create a rift to our selected dungeon and notify the player
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
||||
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result);
|
||||
sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift.blockID, 0, 3);
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result))
|
||||
{
|
||||
// Create a rift to our selected dungeon and notify the player
|
||||
sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift.blockID, 0, 3);
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dungeon generation failed somehow. Notify the user and remove the useless link.
|
||||
dimension.deleteLink(link);
|
||||
sendChat(sender, "Dungeon generation failed unexpectedly!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -69,15 +69,24 @@ public class CommandCreateRandomRift extends DDCommandBase
|
|||
{
|
||||
result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
|
||||
}
|
||||
//Check if we found any matches
|
||||
|
||||
// Check if we found any matches
|
||||
if (result != null)
|
||||
{
|
||||
//Create a rift to our selected dungeon and notify the player
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
||||
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result);
|
||||
sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift.blockID, 0, 3);
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result))
|
||||
{
|
||||
// Create a rift to our selected dungeon and notify the player
|
||||
sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift.blockID, 0, 3);
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dungeon generation failed somehow. Notify the user and remove the useless link.
|
||||
dimension.deleteLink(link);
|
||||
sendChat(sender, "Dungeon generation failed unexpectedly!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ public class PocketBuilder
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean generateSelectedDungeonPocket(DimLink link, DDProperties properties, DungeonData data)
|
||||
public static boolean generateSelectedDungeonPocket(DimLink link, DDProperties properties, DungeonData dungeon)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
|
@ -155,13 +155,20 @@ public class PocketBuilder
|
|||
{
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
|
||||
if (link.hasDestination())
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
if (dungeon == null)
|
||||
{
|
||||
throw new IllegalArgumentException("dungeon cannot be null.");
|
||||
}
|
||||
|
||||
//Register a new dimension
|
||||
// Try to load up the schematic
|
||||
DungeonSchematic schematic = null;
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
|
||||
// Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
||||
|
||||
|
@ -174,17 +181,6 @@ public class PocketBuilder
|
|||
return false;
|
||||
}
|
||||
|
||||
DungeonData dungeon = null;
|
||||
DungeonSchematic schematic = null;
|
||||
|
||||
dungeon = data;
|
||||
if (data == null)
|
||||
{
|
||||
System.err.println("Could not select a dungeon for generation!");
|
||||
return false;
|
||||
}
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
|
||||
return PocketBuilder.buildDungeonPocket(dungeon, dimension, link, schematic, world, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,15 @@ public abstract class BaseGateway
|
|||
this.generateRandomBits(world, x, y, z);
|
||||
|
||||
DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
||||
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, this.getStartingDungeon(PocketManager.getDimensionData(world),world.rand));
|
||||
DungeonData dungeon = this.getStartingDungeon(PocketManager.getDimensionData(world), world.rand);
|
||||
if (dungeon != null)
|
||||
{
|
||||
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, dungeon);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("Warning: Dimensional Doors was unable to assign a dungeon to a Rift Gateway.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -107,7 +115,7 @@ public abstract class BaseGateway
|
|||
*/
|
||||
public DungeonData getStartingDungeon(NewDimData dimension, Random random)
|
||||
{
|
||||
return getStartingPack().getNextDungeon(dimension,random);
|
||||
return getStartingPack().getNextDungeon(dimension, random);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue