From 415a3c29d7903c4ce1dc6e887fd17ad3ec528f42 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Sun, 26 Jan 2014 04:26:09 -0500 Subject: [PATCH 01/11] removed rotation mechanic --- .../mod_pocketDim/blocks/BaseDimDoor.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index bddb39b..139b00d 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -63,32 +63,6 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - boolean shouldOpen = true; - - if (player.inventory.getCurrentItem()!=null) - { - if(player.inventory.getCurrentItem().getItem() == mod_pocketDim.itemRiftBlade) - { - shouldOpen = false; - if (!world.isRemote && world.getBlockId(x, y-1, z) == this.blockID) - { - world.setBlockMetadataWithNotify(x, y-1, z, (world.getBlockMetadata(x, y-1, z)+1)%4, 2); - } - if (!world.isRemote && world.getBlockId(x, y+1, z) == this.blockID) - { - world.setBlockMetadataWithNotify(x, y, z, (world.getBlockMetadata(x, y, z)+1)%4, 2); - } - world.playAuxSFXAtEntity(player, 1001, x, y, z, 0); - - if (!shouldOpen && !world.isRemote) - { - player.inventory.getCurrentItem().damageItem(5, player); - } - } - } - - if(shouldOpen) - { int var10 = this.getFullMetadata(world, x, y, z); int var11 = var10 & 7; var11 ^= 4; @@ -106,19 +80,12 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn world.playAuxSFXAtEntity(player, 1003, x, y, z, 0); return true; - } - else - { - return false; - } } @Override public void onBlockAdded(World world, int x, int y, int z) { - //FIXME: We need to set door generation flags on the tile entities. Ignoring that for now. ~SenseiKiwi - this.placeLink(world, x, y, z); world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world)); this.updateAttachedTile(world, x, y, z); -- 2.39.5 From d52f0ed2c7ca4609074f031c1e6ba5eca3816aba Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Sun, 26 Jan 2014 13:39:09 -0500 Subject: [PATCH 02/11] Minor Tweaks --- .../StevenDimDoors/mod_pocketDim/DDLoot.java | 6 +++- .../mod_pocketDim/blocks/BaseDimDoor.java | 31 +++++++++---------- .../mod_pocketDim/blocks/BlockRift.java | 3 +- .../dungeon/pack/DungeonPack.java | 2 +- .../mod_pocketDim/helpers/DungeonHelper.java | 7 +++-- .../world/gateways/BaseGateway.java | 3 +- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java index d8045b6..225ebdf 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java @@ -49,9 +49,13 @@ public class DDLoot { addContent(true, items, Item.diamond.itemID, 40, 1, 2); addContent(true, items, Item.emerald.itemID, 20, 1, 2); addContent(true, items, Item.appleGold.itemID, 10); + addContent(true, items, Item.nameTag.itemID, 15); + addContent(true, items, Item.eyeOfEnder.itemID, 15); + addContent(true, items, Item.ghastTear.itemID, 15); addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 80, 4, 16); - addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 80); + addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 90, 1,2); + // Add all the items to our dungeon chest addItemsToContainer(DungeonChestInfo, items); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index 139b00d..3233c6e 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -63,24 +63,23 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - int var10 = this.getFullMetadata(world, x, y, z); - int var11 = var10 & 7; - var11 ^= 4; + int var10 = this.getFullMetadata(world, x, y, z); + int var11 = var10 & 7; + var11 ^= 4; - if ((var10 & 8) == 0) - { - world.setBlockMetadataWithNotify(x, y, z, var11,2); - world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); - } - else - { - world.setBlockMetadataWithNotify(x, y - 1, z, var11,2); - world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z); - } - - world.playAuxSFXAtEntity(player, 1003, x, y, z, 0); - return true; + if ((var10 & 8) == 0) + { + world.setBlockMetadataWithNotify(x, y, z, var11,2); + world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + } + else + { + world.setBlockMetadataWithNotify(x, y - 1, z, var11,2); + world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z); + } + world.playAuxSFXAtEntity(player, 1003, x, y, z, 0); + return true; } @Override diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java index e438bcc..85719c3 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java @@ -43,6 +43,7 @@ public class BlockRift extends Block implements ITileEntityProvider private static final int BLOCK_SEARCH_CHANCE = 50; private static final int MAX_BLOCK_DESTRUCTION_CHANCE = 100; private static final int BLOCK_DESTRUCTION_CHANCE = 50; + private static final int WORLD_THREAD_PROBABILITY = 10; private final DDProperties properties; private final ArrayList blocksImmuneToRift; @@ -208,7 +209,7 @@ public class BlockRift extends Block implements ITileEntityProvider { return; } - if(worldObj.rand.nextInt(7)==0) + if(worldObj.rand.nextInt(100) history = DungeonHelper.getDungeonChainHistory(dimension.parent(), this, maxSearchLength); + ArrayList history = DungeonHelper.getDungeonChainHistory(dimension, this, maxSearchLength); return getNextDungeon(history, random); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/src/main/java/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index ac5b191..3f8e7a3 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -615,9 +615,12 @@ public class DungeonHelper { throw new IllegalArgumentException("dimension cannot be null."); } - + if(dimension.parent()==null) + { + return new ArrayList(); + } int count = 0; - NewDimData tail = dimension; + NewDimData tail = dimension.parent(); DungeonData dungeon = tail.dungeon(); ArrayList history = new ArrayList(); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java index 8662927..9dfae59 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java @@ -73,8 +73,7 @@ public abstract class BaseGateway this.generateRandomBits(world, x, y, z); DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); - NewDimData data = PocketManager.registerPocket(PocketManager.getDimensionData(world), true); - PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, this.getStartingDungeon(data,world.rand)); + PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, this.getStartingDungeon(PocketManager.getDimensionData(world),world.rand)); return true; } -- 2.39.5 From 523025365a5b39ceead5b4bda8d23fb8eba1b75c Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Sun, 26 Jan 2014 14:27:44 -0500 Subject: [PATCH 03/11] removed default nether gateways --- .../StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java index 268d4b5..c5bb477 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java @@ -67,7 +67,7 @@ public class GatewayGenerator implements IWorldGenerator //the current world is a pocket dimension, or the world is remote. //Also don't generate anything in The End. if (world.isRemote || (!properties.WorldRiftGenerationEnabled) || - (world.provider instanceof PocketProvider) || (world.provider.dimensionId == END_DIMENSION_ID)) + (world.provider instanceof PocketProvider) || (world.provider.dimensionId == END_DIMENSION_ID)||(world.provider.dimensionId == NETHER_DIMENSION_ID)) { return; } -- 2.39.5 From c830a8e812c2db6ce6707af9a69b64d120ae032f Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Sun, 26 Jan 2014 14:32:28 -0500 Subject: [PATCH 04/11] build --- src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java index 225ebdf..cb36970 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java @@ -56,7 +56,6 @@ public class DDLoot { addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 80, 4, 16); addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 90, 1,2); - // Add all the items to our dungeon chest addItemsToContainer(DungeonChestInfo, items); } -- 2.39.5 From ca42be0a5e61d486a5378bc4f7c6ad5cc37c7fe1 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 16:25:49 -0500 Subject: [PATCH 05/11] debug --- .../java/StevenDimDoors/mod_pocketDim/DDLoot.java | 2 +- .../mod_pocketDim/blocks/BlockRift.java | 14 ++++++-------- .../mod_pocketDim/saving/DDSaveHandler.java | 7 ++++--- .../mod_pocketDim/tileentities/TileEntityRift.java | 10 +++++++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java index cb36970..503d669 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java @@ -54,7 +54,7 @@ public class DDLoot { addContent(true, items, Item.ghastTear.itemID, 15); addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 80, 4, 16); - addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 90, 1,2); + addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 120, 1,4); // Add all the items to our dungeon chest addItemsToContainer(DungeonChestInfo, items); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java index 85719c3..713e8bc 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java @@ -199,7 +199,7 @@ public class BlockRift extends Block implements ITileEntityProvider } private void spawnWorldThread(int blockID,World worldObj,int x,int y,int z ) { - if(blockID == 0) + if(blockID == 0||!(worldObj.rand.nextInt(100) pointDistances, Queue points) { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java index c5ea571..675ff43 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java @@ -88,8 +88,10 @@ public class DDSaveHandler public static boolean unpackDimData(List packedDims) { List unpackedDims = new ArrayList(); - - + for(PackedDimData data : packedDims) + { + System.out.println(data.ID); + } //Load roots for(PackedDimData packedDim : packedDims) { @@ -144,7 +146,6 @@ public class DDSaveHandler linkType = LinkTypes.NORMAL; } - @SuppressWarnings("deprecation") DimLink link = data.createLink(packedLink.source, linkType, packedLink.orientation); Point4D destination = packedLink.tail.destination; if(destination!=null) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java index 9cedd18..6432062 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java @@ -170,10 +170,14 @@ public class TileEntityRift extends TileEntity EntityEnderman enderman = new EntityEnderman(worldObj); enderman.setLocationAndAngles(xCoord + 0.5, yCoord - 1, zCoord + 0.5, 5, 6); worldObj.spawnEntityInWorld(enderman); - EntityPlayer player = this.worldObj.getClosestPlayerToEntity(enderman, 50); - if(player!=null) + + if(this.worldObj.rand.nextInt(3)==0) { - enderman.setTarget(player); + EntityPlayer player = this.worldObj.getClosestPlayerToEntity(enderman, 50); + if(player!=null) + { + enderman.setTarget(player); + } } } } -- 2.39.5 From c935156b7172bb735ca7b02567f6a593d229a3e0 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 17:01:23 -0500 Subject: [PATCH 06/11] working on saving --- .../mod_pocketDim/saving/DDSaveHandler.java | 54 ++++++++----------- .../mod_pocketDim/saving/OldSaveImporter.java | 4 +- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java index 675ff43..c23fd20 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java @@ -5,6 +5,7 @@ import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import net.minecraftforge.common.DimensionManager; @@ -59,24 +60,22 @@ public class DDSaveHandler // List any dimension data files and read each dimension DimDataProcessor reader = new DimDataProcessor(); - List packedDims = new ArrayList(); + HashMap packedDims = new HashMap(); FileFilter dataFileFilter = new FileFilters.RegexFileFilter("dim_-?\\d+\\.txt"); File[] dataFiles = dataDirectory.listFiles(dataFileFilter); for (File dataFile : dataFiles) { PackedDimData packedDim = readDimension(dataFile, reader); - packedDims.add(packedDim); + packedDims.put(packedDim.ID,packedDim); } List linksToUnpack = new ArrayList(); //get the grand list of all links to unpack - for(PackedDimData packedDim : packedDims) + for(PackedDimData packedDim : packedDims.values()) { linksToUnpack.addAll(packedDim.Links); } - - return unpackDimData(packedDims)&&unpackLinkData(linksToUnpack); } @@ -85,47 +84,36 @@ public class DDSaveHandler * @param packedDims * @return */ - public static boolean unpackDimData(List packedDims) + public static boolean unpackDimData(HashMap packedDims) { - List unpackedDims = new ArrayList(); - for(PackedDimData data : packedDims) - { - System.out.println(data.ID); - } + ArrayList roots = new ArrayList(); + //Load roots - for(PackedDimData packedDim : packedDims) + for(PackedDimData packedDim : packedDims.values()) { if(packedDim.ParentID==packedDim.ID) { PocketManager.registerPackedDimData(packedDim); - unpackedDims.add(packedDim); + roots.add(packedDim); } } - packedDims.removeAll(unpackedDims); - unpackedDims.clear(); - - //Load the pockets - while(!packedDims.isEmpty()) + //load the children for each root + for(PackedDimData packedDim : roots) { - for(PackedDimData packedDim : packedDims) - { - if(PocketManager.isRegisteredInternally(packedDim.ParentID)) - { - PocketManager.registerPackedDimData(packedDim); - unpackedDims.add(packedDim); - } - else - { - //break here gracefully - } - } - packedDims.removeAll(unpackedDims); - unpackedDims.clear(); - + registerChildren(packedDim, packedDims); } return true; } + private static void registerChildren(PackedDimData data, HashMap packedDims) + { + PocketManager.registerPackedDimData(data); + for(Integer child : data.ChildIDs) + { + registerChildren(packedDims.get(child),packedDims); + } + } + public static boolean unpackLinkData(List linksToUnpack) { Point3D fakePoint = new Point3D(-1,-1,-1); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java index cefaf36..42b8d01 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java @@ -25,7 +25,7 @@ public class OldSaveImporter save.close(); List allPackedLinks = new ArrayList(); - List newPackedDimData = new ArrayList(); + HashMap newPackedDimData = new HashMap(); HashMap dimMap; @@ -59,7 +59,7 @@ public class OldSaveImporter } PackedDimData dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null); - newPackedDimData.add(dim); + newPackedDimData.put(dim.ID,dim); DDSaveHandler.unpackDimData(newPackedDimData); DDSaveHandler.unpackLinkData(allPackedLinks); -- 2.39.5 From d725ce6b5ededebe49e1254251f5edcb336f7083 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 17:31:13 -0500 Subject: [PATCH 07/11] loading fixed --- .../mod_pocketDim/saving/DDSaveHandler.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java index c23fd20..9b6081b 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java @@ -87,7 +87,9 @@ public class DDSaveHandler public static boolean unpackDimData(HashMap packedDims) { ArrayList roots = new ArrayList(); - + ArrayList children = new ArrayList(); + ArrayList tempChildren = new ArrayList(); + //Load roots for(PackedDimData packedDim : packedDims.values()) { @@ -100,18 +102,22 @@ public class DDSaveHandler //load the children for each root for(PackedDimData packedDim : roots) { - registerChildren(packedDim, packedDims); + children.addAll(packedDim.ChildIDs); } - return true; - } - - private static void registerChildren(PackedDimData data, HashMap packedDims) - { - PocketManager.registerPackedDimData(data); - for(Integer child : data.ChildIDs) + while(!children.isEmpty()) { - registerChildren(packedDims.get(child),packedDims); + for(Integer child: children) + { + PackedDimData data = packedDims.get(child); + PocketManager.registerPackedDimData(data); + tempChildren.addAll(data.ChildIDs); + } + children.clear(); + children.addAll(tempChildren); + tempChildren.clear(); } + + return true; } public static boolean unpackLinkData(List linksToUnpack) -- 2.39.5 From ac7dbab39ff33e84f4d5cf435b84963b3b8e624f Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 18:07:19 -0500 Subject: [PATCH 08/11] loot tweaks --- src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java | 3 +-- .../StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java index 503d669..2bf8000 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/DDLoot.java @@ -49,12 +49,11 @@ public class DDLoot { addContent(true, items, Item.diamond.itemID, 40, 1, 2); addContent(true, items, Item.emerald.itemID, 20, 1, 2); addContent(true, items, Item.appleGold.itemID, 10); - addContent(true, items, Item.nameTag.itemID, 15); addContent(true, items, Item.eyeOfEnder.itemID, 15); addContent(true, items, Item.ghastTear.itemID, 15); addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 80, 4, 16); - addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 120, 1,4); + addContent(properties.WorldThreadLootEnabled, items, mod_pocketDim.itemWorldThread.itemID, 90, 2,10); // Add all the items to our dungeon chest addItemsToContainer(DungeonChestInfo, items); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java index b975529..de4103e 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java @@ -218,7 +218,13 @@ public class MobMonolith extends EntityFlying implements IMob { aggro++; } - + } + else + { + if(aggro>0) + { + aggro--; + } } } } -- 2.39.5 From 18c11ee24ec3889665a9d6292b7166e95e90a223 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 22:13:32 -0500 Subject: [PATCH 09/11] Overhauled loading --- .../mod_pocketDim/saving/DDSaveHandler.java | 60 ++++++++++++------- .../mod_pocketDim/saving/PackedDimData.java | 6 ++ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java index 9b6081b..1d6ea46 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java @@ -5,7 +5,10 @@ import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; +import java.util.Deque; import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import net.minecraftforge.common.DimensionManager; @@ -86,39 +89,56 @@ public class DDSaveHandler */ public static boolean unpackDimData(HashMap packedDims) { - ArrayList roots = new ArrayList(); - ArrayList children = new ArrayList(); + LinkedList children = new LinkedList(); ArrayList tempChildren = new ArrayList(); - - //Load roots + int registeredDims=packedDims.keySet().size(); + for(PackedDimData packedDim : packedDims.values()) { - if(packedDim.ParentID==packedDim.ID) + //Load roots + if(packedDim.RootID==packedDim.ID) { + children.add(packedDim.ID); PocketManager.registerPackedDimData(packedDim); - roots.add(packedDim); + } + //fix pockets without parents + if(!packedDims.containsKey(packedDim.ParentID)) + { + packedDim=(new PackedDimData(packedDim.ID, 1, packedDim.PackDepth, packedDim.RootID, packedDim.RootID, packedDim.Orientation, packedDim.IsDungeon, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, packedDim.ChildIDs, packedDim.Links, packedDim.Tails)); + packedDims.put(packedDim.ID, packedDim); + children.addLast(packedDim.ID); } } //load the children for each root - for(PackedDimData packedDim : roots) - { - children.addAll(packedDim.ChildIDs); - } while(!children.isEmpty()) { - for(Integer child: children) - { - PackedDimData data = packedDims.get(child); - PocketManager.registerPackedDimData(data); - tempChildren.addAll(data.ChildIDs); - } - children.clear(); - children.addAll(tempChildren); - tempChildren.clear(); + Integer childID = children.pop(); + PackedDimData data = packedDims.get(childID); + children.addAll(verifyChildren(data, packedDims)); + PocketManager.registerPackedDimData(data); } - return true; } + private static ArrayList verifyChildren(PackedDimData packedDim,HashMap packedDims) + { + ArrayList children = new ArrayList(); + children.addAll(packedDim.ChildIDs); + boolean isMissing = false; + for(Integer childID : packedDim.ChildIDs) + { + if(!packedDims.containsKey(childID)) + { + children.remove(childID); + isMissing=true; + } + } + if(isMissing) + { + packedDim=(new PackedDimData(packedDim.ID, packedDim.Depth, packedDim.PackDepth, packedDim.ParentID, packedDim.RootID, packedDim.Orientation, packedDim.IsDungeon, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, children, packedDim.Links, packedDim.Tails)); + packedDims.put(packedDim.ID, packedDim); + } + return children; + } public static boolean unpackLinkData(List linksToUnpack) { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java index 524ef54..fb058d3 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java @@ -43,4 +43,10 @@ public class PackedDimData Links = links; Tails = tails; } + + @Override + public String toString() + { + return "ID= "+this.ID; + } } -- 2.39.5 From 1dc7ee7a29462b0edb4c1ee481c7038364f6ee9b Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 27 Jan 2014 23:45:01 -0500 Subject: [PATCH 10/11] Last tweaks --- .../mod_pocketDim/saving/DDSaveHandler.java | 6 ++++++ src/main/resources/schematics/ruins.txt | 5 ++--- ...ComplexHall_CerePuzzleWall_Open_100.schematic | Bin 0 -> 2778 bytes 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/schematics/ruins/ComplexHall_CerePuzzleWall_Open_100.schematic diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java index 1d6ea46..cf6124c 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java @@ -119,6 +119,12 @@ public class DDSaveHandler } return true; } + /** + * ensures that a pocket's children havent been deleted + * @param packedDim + * @param packedDims + * @return + */ private static ArrayList verifyChildren(PackedDimData packedDim,HashMap packedDims) { ArrayList children = new ArrayList(); diff --git a/src/main/resources/schematics/ruins.txt b/src/main/resources/schematics/ruins.txt index 5fa8a1f..2641e62 100644 --- a/src/main/resources/schematics/ruins.txt +++ b/src/main/resources/schematics/ruins.txt @@ -80,6 +80,5 @@ /schematics/ruins/Trap_SK-UTrapRight_Open_50.schematic /schematics/ruins/trap_wallFallcomboPistonHall_closed_200.schematic /schematics/ruins/DeadEnd_Floating-Altar_Open_100.schematic - - -DeadEnd_Floating-Altar_Open +/schematics/ruins/complexHall_exitRuinsWithHiddenDoor_open_100 +.schematic diff --git a/src/main/resources/schematics/ruins/ComplexHall_CerePuzzleWall_Open_100.schematic b/src/main/resources/schematics/ruins/ComplexHall_CerePuzzleWall_Open_100.schematic new file mode 100644 index 0000000000000000000000000000000000000000..00882384943cac6255c96dc8b78c1cb4dffe0aa4 GIT binary patch literal 2778 zcmds3dpOe#8(xKy97?9hp+ZIDeKl6(SUEJa%K5ks4)fC}G0CZNC`n2oTSmsF38e{b zsEEy)!*c3JV@^>mB*r`Jb6wwiecyF`e}8|y_aFCtUC;GA*L^?FUyoM$Cdj`b%tv1t zXxVuyw|KupRY0q=@ybK9jiUQWQ3{o)AM~G|q{x=p-(wrjz1+5MPuhdY)2ngGn%CM& zw8)2cCFTvznQXp4taZ*~(Bti9-*p{(k&oE7rVXK1%w+2rCKZoqG#ARh8C_*q<1D7{ zF;1>5*sNQ#wMJntURw`=ASkoL4R3*x0;uNpe69*!B+Bo-V(%hsE`UHZFV_&y49-k1 z$Uq>E><09H=y-DaGwOP`vCLogWMQ)aZr+OvvF9FJ^0zbN;M0rgI@gtp`wo85G@O5C z+5|q;=nJhL5av|*9p2hbgJltoasJ$@HXcx2wA;cv2DhP9N$jKBP}Bc$@I6Io^?1v@ z^|i1;4L`>cSa8qa?yKl%6_A_pIm1c^BpnaEQ*mkCTU;j~{1Gcg9@vu{yjcDbcKb7* z5A|fTA-S~>(>p6l%$h{)C22=0T|q%%k_mw*#0*cNJA~Ss4y#K+N-fK?EB`+E|4%;j zyO|GdXF> zenJ@?)SZ9_89RbWT}}nFr?L+VTTC9-F43*>k(GSR@1YVN{uoZ)e$@X^_Q12{2abHl zaf>u&ZktH=SAu?GM20V5YuVv+zOLIbNSzyCm!XQPUSXO~l75dcMpCruweF2>t?@6& zXqo%+a{fyU;$*s|Q+gQnM4}PDDwUxWPs(dvg zVms`TN@MvNne9G+WI!}Jxw04~3Fx;#?jb?zFk@^*V{`)6?9OY<-J()ekEQ+m#HRGb z`SyYgyWmzbM?g54`NYjw^K+ek{P|54ps|$5C~tT|joXh=;Q3kRMyqmE(4(b@qdN;| zM(eA^J+rfY!Q|*6%>Jm^vN7q6rjC&zwFaF(8Qs(AhVxXJlZmu-NkKGxNay;bpvRTB zntdLhn2MH;cJr~UU3MPt+k$q$H&D2_Q72sV%XB+>Huli3UVjcPb?9>~4&~UZ4jt6; zqr$u}sPXdGH!q-Ab`$O-Jc_l~Pp*oP71FglYp}Zm03L8uV4d_a!CmN%vOG90%<bksUU*$FR)j&0<(J7-;7cA!d+LtrAbYKxgkByHVk%W~+HnvoTBQ-AkncU2Lmu z1RQ(i6TMh~v^6{m-2z^`@QTnDc0gWo2fE+S$Kw5j;>I`lDbIBJZy65N2p%{&CIegI zD-~a4d4Or&{A`OdFLqZ%7>5z&DKzF)e+bYR=Uy_!K8Ld4)GI!KI;|oxkv-7i`#t0!B9!iOEf!cHk5s z{FF!Vry6rbQ2Owl*PefszLv{E8r(;qT#T`cDfAFlQp#)Jr8kBSmas&AB|{{@R_k(VHYdnP=S;KB8FO{yXAIQo&P2Zaa0 zLI28>e6J&+CW1mBFx6DZ0*itpkAuxLZaW7Dx(fT@C8VPG4)?Odw_7 zO?$yL*ik2zKam9p1a#1aGk@Qelk-UiWx^@6MVVm_|LMyxCY=a25t!GAc+9jIsS8Si2P^hItI1?V|9Z!o20PpV2Gp#Rfa3{V-s5HQ_2FXda zLyGS^di9Q{-1B;@gKt9>H@+?bz^;{h9szZ}K;{yBO2#aix@l9w+xCa9<-$PzmKDI=C@YXEToJPy9LDgpby Uy7o;Olu9;?qub`Y9M?ns1p-H53jhEB literal 0 HcmV?d00001 -- 2.39.5 From 78d7db0f75ed71c86cc58c20ee11c959559bf9ed Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 28 Jan 2014 07:02:11 -0400 Subject: [PATCH 11/11] Implemented Nether Gateways Completed Nether gateways as part of Nether fortresses. --- .../mod_pocketDim/EventHookContainer.java | 25 ++- .../mod_pocketDim/mod_pocketDim.java | 4 +- .../fortresses/ComponentNetherGateway.java | 181 ++++++++++++++++++ .../fortresses/DDNetherFortressGenerator.java | 24 +++ .../DDStructureNetherBridgeStart.java | 145 ++++++++++++++ 5 files changed, 369 insertions(+), 10 deletions(-) create mode 100644 src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/ComponentNetherGateway.java create mode 100644 src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDNetherFortressGenerator.java create mode 100644 src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDStructureNetherBridgeStart.java diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java index a6e3745..afc1c35 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java @@ -1,9 +1,7 @@ package StevenDimDoors.mod_pocketDim; -import paulscode.sound.SoundSystem; import net.minecraft.block.Block; import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPool; import net.minecraft.client.audio.SoundPoolEntry; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -14,15 +12,13 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent; import net.minecraftforge.client.event.sound.SoundLoadEvent; -import net.minecraftforge.event.Event; import net.minecraftforge.event.EventPriority; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingFallEvent; -import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.terraingen.InitMapGenEvent; import net.minecraftforge.event.world.WorldEvent; -import StevenDimDoors.mod_pocketDim.blocks.IDimDoor; import StevenDimDoors.mod_pocketDim.core.DDTeleporter; import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.items.BaseItemDoor; @@ -30,6 +26,7 @@ import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator; import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.world.LimboProvider; import StevenDimDoors.mod_pocketDim.world.PocketProvider; +import StevenDimDoors.mod_pocketDim.world.fortresses.DDNetherFortressGenerator; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -43,6 +40,15 @@ public class EventHookContainer this.properties = properties; } + @ForgeSubscribe(priority = EventPriority.LOW) + public void onMapGen(InitMapGenEvent event) + { + if (event.type == InitMapGenEvent.EventType.NETHER_BRIDGE) + { + event.newGen = new DDNetherFortressGenerator(); + } + } + @SideOnly(Side.CLIENT) @ForgeSubscribe public void onSoundLoad(SoundLoadEvent event) @@ -56,8 +62,8 @@ public class EventHookContainer event.manager.addSound(mod_pocketDim.modid+":riftClose.ogg"); event.manager.addSound(mod_pocketDim.modid+":riftDoor.ogg"); event.manager.addSound(mod_pocketDim.modid+":creepy.ogg"); - } + @SideOnly(Side.CLIENT) @ForgeSubscribe public void onSoundEffectResult(PlayBackgroundMusicEvent event) @@ -68,7 +74,6 @@ public class EventHookContainer } } - @ForgeSubscribe public void onPlayerEvent(PlayerInteractEvent event) { @@ -113,6 +118,7 @@ public class EventHookContainer } } } + @ForgeSubscribe public void onWorldLoad(WorldEvent.Load event) { @@ -129,7 +135,7 @@ public class EventHookContainer RiftRegenerator.regenerateRiftsInAllWorlds(); } - if(event.world!=null) + if (event.world != null) { this.playMusicForDim(event.world); } @@ -140,7 +146,8 @@ public class EventHookContainer { event.setCanceled(event.entity.worldObj.provider.dimensionId == properties.LimboDimensionID); } - @ForgeSubscribe(priority=EventPriority.HIGHEST) + + @ForgeSubscribe(priority = EventPriority.HIGHEST) public boolean LivingDeathEvent(LivingDeathEvent event) { Entity entity = event.entity; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index 26fab1e..3c61aa1 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -174,7 +174,9 @@ public class mod_pocketDim properties = DDProperties.initialize(new File(path)); //Now do other stuff - MinecraftForge.EVENT_BUS.register(new EventHookContainer(properties)); + EventHookContainer hooks = new EventHookContainer(properties); + MinecraftForge.EVENT_BUS.register(hooks); + MinecraftForge.TERRAIN_GEN_BUS.register(hooks); gatewayGenerator = new GatewayGenerator(properties); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/ComponentNetherGateway.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/ComponentNetherGateway.java new file mode 100644 index 0000000..d8c149e --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/ComponentNetherGateway.java @@ -0,0 +1,181 @@ +package StevenDimDoors.mod_pocketDim.world.fortresses; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.core.DimLink; +import StevenDimDoors.mod_pocketDim.core.LinkTypes; +import StevenDimDoors.mod_pocketDim.core.NewDimData; +import StevenDimDoors.mod_pocketDim.core.PocketManager; +import StevenDimDoors.mod_pocketDim.items.BaseItemDoor; + +public class ComponentNetherGateway extends StructureComponent +{ + // Note: In this case, it doesn't really matter which class we extend, since this class will + // never be passed to Minecraft. We just need an instance to have access to structure-building methods. + // If Forge supports adding custom fortress structures in the future, then we might have to change + // our class to extend ComponentNetherBridgeCrossing or something along those lines. ~SenseiKiwi + + public ComponentNetherGateway(int componentType, Random random, StructureBoundingBox bounds, int coordBaseMode) + { + super(componentType); + + this.boundingBox = bounds; + this.coordBaseMode = coordBaseMode; + } + + /** + * Creates and returns a new component piece. Or null if it could not find enough room to place it. + */ + public static ComponentNetherGateway createValidComponent(List components, Random random, int minX, int minY, int minZ, int coordBaseMode, int componentType) + { + StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(minX, minY, minZ, -2, 0, 0, 7, 9, 7, coordBaseMode); + return isAboveGround(bounds) && StructureComponent.findIntersecting(components, bounds) == null ? new ComponentNetherGateway(componentType, random, bounds, coordBaseMode) : null; + } + + public static ComponentNetherGateway createFromComponent(StructureComponent component, Random random) + { + // Create an instance of our gateway component using the same data as another component, + // likely a component that we intend to replace during generation + return new ComponentNetherGateway( component.getComponentType(), random, + component.getBoundingBox(), getCoordBaseMode(component)); + } + + private static int getCoordBaseMode(StructureComponent component) + { + // This is a hack to get the value of a component's coordBaseMode field. + // It's essentially the orientation of the component... with a weird name. + return component.func_143010_b().getInteger("O"); + } + + /** + * Checks if the bounding box's minY is > 10 + */ + protected static boolean isAboveGround(StructureBoundingBox par0StructureBoundingBox) + { + return par0StructureBoundingBox != null && par0StructureBoundingBox.minY > 10; + } + + /** + * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at + * the end, it adds Fences... + */ + public boolean addComponentParts(World world, Random random, StructureBoundingBox bounds) + { + int NETHER_SLAB_METADATA = 6; + + // Set all the blocks in the area of the room to air + this.fillWithBlocks(world, bounds, 0, 2, 0, 6, 6, 6, 0, 0, false); + // Set up the platform under the gateway + this.fillWithBlocks(world, bounds, 0, 0, 0, 6, 1, 6, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + + // Build the fence at the back of the room + this.fillWithBlocks(world, bounds, 1, 2, 6, 5, 2, 6, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.fillWithBlocks(world, bounds, 1, 3, 6, 5, 3, 6, Block.netherFence.blockID, Block.netherFence.blockID, false); + + // Build the fences at the sides of the room + this.fillWithBlocks(world, bounds, 0, 2, 0, 0, 2, 6, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.fillWithBlocks(world, bounds, 0, 3, 0, 0, 3, 6, Block.netherFence.blockID, Block.netherFence.blockID, false); + + this.fillWithBlocks(world, bounds, 6, 2, 0, 6, 2, 6, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.fillWithBlocks(world, bounds, 6, 3, 0, 6, 3, 6, Block.netherFence.blockID, Block.netherFence.blockID, false); + + // Build the fence portions closest to the entrance + this.placeBlockAtCurrentPosition(world, Block.netherBrick.blockID, 0, 1, 2, 0, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 1, 3, 0, bounds); + + this.placeBlockAtCurrentPosition(world, Block.netherBrick.blockID, 0, 5, 2, 0, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 5, 3, 0, bounds); + + // Build the first layer of the gateway + this.fillWithBlocks(world, bounds, 1, 2, 2, 5, 2, 5, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.fillWithMetadataBlocks(world, bounds, 1, 2, 1, 5, 2, 1, Block.stoneSingleSlab.blockID, NETHER_SLAB_METADATA, Block.stoneSingleSlab.blockID, NETHER_SLAB_METADATA, false); + + this.placeBlockAtCurrentPosition(world, Block.stoneSingleSlab.blockID, NETHER_SLAB_METADATA, 1, 2, 2, bounds); + this.placeBlockAtCurrentPosition(world, Block.stoneSingleSlab.blockID, NETHER_SLAB_METADATA, 5, 2, 2, bounds); + + // Build the second layer of the gateway + int orientation = this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 2); + this.fillWithBlocks(world, bounds, 2, 3, 3, 2, 3, 4, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.fillWithBlocks(world, bounds, 4, 3, 3, 4, 3, 4, Block.netherBrick.blockID, Block.netherBrick.blockID, false); + this.placeBlockAtCurrentPosition(world, Block.netherBrick.blockID, 0, 3, 3, 4, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, orientation, 3, 3, 5, bounds); + + // Build the third layer of the gateway + // We add 4 to get the rotated metadata for upside-down stairs + // because Minecraft only supports metadata rotations for normal stairs -_- + this.fillWithMetadataBlocks(world, bounds, 2, 4, 4, 4, 4, 4, Block.stairsNetherBrick.blockID, orientation, Block.stairsNetherBrick.blockID, orientation, false); + + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 0) + 4, 2, 4, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 1) + 4, 4, 4, 3, bounds); + + // Build the fourth layer of the gateway + this.placeBlockAtCurrentPosition(world, Block.netherBrick.blockID, 0, 3, 5, 3, bounds); + + this.placeBlockAtCurrentPosition(world, Block.netherrack.blockID, 0, 2, 5, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 0) + 4, 1, 5, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 3) + 4, 2, 5, 2, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 2) + 4, 2, 5, 4, bounds); + + this.placeBlockAtCurrentPosition(world, Block.netherrack.blockID, 0, 4, 5, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 1) + 4, 5, 5, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 3) + 4, 4, 5, 2, bounds); + this.placeBlockAtCurrentPosition(world, Block.stairsNetherBrick.blockID, this.getMetadataWithOffset(Block.stairsNetherBrick.blockID, 2) + 4, 4, 5, 4, bounds); + + // Build the top layer of the gateway + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 3, 6, 3, bounds); + + this.placeBlockAtCurrentPosition(world, Block.fire.blockID, 0, 2, 6, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 1, 6, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 2, 6, 2, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 2, 6, 4, bounds); + + this.placeBlockAtCurrentPosition(world, Block.fire.blockID, 0, 4, 6, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 5, 6, 3, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 4, 6, 2, bounds); + this.placeBlockAtCurrentPosition(world, Block.netherFence.blockID, 0, 4, 6, 4, bounds); + + // Place the transient door + int y = this.getYWithOffset(3); + int x = this.getXWithOffset(3, 3); + int z = this.getZWithOffset(3, 3); + DimLink link; + NewDimData dimension; + + // This function might run multiple times for a single component + // due to the way Minecraft handles structure generation! + if (bounds.isVecInside(x, y, z) && bounds.isVecInside(x, y + 1, z)) + { + orientation = this.getMetadataWithOffset(Block.doorWood.blockID, 1); + dimension = PocketManager.getDimensionData(world); + link = dimension.getLink(x, y + 1, z); + if (link == null) + { + link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); + } + BaseItemDoor.placeDoorBlock(world, x, y, z, orientation, mod_pocketDim.transientDoor); + } + + for (x = 0; x <= 6; ++x) + { + for (z = 0; z <= 6; ++z) + { + this.fillCurrentPositionBlocksDownwards(world, Block.netherBrick.blockID, 0, x, -1, z, bounds); + } + } + + return true; + } + + @Override + protected void func_143012_a(NBTTagCompound tag) { } + + @Override + protected void func_143011_b(NBTTagCompound tag) { } +} diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDNetherFortressGenerator.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDNetherFortressGenerator.java new file mode 100644 index 0000000..4c2ca7b --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDNetherFortressGenerator.java @@ -0,0 +1,24 @@ +package StevenDimDoors.mod_pocketDim.world.fortresses; + +import net.minecraft.world.gen.structure.MapGenNetherBridge; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraft.world.gen.structure.StructureStart; + +public class DDNetherFortressGenerator extends MapGenNetherBridge +{ + public DDNetherFortressGenerator() + { + super(); + + // Register our custom StructureStart class with MapGenStructureIO + // If we don't do this, Minecraft will crash when a fortress tries to generate. + // Moreover, use Fortress as our structure identifier so that if DD is removed, + // fortresses will generate properly using Vanilla code. + MapGenStructureIO.func_143034_b(DDStructureNetherBridgeStart.class, "Fortress"); + } + + protected StructureStart getStructureStart(int chunkX, int chunkZ) + { + return new DDStructureNetherBridgeStart(this.worldObj, this.rand, chunkX, chunkZ); + } +} diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDStructureNetherBridgeStart.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDStructureNetherBridgeStart.java new file mode 100644 index 0000000..abf23db --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/fortresses/DDStructureNetherBridgeStart.java @@ -0,0 +1,145 @@ +package StevenDimDoors.mod_pocketDim.world.fortresses; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Random; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.ComponentNetherBridgeCrossing; +import net.minecraft.world.gen.structure.ComponentNetherBridgeThrone; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureNetherBridgeStart; + +public class DDStructureNetherBridgeStart extends StructureNetherBridgeStart +{ + private static int GATEWAY_GENERATION_CHANCE = 1; + private static int MAX_GATEWAY_GENERATION_CHANCE = 3; + + private boolean hasGateway; + private int minX; + private int minY; + private int minZ; + + public DDStructureNetherBridgeStart() { } + + public DDStructureNetherBridgeStart(World world, Random random, int chunkX, int chunkZ) + { + // StructureNetherBridgeStart handles designing the fortress for us + super(world, random, chunkX, chunkZ); + + Iterator componentIterator; + StructureComponent component; + StructureBoundingBox bounds; + ArrayList spawnerRooms; + hasGateway = false; + + // Randomly decide whether to build a gateway in this fortress + if (random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < GATEWAY_GENERATION_CHANCE) + { + // Search for all the blaze spawners in a fortress + spawnerRooms = new ArrayList(); + componentIterator = this.components.iterator(); + while (componentIterator.hasNext()) + { + component = (StructureComponent) componentIterator.next(); + if (component instanceof ComponentNetherBridgeThrone) + { + spawnerRooms.add((ComponentNetherBridgeThrone) component); + } + } + + // If any spawner rooms were found, choose one to randomly replace + if (!spawnerRooms.isEmpty()) + { + hasGateway = true; + component = spawnerRooms.get(random.nextInt(spawnerRooms.size())); + // Store enough data to identify the room when it's going to be built later + bounds = component.getBoundingBox(); + minX = bounds.minX; + minY = bounds.minY; + minZ = bounds.minZ; + } + } + } + + @Override + public NBTTagCompound func_143021_a(int chunkX, int chunkZ) + { + // We override the function for writing NBT data to add our own gateway data + NBTTagCompound fortressTag = super.func_143021_a(chunkX, chunkZ); + + // Add a compound tag with our data + NBTTagCompound dimensionalTag = new NBTTagCompound(); + dimensionalTag.setBoolean("HasGateway", this.hasGateway); + if (hasGateway) + { + dimensionalTag.setInteger("GatewayMinX", this.minX); + dimensionalTag.setInteger("GatewayMinY", this.minY); + dimensionalTag.setInteger("GatewayMinZ", this.minZ); + } + fortressTag.setCompoundTag("DimensionalDoors", dimensionalTag); + + return fortressTag; + } + + @Override + public void func_143020_a(World world, NBTTagCompound fortressTag) + { + // We override the function for reading NBT data to load gateway data + super.func_143020_a(world, fortressTag); + + NBTTagCompound dimensionalTag = fortressTag.getCompoundTag("DimensionalDoors"); + if (dimensionalTag != null) + { + this.hasGateway = dimensionalTag.getBoolean("HasGateway"); + if (hasGateway) + { + minX = dimensionalTag.getInteger("GatewayMinX"); + minY = dimensionalTag.getInteger("GatewayMinY"); + minZ = dimensionalTag.getInteger("GatewayMinZ"); + } + } + } + + /** + * Keeps iterating Structure Pieces and spawning them until the checks tell it to stop + */ + public void generateStructure(World world, Random random, StructureBoundingBox generationBounds) + { + if (hasGateway) + { + // Use a modified version of Vanilla's fortress generation code + // Try to detect the room that we intend to replace with our gateway + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent component = (StructureComponent)iterator.next(); + StructureBoundingBox bounds = component.getBoundingBox(); + + if (bounds.intersectsWith(generationBounds)) + { + // Check if this is our replacement target + // Checking the location is enough because structures aren't allowed to have + // intersecting bounding boxes - nothing else can have these min coordinates. + if (bounds.minX == this.minX && bounds.minY == this.minY && bounds.minZ == this.minZ) + { + component = ComponentNetherGateway.createFromComponent(component, random); + } + // Now for the last bit of Vanilla's generation code + if (!component.addComponentParts(world, random, generationBounds)) + { + iterator.remove(); + } + } + } + } + else + { + // Just run the usual structure generation + super.generateStructure(world, random, generationBounds); + } + } +} -- 2.39.5