diff --git a/src/main/java/com/hbm/items/tool/ItemWandD.java b/src/main/java/com/hbm/items/tool/ItemWandD.java index fa0fe9bcc..35f8c6537 100644 --- a/src/main/java/com/hbm/items/tool/ItemWandD.java +++ b/src/main/java/com/hbm/items/tool/ItemWandD.java @@ -6,7 +6,7 @@ import com.hbm.handler.pollution.PollutionHandler; import com.hbm.handler.pollution.PollutionHandler.PollutionType; import com.hbm.lib.Library; import com.hbm.world.gen.MapGenNTMFeatures; -import com.hbm.world.gen.component.BrutalistFeatures.ElevatedLab1; +import com.hbm.world.gen.component.BrutalistFeatures.ElevatedPrefab1; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; diff --git a/src/main/java/com/hbm/lib/HbmWorld.java b/src/main/java/com/hbm/lib/HbmWorld.java index dc8739707..ceb91a336 100644 --- a/src/main/java/com/hbm/lib/HbmWorld.java +++ b/src/main/java/com/hbm/lib/HbmWorld.java @@ -8,6 +8,7 @@ import com.hbm.world.gen.component.BunkerComponents; import com.hbm.world.gen.component.CivilianFeatures; import com.hbm.world.gen.component.OfficeFeatures; import com.hbm.world.gen.component.RuinFeatures; +import com.hbm.world.gen.component.SpecialFeatures; import com.hbm.world.gen.component.BunkerComponents.BunkerStart; import cpw.mods.fml.common.IWorldGenerator; @@ -49,5 +50,6 @@ public class HbmWorld { RuinFeatures.registerComponents(); BunkerComponents.registerComponents(); BrutalistFeatures.registerComponents(); + SpecialFeatures.registerComponents(); } } diff --git a/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java b/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java index 16d5ecd6d..5111a406f 100644 --- a/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java +++ b/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java @@ -5,7 +5,7 @@ import java.util.Random; import java.util.Set; import com.hbm.config.GeneralConfig; -import com.hbm.world.gen.component.BrutalistFeatures.ElevatedLab1; +import com.hbm.world.gen.component.SpecialFeatures.SpecialContainer; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; @@ -45,6 +45,9 @@ public class MapGenSpecialFeatures extends MapGenStructure { ChunkCoordIntPair pair = new ChunkCoordIntPair(cX, cZ); locs.add(pair); + if(GeneralConfig.enableDebugMode) + System.out.println("SpecialFeature: " + (pair.chunkXPos * 16 + 8) + ", Y, " + (pair.chunkZPos * 16 + 8)); + theta += Math.PI * 2 / ringMax; if(i == (ringDist - 1) * 4 + ringMax) { @@ -74,8 +77,8 @@ public class MapGenSpecialFeatures extends MapGenStructure { super(chunkX, chunkZ); //test - ElevatedLab1 lab1 = new ElevatedLab1(rand, chunkX * 16 + 8, 64, chunkZ * 16 + 8); - this.components.add(lab1); + SpecialContainer shipping = new SpecialContainer(rand, chunkX * 16 + 8, 64, chunkZ * 16 + 8); + this.components.add(shipping); if(GeneralConfig.enableDebugMode) { System.out.print("[Debug] StructureStart at " + (chunkX * 16 + 8) + ", " + 64 + ", " + (chunkZ * 16 + 8) + "\n[Debug] Components: "); diff --git a/src/main/java/com/hbm/world/gen/component/BrutalistFeatures.java b/src/main/java/com/hbm/world/gen/component/BrutalistFeatures.java index 13d1c1c4e..9ba8696a7 100644 --- a/src/main/java/com/hbm/world/gen/component/BrutalistFeatures.java +++ b/src/main/java/com/hbm/world/gen/component/BrutalistFeatures.java @@ -23,17 +23,17 @@ import net.minecraftforge.common.BiomeDictionary.Type; public class BrutalistFeatures { public static void registerComponents() { - MapGenStructureIO.func_143031_a(ElevatedLab1.class, "NTMElevatedLab1"); + MapGenStructureIO.func_143031_a(ElevatedPrefab1.class, "NTMElevatedPrefab1"); } //might be other than a lab, placeholder :P - public static class ElevatedLab1 extends Component { + public static class ElevatedPrefab1 extends Component { protected int type; - public ElevatedLab1() { super(); } + public ElevatedPrefab1() { super(); } - public ElevatedLab1(Random rand, int minX, int minY, int minZ) { + public ElevatedPrefab1(Random rand, int minX, int minY, int minZ) { super(rand, minX, minY, minZ, 16, 11, 14); this.type = rand.nextInt(2); diff --git a/src/main/java/com/hbm/world/gen/component/SpecialFeatures.java b/src/main/java/com/hbm/world/gen/component/SpecialFeatures.java new file mode 100644 index 000000000..7664f2b6e --- /dev/null +++ b/src/main/java/com/hbm/world/gen/component/SpecialFeatures.java @@ -0,0 +1,89 @@ +package com.hbm.world.gen.component; + +import java.util.Random; + +import com.hbm.blocks.ModBlocks; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraft.world.gen.structure.StructureBoundingBox; + +public class SpecialFeatures { + + public static void registerComponents() { + MapGenStructureIO.func_143031_a(SpecialContainer.class, "NTMSpecialContainer"); + } + + public static class SpecialContainer extends Component { + + public SpecialContainer() { + + } + + public SpecialContainer(Random rand, int minX, int minY, int minZ) { + super(rand, minX, minY, minZ, 3, 3, 9); + + } + + @Override + public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) { + + if(hpos == -1 && !this.setAverageHeight(world, box, this.boundingBox.minY)) { + return false; + } + + fillWithAir(world, box, 1, 1, 1, 2, 2, 8); + + //floor + fillWithBlocks(world, box, 0, 0, 0, 3, 0, 1, ModBlocks.deco_steel); + fillWithBlocks(world, box, 1, 0, 2, 2, 0, 7, ModBlocks.deco_steel); + fillWithBlocks(world, box, 0, 0, 8, 3, 0, 9, ModBlocks.deco_steel); + fillWithBlocks(world, box, 1, 0, 1, 2, 0, 1, ModBlocks.cm_block); + fillWithBlocks(world, box, 1, 0, 8, 2, 0, 8, ModBlocks.cm_block); + //roof + fillWithBlocks(world, box, 0, 3, 0, 3, 3, 9, ModBlocks.deco_steel); + placeBlockAtCurrentPosition(world, ModBlocks.cm_block, 0, 0, 3, 2, box); + placeBlockAtCurrentPosition(world, ModBlocks.cm_block, 0, 3, 3, 2, box); + placeBlockAtCurrentPosition(world, ModBlocks.cm_block, 0, 0, 3, 7, box); + placeBlockAtCurrentPosition(world, ModBlocks.cm_block, 0, 3, 3, 7, box); + //walls + fillWithBlocks(world, box, 0, 1, 0, 0, 2, 0, ModBlocks.deco_steel); + fillWithBlocks(world, box, 0, 1, 1, 0, 2, 8, ModBlocks.cm_sheet); + fillWithBlocks(world, box, 0, 1, 9, 0, 2, 9, ModBlocks.deco_steel); + fillWithBlocks(world, box, 1, 1, 9, 2, 2, 9, ModBlocks.cm_sheet); + fillWithBlocks(world, box, 3, 1, 9, 3, 2, 9, ModBlocks.deco_steel); + fillWithBlocks(world, box, 3, 1, 1, 3, 2, 8, ModBlocks.cm_sheet); + fillWithBlocks(world, box, 3, 1, 0, 3, 2, 0, ModBlocks.deco_steel); + //doors + placeDoor(world, box, ModBlocks.door_metal, 1, false, false, 2, 1, 0); + placeDoor(world, box, ModBlocks.door_metal, 1, true, false, 1, 1, 0); + + return true; + } + + @Override + protected boolean setAverageHeight(World world, StructureBoundingBox box, int y) { + + int total = 0; + int iterations = 0; + + for(int z = this.boundingBox.minZ; z <= this.boundingBox.maxZ; z++) { + for(int x = this.boundingBox.minX; x <= this.boundingBox.maxX; x++) { + if(box.isVecInside(x, y, z)) { + total += Math.max(world.getTopSolidOrLiquidBlock(x, z), 1); // underwater :3c + iterations++; + } + } + } + + if(iterations == 0) + return false; + + this.hpos = total / iterations; //finds mean of every block in bounding box + this.boundingBox.offset(0, this.hpos - this.boundingBox.minY, 0); + return true; + } + } +}