Various Updates #144
@@ -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.");
|
||||||
|
|||||||
@@ -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.");
|
||||||
|
|||||||
@@ -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,13 +155,20 @@ 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.");
|
||||||
|
}
|
||||||
|
|
||||||
//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 parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
||||||
|
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -107,7 +115,7 @@ public abstract class BaseGateway
|
|||||||
*/
|
*/
|
||||||
public DungeonData getStartingDungeon(NewDimData dimension, Random random)
|
public DungeonData getStartingDungeon(NewDimData dimension, Random random)
|
||||||
{
|
{
|
||||||
return getStartingPack().getNextDungeon(dimension,random);
|
return getStartingPack().getNextDungeon(dimension, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user