Improved DungeonHelper
Completed changes so that our code uses registerDungeon() (formerly registerCustomDungeons() ) to register all dungeons, both bundled with the mod and custom ones. Made some changes to the code to hide implementation details from other classes. Also, I had some problems with old dungeons being mixed into the renamed ones. I had to remove fallingTNThall from the schematics folder and deleted the WIP folder because I think we have completed versions of those schematics already. Some of our dungeons have pre-filled chests and the contents are more generous than our current loot system (e.g. ruinsO has a prefilled chest). I'll have to wipe all the chests later.
This commit is contained in:
parent
a174ad4b29
commit
0b9f8fa5d5
7 changed files with 150 additions and 15 deletions
|
@ -71,7 +71,9 @@ public class SchematicLoader
|
|||
//TODO: In the future, remove this dungeon from the generation lists altogether.
|
||||
//That will have to wait until our code is updated to support that more easily.
|
||||
System.err.println("The dungeon will not be loaded.");
|
||||
dungeon = checkSourceAndLoad(DungeonHelper.instance().defaultBreak.schematicPath);
|
||||
DungeonGenerator defaultError = DungeonHelper.instance().getDefaultErrorDungeon();
|
||||
dimList.get(destDimID).dungeonGenerator = defaultError;
|
||||
dungeon = checkSourceAndLoad(defaultError.schematicPath);
|
||||
dungeon.applyImportFilters(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class CommandExportDungeon extends DDCommandBase
|
|||
if (dungeonHelper.exportDungeon(player.worldObj, x, y, z, exportPath))
|
||||
{
|
||||
player.sendChatToPlayer("Saved dungeon schematic in " + exportPath);
|
||||
dungeonHelper.registerCustomDungeon(new File(exportPath));
|
||||
dungeonHelper.registerDungeon(exportPath, false, true);
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -27,6 +30,11 @@ public class DungeonHelper
|
|||
private static DDProperties properties = null;
|
||||
public static final Pattern SchematicNamePattern = Pattern.compile("[A-Za-z0-9_\\-]+");
|
||||
public static final Pattern DungeonNamePattern = Pattern.compile("[A-Za-z0-9\\-]+");
|
||||
|
||||
private static final String DEFAULT_UP_SCHEMATIC_PATH = "/schematics/core/simpleStairsUp.schematic";
|
||||
private static final String DEFAULT_DOWN_SCHEMATIC_PATH = "/schematics/core/simpleStairsDown.schematic";
|
||||
private static final String DEFAULT_ERROR_SCHEMATIC_PATH = "/schematics/core/somethingBroke.schematic";
|
||||
private static final String BUNDLED_DUNGEONS_LIST_PATH = "/schematics/schematics.txt";
|
||||
|
||||
public static final String SCHEMATIC_FILE_EXTENSION = ".schematic";
|
||||
private static final int DEFAULT_DUNGEON_WEIGHT = 100;
|
||||
|
@ -71,9 +79,10 @@ public class DungeonHelper
|
|||
private ArrayList<DungeonGenerator> mazes = new ArrayList<DungeonGenerator>();
|
||||
private ArrayList<DungeonGenerator> pistonTraps = new ArrayList<DungeonGenerator>();
|
||||
private ArrayList<DungeonGenerator> exits = new ArrayList<DungeonGenerator>();
|
||||
|
||||
public DungeonGenerator defaultBreak = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, "/schematics/somethingBroke.schematic", true);
|
||||
public DungeonGenerator defaultUp = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, "/schematics/simpleStairsUp.schematic", true);
|
||||
|
||||
private DungeonGenerator defaultUp;
|
||||
private DungeonGenerator defaultDown;
|
||||
private DungeonGenerator defaultError;
|
||||
|
||||
private HashSet<String> dungeonTypeChecker;
|
||||
private HashMap<String, ArrayList<DungeonGenerator>> dungeonTypeMapping;
|
||||
|
@ -138,8 +147,8 @@ public class DungeonHelper
|
|||
{
|
||||
copyfile.copyFile("/mods/DimDoors/text/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt");
|
||||
}
|
||||
registerBundledDungeons();
|
||||
importCustomDungeons(properties.CustomSchematicDirectory);
|
||||
registerBaseDungeons();
|
||||
}
|
||||
|
||||
public List<DungeonGenerator> getRegisteredDungeons()
|
||||
|
@ -152,6 +161,21 @@ public class DungeonHelper
|
|||
return Collections.unmodifiableList(this.untaggedDungeons);
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultErrorDungeon()
|
||||
{
|
||||
return defaultError;
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultUpDungeon()
|
||||
{
|
||||
return defaultUp;
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultDownDungeon()
|
||||
{
|
||||
return defaultDown;
|
||||
}
|
||||
|
||||
public LinkData createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
{
|
||||
//Create a link above the specified position. Link to a new pocket dimension.
|
||||
|
@ -213,10 +237,13 @@ public class DungeonHelper
|
|||
return true;
|
||||
}
|
||||
|
||||
public void registerCustomDungeon(File schematicFile)
|
||||
public void registerDungeon(String schematicPath, boolean isInternal, boolean verbose)
|
||||
{
|
||||
//We use schematicPath as the real path for internal files (inside our JAR) because it seems
|
||||
//that File tries to interpret it as a local drive path and mangles it.
|
||||
File schematicFile = new File(schematicPath);
|
||||
String name = schematicFile.getName();
|
||||
String path = schematicFile.getAbsolutePath();
|
||||
String path = isInternal ? schematicPath : schematicFile.getAbsolutePath();
|
||||
try
|
||||
{
|
||||
if (validateSchematicName(name))
|
||||
|
@ -233,23 +260,29 @@ public class DungeonHelper
|
|||
|
||||
dungeonTypeMapping.get(dungeonType).add(generator);
|
||||
registeredDungeons.add(generator);
|
||||
System.out.println("Imported " + name);
|
||||
if (verbose)
|
||||
{
|
||||
System.out.println("Registered dungeon: " + name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Could not parse dungeon filename, not adding dungeon to generation lists");
|
||||
if (verbose)
|
||||
{
|
||||
System.out.println("Could not parse dungeon filename, not adding dungeon to generation lists");
|
||||
}
|
||||
untaggedDungeons.add(new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, path, true));
|
||||
System.out.println("Imported " + name);
|
||||
System.out.println("Registered untagged dungeon: " + name);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.err.println("Failed to register dungeon: " + name);
|
||||
e.printStackTrace();
|
||||
System.out.println("Failed to import " + name);
|
||||
}
|
||||
}
|
||||
|
||||
public void importCustomDungeons(String path)
|
||||
private void importCustomDungeons(String path)
|
||||
{
|
||||
File directory = new File(path);
|
||||
File[] schematicNames = directory.listFiles();
|
||||
|
@ -260,15 +293,48 @@ public class DungeonHelper
|
|||
{
|
||||
if (schematicFile.getName().endsWith(SCHEMATIC_FILE_EXTENSION))
|
||||
{
|
||||
registerCustomDungeon(schematicFile);
|
||||
registerDungeon(schematicFile.getPath(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerBaseDungeons()
|
||||
private void registerBundledDungeons()
|
||||
{
|
||||
//Register the core schematics
|
||||
//These are used for debugging and in case of unusual errors while loading dungeons
|
||||
defaultUp = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_UP_SCHEMATIC_PATH, true);
|
||||
defaultDown = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_DOWN_SCHEMATIC_PATH, true);
|
||||
defaultError = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_ERROR_SCHEMATIC_PATH, true);
|
||||
|
||||
//Open the list of dungeons packaged with our mod and register their schematics
|
||||
InputStream listStream = this.getClass().getResourceAsStream(BUNDLED_DUNGEONS_LIST_PATH);
|
||||
if (listStream == null)
|
||||
{
|
||||
System.err.println("Unable to open list of bundled dungeon schematics.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader listReader = new BufferedReader(new InputStreamReader(listStream));
|
||||
String schematicPath = listReader.readLine();
|
||||
while (schematicPath != null)
|
||||
{
|
||||
schematicPath = schematicPath.trim();
|
||||
if (!schematicPath.isEmpty())
|
||||
{
|
||||
registerDungeon(schematicPath, true, false);
|
||||
}
|
||||
schematicPath = listReader.readLine();
|
||||
}
|
||||
listReader.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("An exception occurred while reading the list of bundled dungeon schematics.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exportDungeon(World world, int centerX, int centerY, int centerZ, String exportPath)
|
||||
|
|
Binary file not shown.
67
schematics/schematics.txt
Normal file
67
schematics/schematics.txt
Normal file
|
@ -0,0 +1,67 @@
|
|||
/schematics/ruins/complexHall_buggyTopEntry1_open_100.schematic
|
||||
/schematics/ruins/complexHall_exitRuinsWithHiddenDoor_open_100.schematic
|
||||
/schematics/ruins/complexHall_hallwayHiddenTreasure_closed_100.schematic
|
||||
/schematics/ruins/complexHall_largeBrokenHall_closed_100.schematic
|
||||
/schematics/ruins/complexHall_mediumPillarStairs_open_100.schematic
|
||||
/schematics/ruins/complexHall_pitStairs_open_100.schematic
|
||||
/schematics/ruins/complexHall_ruinsO_open_100.schematic
|
||||
/schematics/ruins/ComplexHall_SK-AnchoredDescent_Open_50.schematic
|
||||
/schematics/ruins/ComplexHall_SK-HiddenStairs_Open_100.schematic
|
||||
/schematics/ruins/ComplexHall_SK-LostGarden_Open_10.schematic
|
||||
/schematics/ruins/complexHall_smallBranchWithExit_closed_100.schematic
|
||||
/schematics/ruins/complexHall_smallRotundaWithExit_closed_100.schematic
|
||||
/schematics/ruins/complexHall_tntPuzzleTrap_closed_50.schematic
|
||||
/schematics/ruins/deadEnd_azersDungeonO_closed_100.schematic
|
||||
/schematics/ruins/deadEnd_brokenPillarsO_open_100.schematic
|
||||
/schematics/ruins/deadEnd_diamondTowerTemple1_open_100.schematic
|
||||
/schematics/ruins/deadEnd_fallingTrapO_open_100.schematic
|
||||
/schematics/ruins/deadEnd_hiddenStaircaseO_open_100.schematic
|
||||
/schematics/ruins/deadEnd_lavaTrapO_open_100.schematic
|
||||
/schematics/ruins/deadend_randomTree_open_75.schematic
|
||||
/schematics/ruins/DeadEnd_SK-EyesOfTricksters_Open_50.schematic
|
||||
/schematics/ruins/DeadEnd_SK-FarAwayInTheDark_Open_100.schematic
|
||||
/schematics/ruins/DeadEnd_SK-UnstableDesert_Open_50.schematic
|
||||
/schematics/ruins/deadEnd_smallDesert_open_75.schematic
|
||||
/schematics/ruins/deadEnd_smallHiddenTowerO_open_100.schematic
|
||||
/schematics/ruins/deadEnd_smallPond_open_75.schematic
|
||||
/schematics/ruins/deadEnd_smallSilverfishRoom_closed_100.schematic
|
||||
/schematics/ruins/deadEnd_tntTrapO_open_100.schematic
|
||||
/schematics/ruins/exit_exitCube_open_100.schematic
|
||||
/schematics/ruins/exit_lockingExitHall_closed_100.schematic
|
||||
/schematics/ruins/exit_smallExitPrison_open_100.schematic
|
||||
/schematics/ruins/hub_4WayBasicHall_closed_200.schematic
|
||||
/schematics/ruins/hub_4WayHallExit_closed_200.schematic
|
||||
/schematics/ruins/hub_doorTotemRuins_open_100.schematic
|
||||
/schematics/ruins/hub_fortRuins_open_100.schematic
|
||||
/schematics/ruins/hub_hallwayTrapRooms1_closed_100.schematic
|
||||
/schematics/ruins/hub_longDoorHallway_closed_100.schematic
|
||||
/schematics/ruins/Hub_SK-Claustrophobia_Open_10.schematic
|
||||
/schematics/ruins/Hub_SK-FractalCage_Open_20.schematic
|
||||
/schematics/ruins/Hub_SK-HeartOfDisorder_Open_50.schematic
|
||||
/schematics/ruins/maze_smallMaze1_closed_100.schematic
|
||||
/schematics/ruins/maze_smallMultilevelMaze_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_collapsedSingleTunnel1_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_simpleDropHall_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_simpleSmallT1_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_simpleStairsDown_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_simpleStairsUp_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_singleStraightHall1_closed_100.schematic
|
||||
/schematics/ruins/SimpleHall_SK-LeftDownStairs_Open_50.schematic
|
||||
/schematics/ruins/SimpleHall_SK-LeftUpPath_Open_50.schematic
|
||||
/schematics/ruins/SimpleHall_SK-RightDownStairs_Open_50.schematic
|
||||
/schematics/ruins/SimpleHall_SK-RightUpPath_Open_50.schematic
|
||||
/schematics/ruins/SimpleHall_SK-SpiralHallway_Open_100.schematic
|
||||
/schematics/ruins/simpleHall_smallSimpleLeft_closed_100.schematic
|
||||
/schematics/ruins/simpleHall_smallSimpleRight_closed_100.schematic
|
||||
/schematics/ruins/trap_fakeTNTTrap_closed_100.schematic
|
||||
/schematics/ruins/trap_hallwayPitFallTrap_closed_200.schematic
|
||||
/schematics/ruins/trap_lavaPyramid_open_100.schematic
|
||||
/schematics/ruins/trap_pistonFallRuins_open_100.schematic
|
||||
/schematics/ruins/trap_pistonFloorHall_closed_150.schematic
|
||||
/schematics/ruins/trap_pistonFloorPlatform2_closed_100.schematic
|
||||
/schematics/ruins/trap_pistonFloorPlatform_closed_100.schematic
|
||||
/schematics/ruins/trap_pistonHallway_closed_100.schematic
|
||||
/schematics/ruins/trap_pistonSmasherHall_closed_100.schematic
|
||||
/schematics/ruins/trap_raceTheTNTHall_closed_50.schematic
|
||||
/schematics/ruins/Trap_SK-RestlessCorridor_Open_10.schematic
|
||||
/schematics/ruins/trap_wallFallcomboPistonHall_closed_200.schematic
|
Loading…
Reference in a new issue