Major Improvements to DungeonHelper, Minor Bug Fixes and Tweaks #25
@@ -159,7 +159,7 @@ public class SchematicLoader
|
|||||||
}
|
}
|
||||||
public int transformMetadata(int metadata, int orientation, int blockID)
|
public int transformMetadata(int metadata, int orientation, int blockID)
|
||||||
{
|
{
|
||||||
if(mod_pocketDim.dungeonHelper.metadataFlipList.contains(blockID))
|
if (DungeonHelper.instance().metadataFlipList.contains(blockID))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import StevenDimDoors.mod_pocketDim.DimData;
|
|||||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
@@ -27,8 +28,9 @@ public class CommandAddDungeonRift extends CommandBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender var1, String[] var2)
|
public void processCommand(ICommandSender var1, String[] var2)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||||
|
|
||||||
if(var2==null||this.getCommandSenderAsPlayer(var1).worldObj.isRemote)
|
if(var2==null||this.getCommandSenderAsPlayer(var1).worldObj.isRemote)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -54,7 +56,7 @@ public class CommandAddDungeonRift extends CommandBase
|
|||||||
}
|
}
|
||||||
else if(var2.length!=0&&var2[0].equals("list"))
|
else if(var2.length!=0&&var2[0].equals("list"))
|
||||||
{
|
{
|
||||||
for(DungeonGenerator dungeonGen : mod_pocketDim.dungeonHelper.registeredDungeons)
|
for(DungeonGenerator dungeonGen : dungeonHelper.registeredDungeons)
|
||||||
{
|
{
|
||||||
String dungeonName =dungeonGen.schematicPath;
|
String dungeonName =dungeonGen.schematicPath;
|
||||||
if(dungeonName.contains("DimDoors_Custom_schematics"))
|
if(dungeonName.contains("DimDoors_Custom_schematics"))
|
||||||
@@ -69,7 +71,7 @@ public class CommandAddDungeonRift extends CommandBase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(DungeonGenerator dungeonGen : mod_pocketDim.dungeonHelper.customDungeons)
|
for(DungeonGenerator dungeonGen : dungeonHelper.customDungeons)
|
||||||
{
|
{
|
||||||
String dungeonName =dungeonGen.schematicPath;
|
String dungeonName =dungeonGen.schematicPath;
|
||||||
if(dungeonName.contains("DimDoors_Custom_schematics"))
|
if(dungeonName.contains("DimDoors_Custom_schematics"))
|
||||||
@@ -89,7 +91,7 @@ public class CommandAddDungeonRift extends CommandBase
|
|||||||
|
|
||||||
else if(var2.length!=0)
|
else if(var2.length!=0)
|
||||||
{
|
{
|
||||||
for(DungeonGenerator dungeonGen : mod_pocketDim.dungeonHelper.registeredDungeons)
|
for(DungeonGenerator dungeonGen : dungeonHelper.registeredDungeons)
|
||||||
{
|
{
|
||||||
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
||||||
|
|
||||||
@@ -113,7 +115,7 @@ public class CommandAddDungeonRift extends CommandBase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(DungeonGenerator dungeonGen : mod_pocketDim.dungeonHelper.customDungeons)
|
for(DungeonGenerator dungeonGen : dungeonHelper.customDungeons)
|
||||||
{
|
{
|
||||||
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ public class CommandEndDungeonCreation extends CommandBase
|
|||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender var1, String[] var2)
|
public void processCommand(ICommandSender var1, String[] var2)
|
||||||
{
|
{
|
||||||
|
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||||
|
|
||||||
EntityPlayer player = this.getCommandSenderAsPlayer(var1);
|
EntityPlayer player = this.getCommandSenderAsPlayer(var1);
|
||||||
|
|
||||||
if(!mod_pocketDim.dungeonHelper.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId))
|
if (!dungeonHelper.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId))
|
||||||
{
|
{
|
||||||
if(var2.length<2)
|
if(var2.length<2)
|
||||||
{
|
{
|
||||||
@@ -61,10 +63,10 @@ public class CommandEndDungeonCreation extends CommandBase
|
|||||||
//Check that the dungeon name is valid to prevent directory traversal and other forms of abuse
|
//Check that the dungeon name is valid to prevent directory traversal and other forms of abuse
|
||||||
if (DungeonHelper.NamePattern.matcher(var2[0]).matches())
|
if (DungeonHelper.NamePattern.matcher(var2[0]).matches())
|
||||||
{
|
{
|
||||||
DungeonGenerator newDungeon = mod_pocketDim.dungeonHelper.exportDungeon(player.worldObj, x, y, z, properties.CustomSchematicDirectory + "/" + var2[0] + ".schematic");
|
DungeonGenerator newDungeon = dungeonHelper.exportDungeon(player.worldObj, x, y, z, properties.CustomSchematicDirectory + "/" + var2[0] + ".schematic");
|
||||||
player.sendChatToPlayer("created dungeon schematic in " + properties.CustomSchematicDirectory + "/" + var2[0]+".schematic");
|
player.sendChatToPlayer("created dungeon schematic in " + properties.CustomSchematicDirectory + "/" + var2[0]+".schematic");
|
||||||
|
|
||||||
if (mod_pocketDim.dungeonHelper.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId) && !player.worldObj.isRemote)
|
if (dungeonHelper.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId) && !player.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
// mod_pocketDim.dungeonHelper.customDungeonStatus.remove(player.worldObj.provider.dimensionId);
|
// mod_pocketDim.dungeonHelper.customDungeonStatus.remove(player.worldObj.provider.dimensionId);
|
||||||
// dimHelper.instance.teleportToPocket(player.worldObj, mod_pocketDim.dungeonHelper.customDungeonStatus.get(player.worldObj.provider.dimensionId), player);
|
// dimHelper.instance.teleportToPocket(player.worldObj, mod_pocketDim.dungeonHelper.customDungeonStatus.get(player.worldObj.provider.dimensionId), player);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CommandStartDungeonCreation extends CommandBase
|
|||||||
|
|
||||||
// dimHelper.instance.teleportToPocket(player.worldObj, link, player);
|
// dimHelper.instance.teleportToPocket(player.worldObj, link, player);
|
||||||
|
|
||||||
mod_pocketDim.dungeonHelper.customDungeonStatus.put(link.destDimID, dimHelper.instance.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID));
|
DungeonHelper.instance().customDungeonStatus.put(link.destDimID, dimHelper.instance.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID));
|
||||||
|
|
||||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("DimID = "+ link.destDimID);
|
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("DimID = "+ link.destDimID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import StevenDimDoors.mod_pocketDim.helpers.jnbt.Tag;
|
|||||||
|
|
||||||
public class DungeonHelper
|
public class DungeonHelper
|
||||||
{
|
{
|
||||||
|
private static DungeonHelper instance = null;
|
||||||
private static DDProperties properties = null;
|
private static DDProperties properties = null;
|
||||||
|
|
||||||
public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_]+");
|
public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_]+");
|
||||||
@@ -76,7 +77,7 @@ public class DungeonHelper
|
|||||||
private HashSet<String> dungeonTypeChecker;
|
private HashSet<String> dungeonTypeChecker;
|
||||||
private Hashtable<String, ArrayList<DungeonGenerator>> dungeonTypeMapping;
|
private Hashtable<String, ArrayList<DungeonGenerator>> dungeonTypeMapping;
|
||||||
|
|
||||||
public DungeonHelper()
|
private DungeonHelper()
|
||||||
{
|
{
|
||||||
//Load the dungeon type checker with the list of all types in lowercase.
|
//Load the dungeon type checker with the list of all types in lowercase.
|
||||||
//Capitalization matters for matching in a hash set.
|
//Capitalization matters for matching in a hash set.
|
||||||
@@ -100,6 +101,27 @@ public class DungeonHelper
|
|||||||
properties = DDProperties.instance();
|
properties = DDProperties.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DungeonHelper create()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
instance = new DungeonHelper();
|
||||||
|
else
|
||||||
|
throw new IllegalStateException("Cannot create DungeonHelper twice");
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DungeonHelper instance()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
//This is to prevent some frustrating bugs that could arise when classes
|
||||||
|
//are loaded in the wrong order. Trust me, I had to squash a few...
|
||||||
|
throw new IllegalStateException("Instance of DungeonHelper requested before creation");
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean validateSchematicName(String name)
|
public boolean validateSchematicName(String name)
|
||||||
{
|
{
|
||||||
String[] dungeonData = name.split("_");
|
String[] dungeonData = name.split("_");
|
||||||
|
|||||||
@@ -978,7 +978,7 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
if(isRandomRift)
|
if(isRandomRift)
|
||||||
{
|
{
|
||||||
mod_pocketDim.dungeonHelper.generateDungeonlink(link);
|
DungeonHelper.instance().generateDungeonlink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
public static SchematicLoader loader;
|
public static SchematicLoader loader;
|
||||||
public static pocketTeleporter teleporter;
|
public static pocketTeleporter teleporter;
|
||||||
public static DungeonHelper dungeonHelper;
|
|
||||||
|
|
||||||
public static ICommand printDimData;
|
public static ICommand printDimData;
|
||||||
public static ICommand removeRiftsCommand;
|
public static ICommand removeRiftsCommand;
|
||||||
@@ -158,7 +157,6 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
loader = new SchematicLoader();
|
loader = new SchematicLoader();
|
||||||
teleporter = new pocketTeleporter();
|
teleporter = new pocketTeleporter();
|
||||||
dungeonHelper= new DungeonHelper();
|
|
||||||
|
|
||||||
printDimData = new CommandPrintDimData();
|
printDimData = new CommandPrintDimData();
|
||||||
removeRiftsCommand = new CommandDeleteRifts();
|
removeRiftsCommand = new CommandDeleteRifts();
|
||||||
@@ -170,18 +168,6 @@ public class mod_pocketDim
|
|||||||
startDungeonCreation = new CommandStartDungeonCreation();
|
startDungeonCreation = new CommandStartDungeonCreation();
|
||||||
tracker = new PlayerRespawnTracker();
|
tracker = new PlayerRespawnTracker();
|
||||||
riftGen = new RiftGenerator();
|
riftGen = new RiftGenerator();
|
||||||
|
|
||||||
File file= new File(properties.CustomSchematicDirectory);
|
|
||||||
file.mkdir();
|
|
||||||
|
|
||||||
String helpFile = "/mods/DimDoors/How_to_add_dungeons.txt";
|
|
||||||
if(new File(helpFile).exists())
|
|
||||||
{
|
|
||||||
copyfile.copyFile(helpFile, file + "/How_to_add_dungeons.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
dungeonHelper.importCustomDungeons(properties.CustomSchematicDirectory);
|
|
||||||
dungeonHelper.registerBaseDungeons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Init
|
@Init
|
||||||
@@ -249,7 +235,6 @@ public class mod_pocketDim
|
|||||||
LanguageRegistry.addName(itemDimDoor, "Dimensional Door");
|
LanguageRegistry.addName(itemDimDoor, "Dimensional Door");
|
||||||
LanguageRegistry.addName(itemRiftBlade , "Rift Blade");
|
LanguageRegistry.addName(itemRiftBlade , "Rift Blade");
|
||||||
|
|
||||||
|
|
||||||
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
||||||
TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER);
|
TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER);
|
||||||
|
|
||||||
@@ -390,8 +375,8 @@ public class mod_pocketDim
|
|||||||
mod_pocketDim.blocksImmuneToRift.add(Block.blockLapis.blockID);
|
mod_pocketDim.blocksImmuneToRift.add(Block.blockLapis.blockID);
|
||||||
mod_pocketDim.blocksImmuneToRift.add(Block.bedrock.blockID);
|
mod_pocketDim.blocksImmuneToRift.add(Block.bedrock.blockID);
|
||||||
|
|
||||||
dungeonHelper.registerFlipBlocks();
|
DungeonHelper.create();
|
||||||
|
|
||||||
proxy.loadTextures();
|
proxy.loadTextures();
|
||||||
proxy.registerRenderers();
|
proxy.registerRenderers();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user