Various Updates #144

Merged
SenseiKiwi merged 28 commits from master into master 2014-03-24 18:45:47 +00:00
4 changed files with 48 additions and 26 deletions
Showing only changes of commit f4b619635e - Show all commits

View File

@@ -63,17 +63,26 @@ public class CommandCreateDungeonRift extends DDCommandBase
{ {
result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons()); result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
} }
// Check if we found any matches // Check if we found any matches
if (result != null) if (result != null)
{ {
//Create a rift to our selected dungeon and notify the player
dimension = PocketManager.getDimensionData(sender.worldObj); dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result); 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); 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() + ")."); sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
} }
else else
{
// Dungeon generation failed somehow. Notify the user and remove the useless link.
dimension.deleteLink(link);
sendChat(sender, "Dungeon generation failed unexpectedly!");
}
}
else
{ {
//No matches! //No matches!
return new DDCommandResult("Error: The specified dungeon was not found. Use 'dd-list' to see a list of the available dungeons."); return new DDCommandResult("Error: The specified dungeon was not found. Use 'dd-list' to see a list of the available dungeons.");

View File

@@ -69,17 +69,26 @@ public class CommandCreateRandomRift extends DDCommandBase
{ {
result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons()); result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
} }
// Check if we found any matches // Check if we found any matches
if (result != null) if (result != null)
{ {
//Create a rift to our selected dungeon and notify the player
dimension = PocketManager.getDimensionData(sender.worldObj); dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result); 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); 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() + ")."); sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
} }
else else
{
// Dungeon generation failed somehow. Notify the user and remove the useless link.
dimension.deleteLink(link);
sendChat(sender, "Dungeon generation failed unexpectedly!");
}
}
else
{ {
//No matches! //No matches!
return new DDCommandResult("Error: The specified dungeon was not found. Use 'list' to see a list of the available dungeons."); return new DDCommandResult("Error: The specified dungeon was not found. Use 'list' to see a list of the available dungeons.");

View File

@@ -145,7 +145,7 @@ public class PocketBuilder
return true; 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) if (link == null)
{ {
@@ -155,11 +155,18 @@ public class PocketBuilder
{ {
throw new IllegalArgumentException("properties cannot be null."); throw new IllegalArgumentException("properties cannot be null.");
} }
if (link.hasDestination()) if (link.hasDestination())
{ {
throw new IllegalArgumentException("link cannot have a destination assigned already."); throw new IllegalArgumentException("link cannot have a destination assigned already.");
} }
if (dungeon == null)
{
throw new IllegalArgumentException("dungeon cannot be null.");
}
// Try to load up the schematic
DungeonSchematic schematic = null;
schematic = loadAndValidateDungeon(dungeon, properties);
// Register a new dimension // Register a new dimension
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension()); NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
@@ -174,17 +181,6 @@ public class PocketBuilder
return false; 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); return PocketBuilder.buildDungeonPocket(dungeon, dimension, link, schematic, world, properties);
} }

View File

@@ -73,7 +73,15 @@ public abstract class BaseGateway
this.generateRandomBits(world, x, y, z); this.generateRandomBits(world, x, y, z);
DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); 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; return true;
} }