From 9420b8edf2e28287e6569e2dfd468593e7f1e6fd Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Wed, 9 Oct 2013 19:07:58 -0400 Subject: [PATCH] Deleting dungeons is still buggy --- .../commands/CommandCreateDungeonRift.java | 1 + .../commands/CommandResetDungeons.java | 16 +++++++++++++--- .../mod_pocketDim/core/NewDimData.java | 11 ++++++++++- .../mod_pocketDim/dungeon/DungeonSchematic.java | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java b/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java index 8eff0aa6..0eaefaab 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java @@ -86,6 +86,7 @@ public class CommandCreateDungeonRift extends DDCommandBase if (result != null) { //Create a rift to our selected dungeon and notify the player + //TODO currently crashes dimension = PocketManager.getDimensionData(sender.worldObj); link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON); PocketManager.getDimensionData(link.destination().getDimension()).initializeDungeon(x, y + 1, z, orientation,link, result); diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java b/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java index b7c1bf77..7a34c7c7 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java @@ -29,6 +29,10 @@ public class CommandResetDungeons extends DDCommandBase @Override protected DDCommandResult processCommand(EntityPlayer sender, String[] command) { + if(sender.worldObj.isRemote) + { + return DDCommandResult.SUCCESS; + } if (command.length > 0) { return DDCommandResult.TOO_FEW_ARGUMENTS; @@ -39,13 +43,17 @@ public class CommandResetDungeons extends DDCommandBase ArrayList dimsToDelete = new ArrayList(); for (NewDimData data : PocketManager.getDimensions()) { - dungeonCount++; + if(DimensionManager.getWorld(data.id())==null&&data.isDungeon()) { + resetCount++; + dungeonCount++; dimsToDelete.add(data.id()); } else if(data.isDungeon()) { + data.setParentToRoot(); + dungeonCount++; for(DimLink link : data.links()) { if(link.linkType()==LinkTypes.REVERSE) @@ -59,13 +67,15 @@ public class CommandResetDungeons extends DDCommandBase } } } + NewDimData test = PocketManager.getDimensionData(sender.worldObj.provider.dimensionId); + test.parent().depth(); for(Integer dimID:dimsToDelete) { PocketManager.deletePocket(PocketManager.getDimensionData(dimID), true); } - + test.parent().depth(); + //TODO- for some reason test.parent is null even though I just set like 23 lines earlier, in data.setParentToRoot //TODO implement blackList - //Notify the user of the results sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset."); return DDCommandResult.SUCCESS; diff --git a/StevenDimDoors/mod_pocketDim/core/NewDimData.java b/StevenDimDoors/mod_pocketDim/core/NewDimData.java index 100be9a4..ac06ed52 100644 --- a/StevenDimDoors/mod_pocketDim/core/NewDimData.java +++ b/StevenDimDoors/mod_pocketDim/core/NewDimData.java @@ -453,7 +453,6 @@ public abstract class NewDimData { throw new IllegalArgumentException("orientation must be between 0 and 3, inclusive."); } - setDestination(incoming, originX, originY, originZ); this.origin = incoming.destination(); this.orientation = orientation; @@ -461,6 +460,16 @@ public abstract class NewDimData this.packDepth = calculatePackDepth(parent, dungeon); } + /** + * effectivly moves the dungeon to the 'top' of a chain as far as dungeon generation is concerend. + */ + public void setParentToRoot() + { + this.depth=1; + this.parent=this.root; + this.root.children.add(this); + } + public static int calculatePackDepth(NewDimData parent, DungeonData current) { DungeonData predecessor = parent.dungeon(); diff --git a/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java b/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java index 053008f7..a2edde4c 100644 --- a/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java +++ b/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java @@ -202,6 +202,8 @@ public class DungeonSchematic extends Schematic { //In the future, we might want to make this more efficient by building whole chunks at a time setBlockDirectly(world, pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), blockID, blockMeta); + world.markBlockForRenderUpdate((pocketPoint.getX()), pocketPoint.getY(), pocketPoint.getZ()); + index++; } }