From d15f372c598846fabe4c3e090d0a119fc845d4a3 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 25 Jun 2013 14:28:11 -0400 Subject: [PATCH 1/4] Improved and Renamed CommandRegenPocket Renamed CommandRegenPocket to CommandResetDungeons. Changed command name accordingly. Added a message for the user listing the number of dungeons that were reset. Modified DimHelper slightly to add support for this. Added error condition if user specifies arguments for the command. --- .../commands/CommandRegenPocket.java | 43 ---------------- .../commands/CommandResetDungeons.java | 51 +++++++++++++++++++ .../mod_pocketDim/helpers/dimHelper.java | 33 ++++++------ .../mod_pocketDim/mod_pocketDim.java | 2 +- 4 files changed, 68 insertions(+), 61 deletions(-) delete mode 100644 StevenDimDoors/mod_pocketDim/commands/CommandRegenPocket.java create mode 100644 StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandRegenPocket.java b/StevenDimDoors/mod_pocketDim/commands/CommandRegenPocket.java deleted file mode 100644 index b4d1feb4..00000000 --- a/StevenDimDoors/mod_pocketDim/commands/CommandRegenPocket.java +++ /dev/null @@ -1,43 +0,0 @@ -package StevenDimDoors.mod_pocketDim.commands; - -import java.io.File; - -import net.minecraft.entity.player.EntityPlayer; -import StevenDimDoors.mod_pocketDim.DDProperties; -import StevenDimDoors.mod_pocketDim.DimData; -import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; -import StevenDimDoors.mod_pocketDim.helpers.dimHelper; - -public class CommandRegenPocket extends DDCommandBase -{ - private static CommandRegenPocket instance = null; - - private CommandRegenPocket() - { - super("dd-regenDungeons"); - } - - public static CommandRegenPocket instance() - { - if (instance == null) - instance = new CommandRegenPocket(); - - return instance; - } - - @Override - protected DDCommandResult processCommand(EntityPlayer sender, String[] command) - { - DungeonHelper dungeonHelper = DungeonHelper.instance(); - DDProperties properties = DDProperties.instance(); - - for(DimData data : dimHelper.dimList.values()) - { - if(data.isDimRandomRift) - { - dimHelper.instance.regenPocket(data); - } - } - - } -} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java b/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java new file mode 100644 index 00000000..11c875a6 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java @@ -0,0 +1,51 @@ +package StevenDimDoors.mod_pocketDim.commands; + +import net.minecraft.entity.player.EntityPlayer; +import StevenDimDoors.mod_pocketDim.DimData; +import StevenDimDoors.mod_pocketDim.helpers.dimHelper; + +public class CommandResetDungeons extends DDCommandBase +{ + private static CommandResetDungeons instance = null; + + private CommandResetDungeons() + { + super("dd-resetdungeons", ""); + } + + public static CommandResetDungeons instance() + { + if (instance == null) + instance = new CommandResetDungeons(); + + return instance; + } + + @Override + protected DDCommandResult processCommand(EntityPlayer sender, String[] command) + { + if (command.length > 0) + { + return DDCommandResult.TOO_FEW_ARGUMENTS; + } + + int dungeonCount = 0; + int resetCount = 0; + + for (DimData data : dimHelper.dimList.values()) + { + if (data.isDimRandomRift) + { + dungeonCount++; + if (dimHelper.instance.resetPocket(data)) + { + resetCount++; + } + } + } + + //Notify the user of the results + sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset."); + return DDCommandResult.SUCCESS; + } +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java b/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java index 45de6346..bf30fa19 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java @@ -38,6 +38,7 @@ import StevenDimDoors.mod_pocketDim.DimData; import StevenDimDoors.mod_pocketDim.LinkData; import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream; import StevenDimDoors.mod_pocketDim.PacketHandler; +import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.TileEntityRift; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.world.LimboProvider; @@ -64,7 +65,7 @@ public class dimHelper extends DimensionManager * ArrayList containing any blocks in limbo that have been placed by the player. Cycled through in the common tick manager * @Return */ - public static ArrayList blocksToDecay= new ArrayList(); + public static ArrayList blocksToDecay = new ArrayList(); /** * instance of the dimHelper @@ -812,33 +813,31 @@ public class dimHelper extends DimensionManager } } - public void regenPocket(DimData dimData) + public boolean resetPocket(DimData dimData) { - if(this.getWorld(dimData.dimID)!=null ||!dimData.isPocket) + //TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi + if (getWorld(dimData.dimID) != null || !dimData.isPocket) { - return; + return false; } - File save = new File( this.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + dimData.dimID); + File save = new File(getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimData.dimID); DeleteFolder.deleteFolder(save); - dimData.hasBeenFilled=false; - dimData.hasDoor=false; + dimData.hasBeenFilled = false; + dimData.hasDoor = false; for(LinkData link : dimData.printAllLinkData()) { - link.hasGennedDoor=false; - LinkData linkOut =this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID); - if(linkOut!=null) + link.hasGennedDoor = false; + LinkData linkOut = this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID); + if (linkOut != null) { - linkOut.hasGennedDoor=false; - + linkOut.hasGennedDoor = false; } } - - - - + return true; } + /** - * method called when the client disconects/server stops to unregister dims. + * method called when the client disconnects/server stops to unregister dims. * @Return */ public void unregsisterDims() diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index bd9ab9e9..b2499f47 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -29,7 +29,7 @@ import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts; import StevenDimDoors.mod_pocketDim.commands.CommandEndDungeonCreation; import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData; import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions; -import StevenDimDoors.mod_pocketDim.commands.CommandRegenPocket; +import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons; import StevenDimDoors.mod_pocketDim.commands.CommandStartDungeonCreation; import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; import StevenDimDoors.mod_pocketDim.helpers.dimHelper; From ad0e2cbe61b03b7ffc500cac2541920f1760ce2c Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 25 Jun 2013 20:54:58 -0400 Subject: [PATCH 2/4] Improved CommandPruneDimensions Improved CommandPruneDimensions. Cleaned up the code and improved performance by using a HashSet instead of an ArrayList to list dimension reachability. Added an optional argument that sets whether we should delete the folders of pruned dimensions. --- .../commands/CommandPruneDimensions.java | 56 +++++++++++-------- .../commands/DDCommandResult.java | 1 + .../mod_pocketDim/helpers/dimHelper.java | 19 ++++++- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandPruneDimensions.java b/StevenDimDoors/mod_pocketDim/commands/CommandPruneDimensions.java index d58f0b4d..b130dbf7 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandPruneDimensions.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandPruneDimensions.java @@ -2,6 +2,8 @@ package StevenDimDoors.mod_pocketDim.commands; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import net.minecraft.entity.player.EntityPlayer; import StevenDimDoors.mod_pocketDim.DimData; @@ -14,7 +16,7 @@ public class CommandPruneDimensions extends DDCommandBase private CommandPruneDimensions() { - super("dd-prune"); + super("dd-prune", "['delete']"); } public static CommandPruneDimensions instance() @@ -28,36 +30,44 @@ public class CommandPruneDimensions extends DDCommandBase @Override protected DDCommandResult processCommand(EntityPlayer sender, String[] command) { - int numRemoved=0; - ArrayList dimsWithLinks = new ArrayList(); + if (command.length > 1) + { + return DDCommandResult.TOO_MANY_ARGUMENTS; + } + if (command.length == 1 && !command[0].equalsIgnoreCase("delete")) + { + return DDCommandResult.INVALID_ARGUMENTS; + } + + int removedCount = 0; + boolean deleteFolders = (command.length == 1); + Set linkedDimensions = new HashSet(); Collection allDims = new ArrayList(); allDims.addAll(dimHelper.dimList.values()); - for(DimData data: allDims) + + for (DimData data : allDims) { - for(LinkData link:data.printAllLinkData()) + for (LinkData link : data.printAllLinkData()) { - if(!dimsWithLinks.contains(link.destDimID)) + linkedDimensions.add(link.destDimID); + } + } + for (LinkData link : dimHelper.instance.interDimLinkList.values()) + { + linkedDimensions.add(link.destDimID); + } + for (DimData data : allDims) + { + if (!linkedDimensions.contains(data.dimID)) + { + if (dimHelper.instance.pruneDimension(data, deleteFolders)) { - dimsWithLinks.add(link.destDimID); + removedCount++; } } } - for(LinkData link : dimHelper.instance.interDimLinkList.values()) - { - if(!dimsWithLinks.contains(link.destDimID)) - { - dimsWithLinks.add(link.destDimID); - } - } - for(DimData data : allDims) - { - if(!dimsWithLinks.contains(data.dimID)) - { - dimHelper.dimList.remove(data.dimID); - numRemoved++; - } - } dimHelper.instance.save(); - sender.sendChatToPlayer("Removed " + numRemoved + " unreachable pocket dims."); + sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims."); + return DDCommandResult.SUCCESS; } } \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/DDCommandResult.java b/StevenDimDoors/mod_pocketDim/commands/DDCommandResult.java index c40a99e0..9ec0cf73 100644 --- a/StevenDimDoors/mod_pocketDim/commands/DDCommandResult.java +++ b/StevenDimDoors/mod_pocketDim/commands/DDCommandResult.java @@ -8,6 +8,7 @@ public class DDCommandResult { public static final DDCommandResult TOO_MANY_ARGUMENTS = new DDCommandResult(2, "Error: Too many arguments passed to the command", true); public static final DDCommandResult INVALID_DIMENSION_ID = new DDCommandResult(3, "Error: Invalid dimension ID", true); public static final DDCommandResult UNREGISTERED_DIMENSION = new DDCommandResult(4, "Error: Dimension is not registered", false); + public static final DDCommandResult INVALID_ARGUMENTS = new DDCommandResult(5, "Error: Invalid arguments passed to the command.", true); public static final int CUSTOM_ERROR_CODE = -1; diff --git a/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java b/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java index bf30fa19..e5e357af 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/dimHelper.java @@ -816,7 +816,7 @@ public class dimHelper extends DimensionManager public boolean resetPocket(DimData dimData) { //TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi - if (getWorld(dimData.dimID) != null || !dimData.isPocket) + if (!dimData.isPocket || getWorld(dimData.dimID) != null) { return false; } @@ -836,6 +836,23 @@ public class dimHelper extends DimensionManager return true; } + public boolean pruneDimension(DimData dimData, boolean deleteFolder) + { + //TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi + //TODO: All the logic for checking that this is an isolated pocket should be moved in here. + if (!dimData.isPocket || getWorld(dimData.dimID) != null) + { + return false; + } + dimList.remove(dimData.dimID); + if (deleteFolder) + { + File save = new File(getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimData.dimID); + DeleteFolder.deleteFolder(save); + } + return true; + } + /** * method called when the client disconnects/server stops to unregister dims. * @Return From 6e3c93fa17e3a6ede800a54ec7a564ce37ad4f21 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 25 Jun 2013 23:24:21 -0400 Subject: [PATCH 3/4] Temporary Fix to Commands Temporarily patched up CommandDeleteAllLinks, CommandDeleteDimensionData, and CommandDeleteRifts so they'll compile. I'll be fixing some things for Steven and I'll come back to those classes to finish overhauling them. --- .../mod_pocketDim/commands/CommandDeleteAllLinks.java | 3 ++- .../mod_pocketDim/commands/CommandDeleteDimensionData.java | 3 ++- StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java index 0d27e8e8..191424e5 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java @@ -14,7 +14,7 @@ public class CommandDeleteAllLinks extends DDCommandBase private CommandDeleteAllLinks() { - super("dd-deletelinks"); + super("dd-deletelinks", "FIXME"); } public static CommandDeleteAllLinks instance() @@ -80,5 +80,6 @@ public class CommandDeleteAllLinks extends DDCommandBase sender.sendChatToPlayer("Removed " + linksRemoved + " links."); } } + return DDCommandResult.SUCCESS; //TEMPORARY HACK } } \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimensionData.java b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimensionData.java index 7ba8f09c..388e3dbf 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimensionData.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimensionData.java @@ -14,7 +14,7 @@ public class CommandDeleteDimensionData extends DDCommandBase private CommandDeleteDimensionData() { - super("dd-deletedimension"); + super("dd-deletedimension", "FIXME"); } public static CommandDeleteDimensionData instance() @@ -90,5 +90,6 @@ public class CommandDeleteDimensionData extends DDCommandBase sender.sendChatToPlayer("Error- dimension "+targetDim+" not registered with dimDoors"); } } + return DDCommandResult.SUCCESS; //TEMPORARY HACK } } \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java index 7537371a..d109d82c 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java @@ -15,7 +15,7 @@ public class CommandDeleteRifts extends DDCommandBase private CommandDeleteRifts() { - super("dd-???"); + super("dd-???", "FIXME"); } public static CommandDeleteRifts instance() @@ -84,5 +84,6 @@ public class CommandDeleteRifts extends DDCommandBase sender.sendChatToPlayer("Removed "+linksRemoved+" rifts."); } } + return DDCommandResult.SUCCESS; //TEMPORARY HACK } } \ No newline at end of file From 471114415bd153e2d95548bb5143f094d4f67904 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Wed, 26 Jun 2013 00:45:20 -0400 Subject: [PATCH 4/4] Fixed Rotation in SchematicLoader Fixed reference to CommandRegenPocket - should be CommandResetDungeons. Autofixed indentation in SchematicLoader. I wanted to commit that change before doing any more code changes but I forgot. Then I fixed the code that calculates the coordinate offsets so our dungeons rotate right. It was pretty simple - all I had to do was move the xCooe and zCooe calculations into the loops so they're recalculated to account for rotation. I rearranged the loops for optimal performance. --- .../mod_pocketDim/SchematicLoader.java | 206 +++++++++--------- .../mod_pocketDim/mod_pocketDim.java | 2 +- 2 files changed, 102 insertions(+), 106 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/SchematicLoader.java b/StevenDimDoors/mod_pocketDim/SchematicLoader.java index 2c4f8de5..3ebe87d9 100644 --- a/StevenDimDoors/mod_pocketDim/SchematicLoader.java +++ b/StevenDimDoors/mod_pocketDim/SchematicLoader.java @@ -37,15 +37,15 @@ public class SchematicLoader private Random rand = new Random(); public HashMap>> rotationMap = new HashMap>>(); public int transMeta; - - - - + + + + private DDProperties properties = DDProperties.instance(); - + public SchematicLoader() { } public int transformMetadata(int metadata, int orientation, int blockID) @@ -733,17 +733,17 @@ public class SchematicLoader public void generateSchematic(int incX, int incY, int incZ, int orientation, int destDimID, int originDimID, String schematicPath) { - + short width=0; short height=0; short length=0; //list of combined blockIds short[] blocks = new short[0]; - + //block metaData byte[] blockData = new byte[0]; - + //first 4 bytes of the block ID byte[] blockId = new byte[0]; @@ -756,19 +756,19 @@ public class SchematicLoader NBTTagList entities; NBTTagList tileEntities=null; - + //the wooden door leading into the pocket Point3D incomingLink= new Point3D(0,0,0); - + //the iron dim doors leading to more pockets ArrayList sideLinks = new ArrayList(); - + //the wooden dim doors leading to the surface ArrayList exitLinks = new ArrayList(); - + //the locations to spawn monoliths ArrayList monolithSpawns = new ArrayList(); - + //load the schematic from disk try { @@ -793,7 +793,7 @@ public class SchematicLoader width = nbtdata.getShort("Width"); height = nbtdata.getShort("Height"); length = nbtdata.getShort("Length"); - + //load block info blockId = nbtdata.getByteArray("Blocks"); blockData = nbtdata.getByteArray("Data"); @@ -814,7 +814,7 @@ public class SchematicLoader entities = nbtdata.getTagList("Entities"); tileentities = nbtdata.getTagList("TileEntities"); - **/ + **/ input.close(); //combine the split block IDs into a single short[] @@ -871,16 +871,16 @@ public class SchematicLoader { for ( z = 0; z < length; ++z) { - + int index = y * width * length + z * width + x; int blockToReplace=blocks[index]; int blockMetaData=blockData[index]; - + //NBTTagList tileEntity = tileEntities; //int size = tileEntity.tagCount(); - + if(blockToReplace==Block.doorIron.blockID&&blocks[ (y-1) * width * length + z * width + x]==Block.doorIron.blockID) { sideLinks.add(new Point3D(x,y,z)); @@ -900,56 +900,52 @@ public class SchematicLoader else if(blockToReplace==Block.endPortalFrame.blockID) { monolithSpawns.add(new Point3D(x,y,z)); - + } - + } } } - - //determines necessary rotation, reflection, and translation to build the .schematic by finding the difference between the - //.schematic incomingLink location which is relative to the .schematic only, and comparing it with the world incoming link coordinates - //must also factor in the orientation of the incoming door. - if(orientation==0) //TODO currently broken, only orientation 3 works atm - { - xCooe=-incomingLink.getX()+incX; - yCooe=-incomingLink.getY()+incY; - zCooe=-incomingLink.getZ()+incZ; - } - if(orientation==1)//TODO currently broken, only orientation 3 works atm - { - xCooe=-incomingLink.getX()+incX; - yCooe=-incomingLink.getY()+incY; - zCooe=-incomingLink.getZ()+incZ; - } - if(orientation==2)//TODO currently broken, only orientation 3 works atm - { - xCooe=-incomingLink.getX()+incX; - yCooe=-incomingLink.getY()+incY; - zCooe=-incomingLink.getZ()+incZ; - } - if(orientation==3)//TODO this only works because it is the default orientation of the pocket dim - { - xCooe=-incomingLink.getX()+incX; - yCooe=-incomingLink.getY()+incY; - zCooe=-incomingLink.getZ()+incZ; - } + //Compute the Y-axis translation that places our structure correctly + yCooe = incY - incomingLink.getY(); - //loop to actually place the blocks - for ( x = 0; x < width; ++x) + //Loop to actually place the blocks + for ( x = 0; x < width; x++) { - for ( y = 0; y < height; ++y) + for ( z = 0; z < length; z++) { - for ( z = 0; z < length; ++z) + //Compute the X-axis and Z-axis translations that will shift + //and rotate our structure properly. + switch (orientation) { - + case 0: + xCooe = -incomingLink.getX() + incX; + zCooe = -incomingLink.getZ() + incZ; + break; + case 1: + xCooe = -incomingLink.getX() + incX; + zCooe = -incomingLink.getZ() + incZ; + break; + case 2: + xCooe = -incomingLink.getX() + incX; + zCooe = -incomingLink.getZ() + incZ; + break; + case 3: + xCooe = -incomingLink.getX() + incX; + zCooe = -incomingLink.getZ() + incZ; + break; + } + + for ( y = 0; y < height; y++) + { + int index = y * width * length + z * width + x; int blockToReplace=blocks[index]; int blockMetaData=blockData[index]; NBTTagList tileEntity = tileEntities; - + //replace tagging blocks with air, and mob blocks with FoR if(blockToReplace==Block.endPortalFrame.blockID) { @@ -959,7 +955,7 @@ public class SchematicLoader { blockToReplace=mod_pocketDim.blockDimWall.blockID; } - + //place blocks and metaData if(blockToReplace>0) { @@ -990,23 +986,23 @@ public class SchematicLoader { tile.readFromNBT(tag); } - **/ - - //fill chests - if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityChest) - { - TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); - ChestGenHooks info = DDLoot.DungeonChestInfo; - WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe), info.getCount(rand)); - } - - //fill dispensers - if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityDispenser) - { - TileEntityDispenser dispenser = (TileEntityDispenser) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); - dispenser.addItem(new ItemStack(Item.arrow, 64)); + **/ - } + //fill chests + if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityChest) + { + TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); + ChestGenHooks info = DDLoot.DungeonChestInfo; + WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe), info.getCount(rand)); + } + + //fill dispensers + if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityDispenser) + { + TileEntityDispenser dispenser = (TileEntityDispenser) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); + dispenser.addItem(new ItemStack(Item.arrow, 64)); + + } } } } @@ -1016,39 +1012,39 @@ public class SchematicLoader //generate the LinkData defined by the door placement, Iron Dim doors first for(Point3D point : sideLinks) { - - int depth = dimHelper.instance.getDimDepth(originDimID); - int xNoise = 0; - int zNoise =0; - switch(world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)) - { - case 0: - xNoise = (int)rand.nextInt(depth+1*200)+depth*50; - zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; - break; - case 1: - xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; - zNoise = (int) rand.nextInt(depth+1*200)+depth*50; + int depth = dimHelper.instance.getDimDepth(originDimID); + int xNoise = 0; + int zNoise =0; + switch(world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)) + { + case 0: + xNoise = (int)rand.nextInt(depth+1*200)+depth*50; + zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; - break; - case 2: - xNoise = - (rand.nextInt(depth+1*200)+depth*50); - zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; + break; + case 1: + xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; + zNoise = (int) rand.nextInt(depth+1*200)+depth*50; - break; - case 3: - xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; - zNoise = -(rand.nextInt(depth+1*200)+depth*50); + break; + case 2: + xNoise = - (rand.nextInt(depth+1*200)+depth*50); + zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; - break; - } + break; + case 3: + xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; + zNoise = -(rand.nextInt(depth+1*200)+depth*50); - LinkData sideLink = new LinkData(destDimID,0,point.getX()+xCooe, point.getY()+yCooe, point.getZ()+zCooe,xNoise+point.getX()+xCooe, point.getY()+yCooe+1, zNoise+point.getZ()+zCooe,true,world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)); - dimHelper.instance.createPocket(sideLink, true, true); + break; + } + + LinkData sideLink = new LinkData(destDimID,0,point.getX()+xCooe, point.getY()+yCooe, point.getZ()+zCooe,xNoise+point.getX()+xCooe, point.getY()+yCooe+1, zNoise+point.getZ()+zCooe,true,world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)); + dimHelper.instance.createPocket(sideLink, true, true); } - + //generate linkData for wooden dim doors leading to the overworld for(Point3D point : exitLinks) { @@ -1064,7 +1060,7 @@ public class SchematicLoader else if((rand.nextBoolean()&&randomLink!=null)) { sideLink.destDimID=randomLink.locDimID; - // System.out.println("randomLink"); + // System.out.println("randomLink"); } sideLink.destYCoord=yCoordHelper.getFirstUncovered(sideLink.destDimID, point.getX()+xCooe,10,point.getZ()+zCooe); @@ -1075,7 +1071,7 @@ public class SchematicLoader } sideLink.linkOrientation=world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe); - + dimHelper.instance.createLink(sideLink); dimHelper.instance.createLink(sideLink.destDimID , sideLink.locDimID, sideLink.destXCoord, sideLink.destYCoord, sideLink.destZCoord, sideLink.locXCoord, sideLink.locYCoord, sideLink.locZCoord, dimHelper.instance.flipDoorMetadata(sideLink.linkOrientation)); @@ -1093,7 +1089,7 @@ public class SchematicLoader E.printStackTrace(); } } - + //spawn monoliths for(Point3D point : monolithSpawns) { @@ -1102,7 +1098,7 @@ public class SchematicLoader world.spawnEntityInWorld(mob); } } - + public void generateDungeonPocket(LinkData link) { String filePath=DungeonHelper.instance().defaultBreak.schematicPath; @@ -1124,15 +1120,15 @@ public class SchematicLoader { return; } - + int cX; int cZ; int cY; - + Chunk chunk; cX = x >> 4; - cZ = z >> 4; - cY=y >>4; + cZ = z >> 4; + cY=y >>4; int chunkX=(x % 16)< 0 ? ((x) % 16)+16 : ((x) % 16); int chunkZ=((z) % 16)< 0 ? ((z) % 16)+16 : ((z) % 16); diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index dc2d3261..10af10e6 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -391,7 +391,7 @@ public class mod_pocketDim @ServerStarting public void serverStarting(FMLServerStartingEvent event) { - CommandRegenPocket.instance().register(event); + CommandResetDungeons.instance().register(event); CommandCreateDungeonRift.instance().register(event); CommandDeleteAllLinks.instance().register(event); CommandDeleteDimensionData.instance().register(event);