merged SenseiKiwi changes
This commit is contained in:
parent
a2eb4cf524
commit
0752c032d3
9 changed files with 515 additions and 555 deletions
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.WeightedRandomChestContent;
|
import net.minecraft.util.WeightedRandomChestContent;
|
||||||
import net.minecraftforge.common.ChestGenHooks;
|
import net.minecraftforge.common.ChestGenHooks;
|
||||||
|
|
||||||
|
@ -27,9 +28,9 @@ public class DDLoot {
|
||||||
public static ChestGenHooks DungeonChestInfo = null;
|
public static ChestGenHooks DungeonChestInfo = null;
|
||||||
private static final int CHEST_SIZE = 5;
|
private static final int CHEST_SIZE = 5;
|
||||||
|
|
||||||
private static final int COMMON_LOOT_WEIGHT = 10; //As common as iron ingots
|
private static final int COMMON_LOOT_WEIGHT = 9; //1 less than weight of iron ingots
|
||||||
private static final int UNCOMMON_LOOT_WEIGHT = 5; //As common as iron armor loot
|
private static final int UNCOMMON_LOOT_WEIGHT = 4; //1 less than weight of iron armor
|
||||||
private static final int RARE_LOOT_WEIGHT = 3; //As common as diamonds
|
private static final int RARE_LOOT_WEIGHT = 1; //Same weight as music discs, golden apple
|
||||||
private static final int DUNGEON_CHEST_WEIGHT_INFLATION = 10; // (weight of iron ingots in dungeon) / (weight of iron ingots in other chests)
|
private static final int DUNGEON_CHEST_WEIGHT_INFLATION = 10; // (weight of iron ingots in dungeon) / (weight of iron ingots in other chests)
|
||||||
|
|
||||||
public static void registerInfo()
|
public static void registerInfo()
|
||||||
|
@ -113,6 +114,19 @@ public class DDLoot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//I've added a minor hack here to make enchanted books more common
|
||||||
|
//If this is necessary for more items, create an override table and use that
|
||||||
|
//rather than hardcoding the changes below
|
||||||
|
final int enchantedBookID = Item.enchantedBook.itemID;
|
||||||
|
for (WeightedRandomChestContent item : container.values())
|
||||||
|
{
|
||||||
|
if (item.theItemId.itemID == enchantedBookID)
|
||||||
|
{
|
||||||
|
item.itemWeight = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Return merged list
|
//Return merged list
|
||||||
return new ArrayList<WeightedRandomChestContent>( container.values() );
|
return new ArrayList<WeightedRandomChestContent>( container.values() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,8 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class DungeonGenerator implements Serializable
|
public class DungeonGenerator implements Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
public int weight;
|
public int weight;
|
||||||
public String schematicPath;
|
public String schematicPath;
|
||||||
public ArrayList<HashMap> sideRifts = new ArrayList<HashMap>();
|
public ArrayList<HashMap> sideRifts = new ArrayList<HashMap>();
|
||||||
|
@ -22,21 +19,10 @@ public class DungeonGenerator implements Serializable
|
||||||
public int exitDoorsSoFar=0;
|
public int exitDoorsSoFar=0;
|
||||||
public int deadEndsSoFar=0;
|
public int deadEndsSoFar=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DungeonGenerator(int weight, String schematicPath, Boolean isOpen)
|
public DungeonGenerator(int weight, String schematicPath, Boolean isOpen)
|
||||||
{
|
{
|
||||||
this.weight=weight;
|
this.weight=weight;
|
||||||
this.schematicPath=schematicPath;
|
this.schematicPath=schematicPath;
|
||||||
this.isOpen=isOpen;
|
this.isOpen=isOpen;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -173,7 +173,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))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -984,8 +984,7 @@ public class SchematicLoader
|
||||||
if(world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe) instanceof TileEntityChest)
|
if(world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe) instanceof TileEntityChest)
|
||||||
{
|
{
|
||||||
TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe);
|
TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe);
|
||||||
|
ChestGenHooks info = DDLoot.DungeonChestInfo;
|
||||||
ChestGenHooks info = ChestGenHooks.getInfo(DDLoot.DIMENSIONAL_DUNGEON_CHEST);
|
|
||||||
WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe), info.getCount(rand));
|
WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe), info.getCount(rand));
|
||||||
}
|
}
|
||||||
if(world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe) instanceof TileEntityDispenser)
|
if(world.getBlockTileEntity(i+xCooe, j+yCooe, k+zCooe) instanceof TileEntityDispenser)
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
|
|
||||||
public class CommandEndDungeonCreation extends CommandBase
|
public class CommandEndDungeonCreation extends CommandBase
|
||||||
{
|
{
|
||||||
private static DDProperties properties = null;
|
private static DDProperties properties = null;
|
||||||
private static Pattern nameFilter = Pattern.compile("[A-Za-z0-9_]+");
|
|
||||||
|
|
||||||
public CommandEndDungeonCreation()
|
public CommandEndDungeonCreation()
|
||||||
{
|
{
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -59,13 +61,12 @@ public class CommandEndDungeonCreation extends CommandBase
|
||||||
else if(!player.worldObj.isRemote)
|
else if(!player.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
//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 (nameFilter.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");
|
||||||
mod_pocketDim.dungeonHelper.customDungeons.add(newDungeon);
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,13 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.HashSet;
|
||||||
import java.util.Map.Entry;
|
import java.util.Hashtable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||||
|
@ -19,191 +18,225 @@ import StevenDimDoors.mod_pocketDim.LinkData;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ByteArrayTag;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ByteArrayTag;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.CompoundTag;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.CompoundTag;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.IntTag;
|
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ListTag;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ListTag;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.NBTOutputStream;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.NBTOutputStream;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ShortTag;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ShortTag;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.StringTag;
|
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.Tag;
|
import StevenDimDoors.mod_pocketDim.helpers.jnbt.Tag;
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
* @Return
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class DungeonHelper
|
public class DungeonHelper
|
||||||
{
|
{
|
||||||
|
private static DungeonHelper instance = null;
|
||||||
public DungeonHelper()
|
|
||||||
{
|
|
||||||
if (properties == null)
|
|
||||||
properties = DDProperties.instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DDProperties properties = null;
|
private static DDProperties properties = null;
|
||||||
|
|
||||||
|
public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_]+");
|
||||||
|
|
||||||
|
private static final String SCHEMATIC_FILE_EXTENSION = ".schematic";
|
||||||
|
private static final int DEFAULT_DUNGEON_WEIGHT = 100;
|
||||||
|
private static final int MAX_DUNGEON_WEIGHT = 10000; //Used to prevent overflows and math breaking down
|
||||||
|
|
||||||
|
private static final String HUB_DUNGEON_TYPE = "Hub";
|
||||||
|
private static final String TRAP_DUNGEON_TYPE = "Trap";
|
||||||
|
private static final String SIMPLE_HALL_DUNGEON_TYPE = "SimpleHall";
|
||||||
|
private static final String COMPLEX_HALL_DUNGEON_TYPE = "ComplexHall";
|
||||||
|
private static final String EXIT_DUNGEON_TYPE = "Exit";
|
||||||
|
private static final String DEAD_END_DUNGEON_TYPE = "DeadEnd";
|
||||||
|
private static final String MAZE_DUNGEON_TYPE = "Maze";
|
||||||
|
|
||||||
|
//The list of dungeon types will be kept as an array for now. If we allow new
|
||||||
|
//dungeon types in the future, then this can be changed to an ArrayList.
|
||||||
|
private static final String[] DUNGEON_TYPES = new String[] {
|
||||||
|
HUB_DUNGEON_TYPE,
|
||||||
|
TRAP_DUNGEON_TYPE,
|
||||||
|
SIMPLE_HALL_DUNGEON_TYPE,
|
||||||
|
COMPLEX_HALL_DUNGEON_TYPE,
|
||||||
|
EXIT_DUNGEON_TYPE,
|
||||||
|
DEAD_END_DUNGEON_TYPE,
|
||||||
|
MAZE_DUNGEON_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
private Random rand = new Random();
|
private Random rand = new Random();
|
||||||
|
|
||||||
public HashMap<Integer, LinkData> customDungeonStatus = new HashMap<Integer, LinkData>();
|
public HashMap<Integer, LinkData> customDungeonStatus = new HashMap<Integer, LinkData>();
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> customDungeons = new ArrayList<DungeonGenerator>();
|
public ArrayList<DungeonGenerator> customDungeons = new ArrayList<DungeonGenerator>();
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> registeredDungeons = new ArrayList<DungeonGenerator>();
|
public ArrayList<DungeonGenerator> registeredDungeons = new ArrayList<DungeonGenerator>();
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> weightedDungeonGenList = new ArrayList<DungeonGenerator>();
|
private ArrayList<DungeonGenerator> weightedDungeonGenList = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> simpleHalls = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> complexHalls = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> deadEnds = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> hubs = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> mazes = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> pistonTraps = new ArrayList<DungeonGenerator>();
|
||||||
|
private ArrayList<DungeonGenerator> exits = new ArrayList<DungeonGenerator>();
|
||||||
|
|
||||||
|
public ArrayList<Integer> metadataFlipList = new ArrayList<Integer>();
|
||||||
public ArrayList<DungeonGenerator> simpleHalls = new ArrayList<DungeonGenerator>();
|
public ArrayList<Integer> metadataNextList = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> complexHalls = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> deadEnds = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> hubs = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> mazes = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> pistonTraps = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<DungeonGenerator> exits = new ArrayList<DungeonGenerator>();
|
|
||||||
|
|
||||||
public ArrayList<String> tagList = new ArrayList<String>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList metadataFlipList = new ArrayList();
|
|
||||||
|
|
||||||
public ArrayList metadataNextList = new ArrayList();
|
|
||||||
|
|
||||||
public static DungeonGenerator defaultUp = new DungeonGenerator(0, "/schematic/simpleStairsUp.schematic", true);
|
|
||||||
public static DungeonGenerator defaultBreak = new DungeonGenerator(0, "/schematic/somethingBroke.schematic", true);
|
public static DungeonGenerator defaultBreak = new DungeonGenerator(0, "/schematic/somethingBroke.schematic", true);
|
||||||
public void registerCustomDungeon(File schematicFile)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
if(schematicFile.getName().contains(".schematic"))
|
|
||||||
{
|
|
||||||
String[] name = schematicFile.getName().split("_");
|
|
||||||
|
|
||||||
if(name.length<4)
|
|
||||||
{
|
|
||||||
System.out.println("Could not parse filename tags, not adding dungeon to generation lists");
|
|
||||||
this.customDungeons.add(new DungeonGenerator(0,schematicFile.getAbsolutePath(),true));
|
|
||||||
System.out.println("Imported "+schematicFile.getName());
|
|
||||||
|
|
||||||
|
|
||||||
|
public DungeonGenerator defaultUp = new DungeonGenerator(0, "/schematic/simpleStairsUp.schematic", true);
|
||||||
|
private HashSet<String> dungeonTypeChecker;
|
||||||
|
private Hashtable<String, ArrayList<DungeonGenerator>> dungeonTypeMapping;
|
||||||
|
|
||||||
|
private DungeonHelper()
|
||||||
|
{
|
||||||
|
//Load the dungeon type checker with the list of all types in lowercase.
|
||||||
|
//Capitalization matters for matching in a hash set.
|
||||||
|
dungeonTypeChecker = new HashSet<String>();
|
||||||
|
for (String dungeonType : DUNGEON_TYPES)
|
||||||
|
{
|
||||||
|
dungeonTypeChecker.add(dungeonType.toLowerCase());
|
||||||
}
|
}
|
||||||
else if(!(name[2].equals("open")||name[2].equals("closed"))||!this.tagList.contains(name[0]))
|
|
||||||
{
|
|
||||||
System.out.println("Could not parse filename tags, not adding dungeon to generation lists");
|
|
||||||
this.customDungeons.add(new DungeonGenerator(0,schematicFile.getAbsolutePath(),true));
|
|
||||||
System.out.println("Imported "+schematicFile.getName());
|
|
||||||
|
|
||||||
|
//Add all the basic dungeon types to dungeonTypeMapping
|
||||||
|
dungeonTypeMapping = new Hashtable<String, ArrayList<DungeonGenerator>>();
|
||||||
|
dungeonTypeMapping.put(SIMPLE_HALL_DUNGEON_TYPE, simpleHalls);
|
||||||
|
dungeonTypeMapping.put(COMPLEX_HALL_DUNGEON_TYPE, complexHalls);
|
||||||
|
dungeonTypeMapping.put(HUB_DUNGEON_TYPE, hubs);
|
||||||
|
dungeonTypeMapping.put(EXIT_DUNGEON_TYPE, exits);
|
||||||
|
dungeonTypeMapping.put(DEAD_END_DUNGEON_TYPE, deadEnds);
|
||||||
|
dungeonTypeMapping.put(MAZE_DUNGEON_TYPE, mazes);
|
||||||
|
dungeonTypeMapping.put(TRAP_DUNGEON_TYPE, pistonTraps);
|
||||||
|
|
||||||
|
//Load our reference to the DDProperties singleton
|
||||||
|
if (properties == null)
|
||||||
|
properties = DDProperties.instance();
|
||||||
|
|
||||||
|
initializeDungeons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeDungeons()
|
||||||
|
{
|
||||||
|
File file = new File(properties.CustomSchematicDirectory);
|
||||||
|
String helpFile = "/mods/DimDoors/How_to_add_dungeons.txt";
|
||||||
|
if (new File(helpFile).exists())
|
||||||
|
{
|
||||||
|
copyfile.copyFile(helpFile, file + "/How_to_add_dungeons.txt");
|
||||||
|
}
|
||||||
|
file.mkdir();
|
||||||
|
|
||||||
|
registerFlipBlocks();
|
||||||
|
importCustomDungeons(properties.CustomSchematicDirectory);
|
||||||
|
registerBaseDungeons();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DungeonHelper create()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = new DungeonHelper();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int count=0;
|
throw new IllegalStateException("Cannot create DungeonHelper twice");
|
||||||
|
}
|
||||||
|
|
||||||
boolean open= name[2].equals("open");
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
int weight = Integer.parseInt(name[3].replace(".schematic", ""));
|
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)
|
||||||
|
{
|
||||||
|
String[] dungeonData = name.split("_");
|
||||||
|
|
||||||
|
//Check for a valid number of parts
|
||||||
|
if (dungeonData.length < 3 || dungeonData.length > 4)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
//Check if the dungeon type is valid
|
||||||
|
if (!dungeonTypeChecker.contains(dungeonData[0].toLowerCase()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Check if the name is valid
|
||||||
|
if (!NamePattern.matcher(dungeonData[1]).matches())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Check if the open/closed flag is present
|
||||||
|
if (!dungeonData[2].equalsIgnoreCase("open") && !dungeonData[2].equalsIgnoreCase("closed"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//If the weight is present, check that it is valid
|
||||||
|
if (dungeonData.length == 4)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int weight = Integer.parseInt(dungeonData[3]);
|
||||||
|
if (weight < 0 || weight > MAX_DUNGEON_WEIGHT)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
//Not a number
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCustomDungeon(File schematicFile)
|
||||||
|
{
|
||||||
|
String name = schematicFile.getName();
|
||||||
String path = schematicFile.getAbsolutePath();
|
String path = schematicFile.getAbsolutePath();
|
||||||
|
try
|
||||||
while(count<weight)
|
|
||||||
{
|
{
|
||||||
if(name[0].equals("hub"))
|
if (name.endsWith(SCHEMATIC_FILE_EXTENSION) && validateSchematicName(name))
|
||||||
{
|
{
|
||||||
this.hubs.add(new DungeonGenerator(weight,path,open));
|
//Strip off the file extension while splitting the file name
|
||||||
|
String[] dungeonData = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length()).split("_");
|
||||||
|
|
||||||
|
String dungeonType = dungeonData[0].toLowerCase();
|
||||||
|
boolean open = dungeonData[2].equals("open");
|
||||||
|
int weight = (dungeonData.length == 4) ? Integer.parseInt(dungeonData[3]) : DEFAULT_DUNGEON_WEIGHT;
|
||||||
|
|
||||||
|
//Add this custom dungeon to the list corresponding to its type
|
||||||
|
DungeonGenerator generator = new DungeonGenerator(weight, path, open);
|
||||||
|
|
||||||
|
dungeonTypeMapping.get(dungeonType).add(generator);
|
||||||
|
weightedDungeonGenList.add(generator);
|
||||||
|
registeredDungeons.add(generator);
|
||||||
|
customDungeons.add(generator);
|
||||||
|
System.out.println("Imported " + name);
|
||||||
}
|
}
|
||||||
else if(name[0].equals("simpleHall"))
|
else
|
||||||
{
|
{
|
||||||
this.simpleHalls.add(new DungeonGenerator(weight,path,open));
|
System.out.println("Could not parse dungeon filename, not adding dungeon to generation lists");
|
||||||
|
customDungeons.add(new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, path, true));
|
||||||
|
System.out.println("Imported " + name);
|
||||||
}
|
}
|
||||||
else if(name[0].equals("complexHall"))
|
|
||||||
{
|
|
||||||
this.complexHalls.add(new DungeonGenerator(weight,path,open));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(name[0].equals("trap"))
|
|
||||||
{
|
|
||||||
this.pistonTraps.add(new DungeonGenerator(weight,path,open));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(name[0].equals("deadEnd"))
|
|
||||||
{
|
|
||||||
this.deadEnds.add(new DungeonGenerator(weight,path,open));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(name[0].equals("exit"))
|
|
||||||
{
|
|
||||||
this.exits.add(new DungeonGenerator(weight,path,open));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(name[0].equals("maze"))
|
|
||||||
{
|
|
||||||
this.mazes.add(new DungeonGenerator(weight,path,open));
|
|
||||||
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
this.weightedDungeonGenList.add(new DungeonGenerator(weight,path,open));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.registeredDungeons.add(new DungeonGenerator(weight,path,open));
|
|
||||||
System.out.println("Imported "+schematicFile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Importing custom dungeon failed");
|
System.out.println("Failed to import " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importCustomDungeons(String dir)
|
public void importCustomDungeons(String dir)
|
||||||
{
|
{
|
||||||
File file = new File(dir);
|
File file = new File(dir);
|
||||||
File[] schematicNames=file.listFiles();
|
File[] schematicNames = file.listFiles();
|
||||||
|
|
||||||
if(schematicNames!=null)
|
if (schematicNames!=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
for(File schematicFile: schematicNames)
|
for(File schematicFile: schematicNames)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.registerCustomDungeon(schematicFile);
|
this.registerCustomDungeon(schematicFile);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void registerFlipBlocks()
|
public void registerFlipBlocks()
|
||||||
{
|
{
|
||||||
this.metadataFlipList.add(Block.dispenser.blockID);
|
this.metadataFlipList.add(Block.dispenser.blockID);
|
||||||
|
@ -220,10 +253,7 @@ public class DungeonHelper
|
||||||
this.metadataFlipList.add(Block.doorWood.blockID);
|
this.metadataFlipList.add(Block.doorWood.blockID);
|
||||||
this.metadataFlipList.add(Block.pistonBase.blockID);
|
this.metadataFlipList.add(Block.pistonBase.blockID);
|
||||||
this.metadataFlipList.add(Block.pistonStickyBase.blockID);
|
this.metadataFlipList.add(Block.pistonStickyBase.blockID);
|
||||||
|
|
||||||
this.metadataFlipList.add(Block.pistonExtension.blockID);
|
this.metadataFlipList.add(Block.pistonExtension.blockID);
|
||||||
|
|
||||||
|
|
||||||
this.metadataFlipList.add(Block.redstoneComparatorIdle.blockID);
|
this.metadataFlipList.add(Block.redstoneComparatorIdle.blockID);
|
||||||
this.metadataFlipList.add(Block.redstoneComparatorActive.blockID);
|
this.metadataFlipList.add(Block.redstoneComparatorActive.blockID);
|
||||||
this.metadataFlipList.add(Block.signPost.blockID);
|
this.metadataFlipList.add(Block.signPost.blockID);
|
||||||
|
@ -235,28 +265,16 @@ public class DungeonHelper
|
||||||
this.metadataFlipList.add(Block.chest.blockID);
|
this.metadataFlipList.add(Block.chest.blockID);
|
||||||
this.metadataFlipList.add(Block.chestTrapped.blockID);
|
this.metadataFlipList.add(Block.chestTrapped.blockID);
|
||||||
this.metadataFlipList.add(Block.hopperBlock.blockID);
|
this.metadataFlipList.add(Block.hopperBlock.blockID);
|
||||||
|
|
||||||
this.metadataFlipList.add(Block.stairsNetherBrick.blockID);
|
this.metadataFlipList.add(Block.stairsNetherBrick.blockID);
|
||||||
this.metadataFlipList.add(Block.stairsCobblestone.blockID);
|
this.metadataFlipList.add(Block.stairsCobblestone.blockID);
|
||||||
this.metadataFlipList.add(Block.stairsNetherBrick.blockID);
|
this.metadataFlipList.add(Block.stairsNetherBrick.blockID);
|
||||||
this.metadataFlipList.add(Block.stairsNetherQuartz.blockID);
|
this.metadataFlipList.add(Block.stairsNetherQuartz.blockID);
|
||||||
this.metadataFlipList.add(Block.stairsSandStone.blockID);
|
this.metadataFlipList.add(Block.stairsSandStone.blockID);
|
||||||
|
|
||||||
|
|
||||||
this.metadataNextList.add(Block.redstoneRepeaterIdle.blockID);
|
this.metadataNextList.add(Block.redstoneRepeaterIdle.blockID);
|
||||||
this.metadataNextList.add(Block.redstoneRepeaterActive.blockID);
|
this.metadataNextList.add(Block.redstoneRepeaterActive.blockID);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
public void registerDungeonTypeTags()
|
|
||||||
{
|
|
||||||
tagList.add("hub");
|
|
||||||
tagList.add("trap");
|
|
||||||
tagList.add("simpleHall");
|
|
||||||
tagList.add("complexHall");
|
|
||||||
tagList.add("exit");
|
|
||||||
tagList.add("deadEnd");
|
|
||||||
tagList.add("maze");
|
|
||||||
}
|
|
||||||
public void registerBaseDungeons()
|
public void registerBaseDungeons()
|
||||||
{
|
{
|
||||||
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayBasicHall.schematic", false));
|
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayBasicHall.schematic", false));
|
||||||
|
@ -269,7 +287,6 @@ public class DungeonHelper
|
||||||
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayHallExit.schematic", false));
|
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayHallExit.schematic", false));
|
||||||
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayHallExit.schematic", false));
|
this.hubs.add(new DungeonGenerator(0, "/schematics/4WayHallExit.schematic", false));
|
||||||
|
|
||||||
|
|
||||||
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/collapsedSingleTunnel1.schematic", false));
|
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/collapsedSingleTunnel1.schematic", false));
|
||||||
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/singleStraightHall1.schematic", false));
|
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/singleStraightHall1.schematic", false));
|
||||||
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/smallBranchWithExit.schematic", false));
|
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/smallBranchWithExit.schematic", false));
|
||||||
|
@ -279,7 +296,6 @@ public class DungeonHelper
|
||||||
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/simpleStairsDown.schematic", false));
|
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/simpleStairsDown.schematic", false));
|
||||||
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/simpleSmallT1.schematic", false));
|
this.simpleHalls.add(new DungeonGenerator(0, "/schematics/simpleSmallT1.schematic", false));
|
||||||
|
|
||||||
|
|
||||||
this.complexHalls.add(new DungeonGenerator(0, "/schematics/tntPuzzleTrap.schematic", false));
|
this.complexHalls.add(new DungeonGenerator(0, "/schematics/tntPuzzleTrap.schematic", false));
|
||||||
this.complexHalls.add(new DungeonGenerator(0, "/schematics/brokenPillarsO.schematic", true));
|
this.complexHalls.add(new DungeonGenerator(0, "/schematics/brokenPillarsO.schematic", true));
|
||||||
this.complexHalls.add(new DungeonGenerator(0, "/schematics/buggyTopEntry1.schematic", true));
|
this.complexHalls.add(new DungeonGenerator(0, "/schematics/buggyTopEntry1.schematic", true));
|
||||||
|
@ -289,7 +305,6 @@ public class DungeonHelper
|
||||||
this.complexHalls.add(new DungeonGenerator(0, "/schematics/ruinsO.schematic", true));
|
this.complexHalls.add(new DungeonGenerator(0, "/schematics/ruinsO.schematic", true));
|
||||||
this.complexHalls.add(new DungeonGenerator(0, "/schematics/pitStairs.schematic", true));
|
this.complexHalls.add(new DungeonGenerator(0, "/schematics/pitStairs.schematic", true));
|
||||||
|
|
||||||
|
|
||||||
this.deadEnds.add(new DungeonGenerator(0, "/schematics/azersDungeonO.schematic", false));
|
this.deadEnds.add(new DungeonGenerator(0, "/schematics/azersDungeonO.schematic", false));
|
||||||
this.deadEnds.add(new DungeonGenerator(0, "/schematics/diamondTowerTemple1.schematic", true));
|
this.deadEnds.add(new DungeonGenerator(0, "/schematics/diamondTowerTemple1.schematic", true));
|
||||||
this.deadEnds.add(new DungeonGenerator(0, "/schematics/fallingTrapO.schematic", false));
|
this.deadEnds.add(new DungeonGenerator(0, "/schematics/fallingTrapO.schematic", false));
|
||||||
|
@ -302,37 +317,27 @@ public class DungeonHelper
|
||||||
this.deadEnds.add(new DungeonGenerator(0, "/schematics/smallDesert.schematic", true));
|
this.deadEnds.add(new DungeonGenerator(0, "/schematics/smallDesert.schematic", true));
|
||||||
this.deadEnds.add(new DungeonGenerator(0, "/schematics/smallPond.schematic", true));
|
this.deadEnds.add(new DungeonGenerator(0, "/schematics/smallPond.schematic", true));
|
||||||
|
|
||||||
|
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/fakeTNTTrap.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/fakeTNTTrap.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/hallwayPitFallTrap.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/hallwayPitFallTrap.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/hallwayPitFallTrap.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/hallwayPitFallTrap.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFallRuins.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFallRuins.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFloorHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFloorHall.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFloorHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonFloorHall.schematic", false));
|
||||||
// this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonHallway.schematic", null));
|
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonSmasherHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/pistonSmasherHall.schematic", false));
|
||||||
// this.pistonTraps.add(new DungeonGenerator(0, "/schematics/raceTheTNTHall.schematic", false));
|
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/simpleDropHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/simpleDropHall.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/wallFallcomboPistonHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/wallFallcomboPistonHall.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/wallFallcomboPistonHall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/wallFallcomboPistonHall.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/fallingTNThall.schematic", false));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/fallingTNThall.schematic", false));
|
||||||
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/lavaPyramid.schematic", true));
|
this.pistonTraps.add(new DungeonGenerator(0, "/schematics/lavaPyramid.schematic", true));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.mazes.add(new DungeonGenerator(0, "/schematics/smallMaze1.schematic", false));
|
this.mazes.add(new DungeonGenerator(0, "/schematics/smallMaze1.schematic", false));
|
||||||
this.mazes.add(new DungeonGenerator(0, "/schematics/smallMultilevelMaze.schematic", false));
|
this.mazes.add(new DungeonGenerator(0, "/schematics/smallMultilevelMaze.schematic", false));
|
||||||
|
|
||||||
|
|
||||||
this.exits.add(new DungeonGenerator(0, "/schematics/exitCube.schematic", true));
|
this.exits.add(new DungeonGenerator(0, "/schematics/exitCube.schematic", true));
|
||||||
this.exits.add(new DungeonGenerator(0, "/schematics/lockingExitHall.schematic", false));
|
this.exits.add(new DungeonGenerator(0, "/schematics/lockingExitHall.schematic", false));
|
||||||
this.exits.add(new DungeonGenerator(0, "/schematics/smallExitPrison.schematic", true));
|
this.exits.add(new DungeonGenerator(0, "/schematics/smallExitPrison.schematic", true));
|
||||||
this.exits.add(new DungeonGenerator(0, "/schematics/lockingExitHall.schematic", false));
|
this.exits.add(new DungeonGenerator(0, "/schematics/lockingExitHall.schematic", false));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.weightedDungeonGenList.addAll(this.simpleHalls);
|
this.weightedDungeonGenList.addAll(this.simpleHalls);
|
||||||
this.weightedDungeonGenList.addAll(this.exits);
|
this.weightedDungeonGenList.addAll(this.exits);
|
||||||
this.weightedDungeonGenList.addAll(this.pistonTraps);
|
this.weightedDungeonGenList.addAll(this.pistonTraps);
|
||||||
|
@ -346,15 +351,12 @@ public class DungeonHelper
|
||||||
if(!this.registeredDungeons.contains(data))
|
if(!this.registeredDungeons.contains(data))
|
||||||
{
|
{
|
||||||
this.registeredDungeons.add(data);
|
this.registeredDungeons.add(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DungeonGenerator exportDungeon(World world, int xI, int yI, int zI, String file)
|
public DungeonGenerator exportDungeon(World world, int xI, int yI, int zI, String file)
|
||||||
{
|
{
|
||||||
|
|
||||||
int xMin;
|
int xMin;
|
||||||
int yMin;
|
int yMin;
|
||||||
int zMin;
|
int zMin;
|
||||||
|
@ -401,9 +403,7 @@ public class DungeonHelper
|
||||||
short length= (short) (zMax-zMin);
|
short length= (short) (zMax-zMin);
|
||||||
|
|
||||||
//ArrayList<NBTTagCompound> tileEntities = new ArrayList<NBTTagCompound>();
|
//ArrayList<NBTTagCompound> tileEntities = new ArrayList<NBTTagCompound>();
|
||||||
|
ArrayList<Tag> tileEntites = new ArrayList<Tag>();
|
||||||
|
|
||||||
ArrayList<Tag> tileEntites= new ArrayList<Tag>();
|
|
||||||
byte[] blocks = new byte[width * height * length];
|
byte[] blocks = new byte[width * height * length];
|
||||||
byte[] addBlocks = null;
|
byte[] addBlocks = null;
|
||||||
byte[] blockData = new byte[width * height * length];
|
byte[] blockData = new byte[width * height * length];
|
||||||
|
@ -464,8 +464,6 @@ public class DungeonHelper
|
||||||
}
|
}
|
||||||
**/
|
**/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,23 +477,24 @@ public class DungeonHelper
|
||||||
this.nbtdata.setByteArray("Data", blockData);
|
this.nbtdata.setByteArray("Data", blockData);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HashMap schematic = new HashMap();
|
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||||
|
|
||||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||||
|
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||||
schematic.put("TileEntites", new ListTag("TileEntities",CompoundTag.class,tileEntites));
|
schematic.put("TileEntites", new ListTag("TileEntities", CompoundTag.class,tileEntites));
|
||||||
if (addBlocks != null) {
|
|
||||||
|
if (addBlocks != null)
|
||||||
|
{
|
||||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
NBTOutputStream stream = new NBTOutputStream(new FileOutputStream(file));
|
NBTOutputStream stream = new NBTOutputStream(new FileOutputStream(file));
|
||||||
stream.writeTag(schematicTag);
|
stream.writeTag(schematicTag);
|
||||||
stream.close();
|
stream.close();
|
||||||
|
@ -506,11 +505,9 @@ public class DungeonHelper
|
||||||
}
|
}
|
||||||
this.registerCustomDungeon(new File(file));
|
this.registerCustomDungeon(new File(file));
|
||||||
|
|
||||||
return new DungeonGenerator(0,file,true);
|
return new DungeonGenerator(0, file, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void generateDungeonlink(LinkData incoming)
|
public void generateDungeonlink(LinkData incoming)
|
||||||
{
|
{
|
||||||
//DungeonGenerator dungeon = mod_pocketDim.registeredDungeons.get(new Random().nextInt(mod_pocketDim.registeredDungeons.size()));
|
//DungeonGenerator dungeon = mod_pocketDim.registeredDungeons.get(new Random().nextInt(mod_pocketDim.registeredDungeons.size()));
|
||||||
|
@ -525,7 +522,6 @@ public class DungeonHelper
|
||||||
int count=10;
|
int count=10;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if(dimHelper.dimList.get(incoming.destDimID)!=null&&dimHelper.dimList.get(incoming.destDimID).dungeonGenerator!=null)
|
if(dimHelper.dimList.get(incoming.destDimID)!=null&&dimHelper.dimList.get(incoming.destDimID).dungeonGenerator!=null)
|
||||||
{
|
{
|
||||||
mod_pocketDim.loader.init(incoming);
|
mod_pocketDim.loader.init(incoming);
|
||||||
|
@ -561,11 +557,8 @@ public class DungeonHelper
|
||||||
{
|
{
|
||||||
flag=false;
|
flag=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(depth<=3&&(deadEnds.contains(dungeon)||exits.contains(dungeon)||rand.nextBoolean()))
|
else if (depth<=3&&(deadEnds.contains(dungeon)||exits.contains(dungeon)||rand.nextBoolean()))
|
||||||
{
|
{
|
||||||
if(rand.nextBoolean())
|
if(rand.nextBoolean())
|
||||||
{
|
{
|
||||||
|
@ -602,7 +595,6 @@ public class DungeonHelper
|
||||||
dungeon = hubs.get(rand.nextInt(hubs.size()));
|
dungeon = hubs.get(rand.nextInt(hubs.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(depthWeight-depthWeight/2>depth-4&&(deadEnds.contains(dungeon)||exits.contains(dungeon)))
|
else if(depthWeight-depthWeight/2>depth-4&&(deadEnds.contains(dungeon)||exits.contains(dungeon)))
|
||||||
{
|
{
|
||||||
|
@ -641,7 +633,6 @@ public class DungeonHelper
|
||||||
dungeon = pistonTraps.get(rand.nextInt(pistonTraps.size()));
|
dungeon = pistonTraps.get(rand.nextInt(pistonTraps.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -652,18 +643,17 @@ public class DungeonHelper
|
||||||
{
|
{
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
while(!flag&&count>0);
|
while (!flag && count > 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dungeon= defaultUp;
|
dungeon = defaultUp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if(weightedDungeonGenList.size()>0)
|
if (weightedDungeonGenList.size() > 0)
|
||||||
{
|
{
|
||||||
dungeon = weightedDungeonGenList.get(rand.nextInt(weightedDungeonGenList.size()));
|
dungeon = weightedDungeonGenList.get(rand.nextInt(weightedDungeonGenList.size()));
|
||||||
}
|
}
|
||||||
|
@ -673,22 +663,6 @@ public class DungeonHelper
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dimHelper.dimList.get(incoming.destDimID).dungeonGenerator = dungeon;
|
||||||
|
|
||||||
|
|
||||||
dimHelper.dimList.get(incoming.destDimID).dungeonGenerator=dungeon;
|
|
||||||
//loader.generateSchematic(incoming,0,0,0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -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,19 +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();
|
|
||||||
dungeonHelper.registerDungeonTypeTags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Init
|
@Init
|
||||||
|
@ -250,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);
|
||||||
|
|
||||||
|
@ -391,7 +375,7 @@ 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();
|
||||||
|
|
Loading…
Reference in a new issue