diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/australia/gen/map')
7 files changed, 1513 insertions, 1418 deletions
diff --git a/src/main/java/gtPlusPlus/australia/gen/map/MapGenExtendedVillage.java b/src/main/java/gtPlusPlus/australia/gen/map/MapGenExtendedVillage.java index 8fc6940242..72b303ff69 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/MapGenExtendedVillage.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/MapGenExtendedVillage.java @@ -1,17 +1,15 @@ package gtPlusPlus.australia.gen.map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.australia.GTplusplus_Australia; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Random; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.australia.GTplusplus_Australia; - import java.util.Map.Entry; +import java.util.Random; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -22,60 +20,57 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureStart; import net.minecraft.world.gen.structure.StructureVillagePieces; -public class MapGenExtendedVillage extends MapGenStructure -{ +public class MapGenExtendedVillage extends MapGenStructure { /** A list of all the biomes villages can spawn in. */ - public static List<BiomeGenBase> villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] {GTplusplus_Australia.Australian_Desert_Biome_3, GTplusplus_Australia.Australian_Plains_Biome, GTplusplus_Australia.Australian_Forest_Biome, GTplusplus_Australia.Australian_Outback_Biome}); + public static List<BiomeGenBase> villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] { + GTplusplus_Australia.Australian_Desert_Biome_3, + GTplusplus_Australia.Australian_Plains_Biome, + GTplusplus_Australia.Australian_Forest_Biome, + GTplusplus_Australia.Australian_Outback_Biome + }); /** World terrain type, 0 for normal, 1 for flat map */ private int terrainType; + private int field_82665_g; private int field_82666_h; - public MapGenExtendedVillage(){ + public MapGenExtendedVillage() { this.field_82665_g = 8; this.field_82666_h = 4; } - public MapGenExtendedVillage(Map<?, ?> p_i2093_1_){ + public MapGenExtendedVillage(Map<?, ?> p_i2093_1_) { this(); Iterator<?> iterator = p_i2093_1_.entrySet().iterator(); Logger.INFO("Created Extended Village Object."); - - while (iterator.hasNext()) - { - Entry<?, ?> entry = (Entry<?, ?>)iterator.next(); - - if (((String)entry.getKey()).equals("size")) - { - this.terrainType = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.terrainType, 0); - } - else if (((String)entry.getKey()).equals("distance")) - { - this.field_82665_g = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82665_g, this.field_82666_h + 1); + + while (iterator.hasNext()) { + Entry<?, ?> entry = (Entry<?, ?>) iterator.next(); + + if (((String) entry.getKey()).equals("size")) { + this.terrainType = MathHelper.parseIntWithDefaultAndMax((String) entry.getValue(), this.terrainType, 0); + } else if (((String) entry.getKey()).equals("distance")) { + this.field_82665_g = MathHelper.parseIntWithDefaultAndMax( + (String) entry.getValue(), this.field_82665_g, this.field_82666_h + 1); } } } - public String func_143025_a() - { + public String func_143025_a() { return "ExtendedVillage"; } - protected boolean canSpawnStructureAtCoords(int p_75047_1_, int p_75047_2_) - { - - + protected boolean canSpawnStructureAtCoords(int p_75047_1_, int p_75047_2_) { + int k = p_75047_1_; int l = p_75047_2_; - if (p_75047_1_ < 0) - { + if (p_75047_1_ < 0) { p_75047_1_ -= this.field_82665_g - 1; } - if (p_75047_2_ < 0) - { + if (p_75047_2_ < 0) { p_75047_2_ -= this.field_82665_g - 1; } @@ -87,13 +82,12 @@ public class MapGenExtendedVillage extends MapGenStructure i1 += random.nextInt(this.field_82665_g - this.field_82666_h); j1 += random.nextInt(this.field_82665_g - this.field_82666_h); - if (k == i1 && l == j1) - { - boolean flag = this.worldObj.getWorldChunkManager().areBiomesViable(k * 16 + 8, l * 16 + 8, 0, villageSpawnBiomes); + if (k == i1 && l == j1) { + boolean flag = + this.worldObj.getWorldChunkManager().areBiomesViable(k * 16 + 8, l * 16 + 8, 0, villageSpawnBiomes); - if (flag) - { - Logger.INFO("Found viable biome(s) for custom village"); + if (flag) { + Logger.INFO("Found viable biome(s) for custom village"); return true; } } @@ -101,122 +95,118 @@ public class MapGenExtendedVillage extends MapGenStructure return false; } - protected StructureStart getStructureStart(int p_75049_1_, int p_75049_2_) - { + protected StructureStart getStructureStart(int p_75049_1_, int p_75049_2_) { return new MapGenExtendedVillage.Start(this.worldObj, this.rand, p_75049_1_, p_75049_2_, this.terrainType); } - public static class Start extends StructureStart - { - /** well ... thats what it does */ - private boolean hasMoreThanTwoComponents; + public static class Start extends StructureStart { + /** well ... thats what it does */ + private boolean hasMoreThanTwoComponents; - public Start() { - } + public Start() {} - public Start(World p_i2092_1_, Random p_i2092_2_, int p_i2092_3_, int p_i2092_4_, int p_i2092_5_) - { - super(p_i2092_3_, p_i2092_4_); - Logger.INFO("Trying to Start Village Builder."); - List<?> list = StructureVillagePieces.getStructureVillageWeightedPieceList(p_i2092_2_, p_i2092_5_); - StructureVillagePieces.Start start = new StructureVillagePieces.Start(p_i2092_1_.getWorldChunkManager(), 0, p_i2092_2_, (p_i2092_3_ << 4) + 2, (p_i2092_4_ << 4) + 2, list, p_i2092_5_); - this.components.add(start); - start.buildComponent(start, this.components, p_i2092_2_); - List<?> list1 = start.field_74930_j; - List<?> list2 = start.field_74932_i; - int l; - Logger.INFO("List1: "+list1.size()+" | List2: "+list2.size()); - - while (!list1.isEmpty() || !list2.isEmpty()) - { - Logger.INFO("Iterating non empty list."); - StructureComponent structurecomponent; - - if (list1.isEmpty()) - { - l = p_i2092_2_.nextInt(list2.size()); - structurecomponent = (StructureComponent)list2.remove(l); - structurecomponent.buildComponent(start, this.components, p_i2092_2_); - } - else - { - l = p_i2092_2_.nextInt(list1.size()); - structurecomponent = (StructureComponent)list1.remove(l); - structurecomponent.buildComponent(start, this.components, p_i2092_2_); - } + public Start(World p_i2092_1_, Random p_i2092_2_, int p_i2092_3_, int p_i2092_4_, int p_i2092_5_) { + super(p_i2092_3_, p_i2092_4_); + Logger.INFO("Trying to Start Village Builder."); + List<?> list = StructureVillagePieces.getStructureVillageWeightedPieceList(p_i2092_2_, p_i2092_5_); + StructureVillagePieces.Start start = new StructureVillagePieces.Start( + p_i2092_1_.getWorldChunkManager(), + 0, + p_i2092_2_, + (p_i2092_3_ << 4) + 2, + (p_i2092_4_ << 4) + 2, + list, + p_i2092_5_); + this.components.add(start); + start.buildComponent(start, this.components, p_i2092_2_); + List<?> list1 = start.field_74930_j; + List<?> list2 = start.field_74932_i; + int l; + Logger.INFO("List1: " + list1.size() + " | List2: " + list2.size()); + + while (!list1.isEmpty() || !list2.isEmpty()) { + Logger.INFO("Iterating non empty list."); + StructureComponent structurecomponent; + + if (list1.isEmpty()) { + l = p_i2092_2_.nextInt(list2.size()); + structurecomponent = (StructureComponent) list2.remove(l); + structurecomponent.buildComponent(start, this.components, p_i2092_2_); + } else { + l = p_i2092_2_.nextInt(list1.size()); + structurecomponent = (StructureComponent) list1.remove(l); + structurecomponent.buildComponent(start, this.components, p_i2092_2_); } - Logger.INFO("Finished iterating lists, updating bounding box for structure."); + } + Logger.INFO("Finished iterating lists, updating bounding box for structure."); - this.updateBoundingBox(); - l = 0; - Iterator iterator = this.components.iterator(); + this.updateBoundingBox(); + l = 0; + Iterator iterator = this.components.iterator(); - while (iterator.hasNext()) - { - Logger.INFO("Iterating Components."); - StructureComponent structurecomponent1 = (StructureComponent)iterator.next(); + while (iterator.hasNext()) { + Logger.INFO("Iterating Components."); + StructureComponent structurecomponent1 = (StructureComponent) iterator.next(); - if (!(structurecomponent1 instanceof StructureVillagePieces.Road)) - { - ++l; - } + if (!(structurecomponent1 instanceof StructureVillagePieces.Road)) { + ++l; } - - Logger.INFO("hasMoreThanTwoComponents? "+(l > 2)); - this.hasMoreThanTwoComponents = l > 2; } - /** - * currently only defined for Villages, returns true if Village has more than 2 non-road components - */ - public boolean isSizeableStructure() - { - //return this.hasMoreThanTwoComponents; - return true; - } + Logger.INFO("hasMoreThanTwoComponents? " + (l > 2)); + this.hasMoreThanTwoComponents = l > 2; + } - public void func_143022_a(NBTTagCompound p_143022_1_) - { - super.func_143022_a(p_143022_1_); - p_143022_1_.setBoolean("Valid", this.hasMoreThanTwoComponents); - } + /** + * currently only defined for Villages, returns true if Village has more than 2 non-road components + */ + public boolean isSizeableStructure() { + // return this.hasMoreThanTwoComponents; + return true; + } - public void func_143017_b(NBTTagCompound p_143017_1_) - { - super.func_143017_b(p_143017_1_); - this.hasMoreThanTwoComponents = p_143017_1_.getBoolean("Valid"); - } + public void func_143022_a(NBTTagCompound p_143022_1_) { + super.func_143022_a(p_143022_1_); + p_143022_1_.setBoolean("Valid", this.hasMoreThanTwoComponents); + } + + public void func_143017_b(NBTTagCompound p_143017_1_) { + super.func_143017_b(p_143017_1_); + this.hasMoreThanTwoComponents = p_143017_1_.getBoolean("Valid"); } - + } + /** * Generates structures in specified chunk next to existing structures. Does *not* generate StructureStarts. */ @Override - public boolean generateStructuresInChunk(World p_75051_1_, Random p_75051_2_, int p_75051_3_, int p_75051_4_){ - //Logger.INFO("Try generate Structs in chunk."); + public boolean generateStructuresInChunk(World p_75051_1_, Random p_75051_2_, int p_75051_3_, int p_75051_4_) { + // Logger.INFO("Try generate Structs in chunk."); this.callPrivateFunction1(p_75051_1_); int k = (p_75051_3_ << 4) + 8; int l = (p_75051_4_ << 4) + 8; boolean flag = false; Iterator iterator = this.structureMap.values().iterator(); - - //Logger.INFO("Iteration Size: "+this.structureMap.values().size()); - while (iterator.hasNext()) - { - //Logger.INFO("Iterating."); - StructureStart structurestart = (StructureStart)iterator.next(); - - if (structurestart.isSizeableStructure() && (structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15) || structurestart.getBoundingBox().intersectsWith(k, l, k - 15, l - 15))) - { - Logger.INFO("Iterating. 2"); - structurestart.generateStructure(p_75051_1_, p_75051_2_, new StructureBoundingBox(k, l, k + 15, l + 15)); + + // Logger.INFO("Iteration Size: "+this.structureMap.values().size()); + while (iterator.hasNext()) { + // Logger.INFO("Iterating."); + StructureStart structurestart = (StructureStart) iterator.next(); + + if (structurestart.isSizeableStructure() + && (structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15) + || structurestart.getBoundingBox().intersectsWith(k, l, k - 15, l - 15))) { + Logger.INFO("Iterating. 2"); + structurestart.generateStructure( + p_75051_1_, p_75051_2_, new StructureBoundingBox(k, l, k + 15, l + 15)); flag = true; - this.callPrivateFunction2(structurestart.func_143019_e(), structurestart.func_143018_f(), structurestart); + this.callPrivateFunction2( + structurestart.func_143019_e(), structurestart.func_143018_f(), structurestart); } - /* else { + /* else { Logger.INFO("Iterating. 3"); Logger.INFO("structurestart.isSizeableStructure()? "+structurestart.isSizeableStructure()); - Logger.INFO("structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15)? "+(structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15) || structurestart.getBoundingBox().intersectsWith(k, l, k - 15, l - 15))); + Logger.INFO("structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15)? "+(structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15) || structurestart.getBoundingBox().intersectsWith(k, l, k - 15, l - 15))); Logger.INFO("K: "+k+" | L: "+l); Logger.INFO("structure bounding box info: x-:"+structurestart.getBoundingBox().minX+" y-:"+structurestart.getBoundingBox().minY+" x+:"+structurestart.getBoundingBox().maxX+" y+:"+structurestart.getBoundingBox().maxY); }*/ @@ -224,42 +214,46 @@ public class MapGenExtendedVillage extends MapGenStructure return flag; } - + Method mMethod1; Method mMethod2; + private boolean callPrivateFunction1(World aWorld) { - if (mMethod1 == null) { - try { - mMethod1 = MapGenStructure.class.getDeclaredMethod("func_143027_a", World.class); - } catch (NoSuchMethodException | SecurityException e) { - return false; - } - } - if (mMethod1 != null) { - try { - //Logger.INFO("Invoking func_143027_a"); - mMethod1.invoke(this, aWorld); - return true; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } - return false; + if (mMethod1 == null) { + try { + mMethod1 = MapGenStructure.class.getDeclaredMethod("func_143027_a", World.class); + } catch (NoSuchMethodException | SecurityException e) { + return false; + } + } + if (mMethod1 != null) { + try { + // Logger.INFO("Invoking func_143027_a"); + mMethod1.invoke(this, aWorld); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + return false; } - + private boolean callPrivateFunction2(int aInt1, int aInt2, StructureStart aStruct) { - if (mMethod2 == null) { - try { - mMethod2 = MapGenStructure.class.getDeclaredMethod("func_143026_a", int.class, int.class, StructureStart.class); - } catch (NoSuchMethodException | SecurityException e) { - return false; - } - } - if (mMethod2 != null) { - try { - Logger.INFO("Invoking func_143026_a"); - mMethod2.invoke(this, aInt1, aInt2, aStruct); - return true; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } - return false; + if (mMethod2 == null) { + try { + mMethod2 = MapGenStructure.class.getDeclaredMethod( + "func_143026_a", int.class, int.class, StructureStart.class); + } catch (NoSuchMethodException | SecurityException e) { + return false; + } + } + if (mMethod2 != null) { + try { + Logger.INFO("Invoking func_143026_a"); + mMethod2.invoke(this, aInt1, aInt2, aStruct); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + return false; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java b/src/main/java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java index 0eab94c5d1..78c7e3b4c1 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java @@ -1,217 +1,233 @@ package gtPlusPlus.australia.gen.map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Random; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.MapGenRavine; public class MapGenLargeRavine extends MapGenRavine { - private float[] field_75046_d = new float[1024]; - - @Override - protected void func_151540_a(long aSeed, int var1, int var2, Block[] aBlocksInChunkOrPassedIn, double p_151540_6_, - double p_151540_8_, double p_151540_10_, float p_151540_12_, float p_151540_13_, float p_151540_14_, - int possibleCurrentY, int possibleMaxY, double p_151540_17_) { - Random random = CORE.RANDOM; - //gtPlusPlus.api.objects.Logger.WORLD("Generating Large Ravine. 1"); - this.range *= 2; - double d4 = (double) (var1 * 24 + 16); - double d5 = (double) (var2 * 24 + 16); - float f3 = 0.0F; - float f4 = 0.0F; - - if (possibleMaxY <= 25) { - int j1 = Math.min(this.range * 16 - 32, 200); - possibleMaxY = j1 - random.nextInt(j1 / 4); - } - - boolean possibleIsUnderGroundFlag = false; - - if (possibleCurrentY <= -1) { - possibleCurrentY = possibleMaxY / 3; - possibleIsUnderGroundFlag = true; - } - - float f5 = 1.0F; - - for (int k1 = 0; k1 < 256; ++k1) { - if (k1 == 0 || random.nextInt(3) == 0) { - f5 = 1.0F + random.nextFloat() * random.nextFloat() * 1.0F; - } - - this.field_75046_d[k1] = f5 * f5; - } - - for (; possibleCurrentY < possibleMaxY; ++possibleCurrentY) { - double d12 = 3.5D + (double) (MathHelper.sin((float) possibleCurrentY * CORE.PI / (float) possibleMaxY) - * p_151540_12_ * 1.0F); - double d6 = d12 * p_151540_17_; - d12 *= (double) random.nextFloat() * 0.55D + 0.75D; - d6 *= (double) random.nextFloat() * 0.55D + 0.75D; - float f6 = MathHelper.cos(p_151540_14_); - float f7 = MathHelper.sin(p_151540_14_); - p_151540_6_ += (double) (MathHelper.cos(p_151540_13_) * f6); - p_151540_8_ += (double) f7; - p_151540_10_ += (double) (MathHelper.sin(p_151540_13_) * f6); - p_151540_14_ *= 1.7F; - p_151540_14_ += f4 * 0.25F; - p_151540_13_ += f3 * 0.25F; - f4 *= 0.8F; - f3 *= 0.5F; - f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; - f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; - - if (possibleIsUnderGroundFlag || random.nextInt(4) != 0) { - double d7 = p_151540_6_ - d4; - double d8 = p_151540_10_ - d5; - double d9 = (double) (possibleMaxY - possibleCurrentY); - double d10 = (double) (p_151540_12_ + 2.0F + 16.0F); - - if (d7 * d7 + d8 * d8 - d9 * d9 > d10 * d10) { - return; - } - - if (p_151540_6_ >= d4 - 16.0D - d12 * 2.0D && p_151540_10_ >= d5 - 16.0D - d12 * 2.0D - && p_151540_6_ <= d4 + 16.0D + d12 * 2.0D && p_151540_10_ <= d5 + 16.0D + d12 * 2.0D) { - int i4 = MathHelper.floor_double(p_151540_6_ - d12) - var1 * 16 - 1; - int l1 = MathHelper.floor_double(p_151540_6_ + d12) - var1 * 16 + 1; - int j4 = MathHelper.floor_double(p_151540_8_ - d6) - 1; - int i2 = MathHelper.floor_double(p_151540_8_ + d6) + 1; - int k4 = MathHelper.floor_double(p_151540_10_ - d12) - var2 * 16 - 1; - int j2 = MathHelper.floor_double(p_151540_10_ + d12) - var2 * 16 + 1; - - if (i4 < 0) { - i4 = 0; - } - - if (l1 > 16) { - l1 = 16; - } - - if (j4 < 1) { - j4 = 1; - } - - if (i2 > 248) { - i2 = 248; - } - - if (k4 < 0) { - k4 = 0; - } - - if (j2 > 16) { - j2 = 16; - } - - boolean flag2 = false; - int k2; - int j3; - - for (k2 = i4; !flag2 && k2 < l1; ++k2) { - for (int l2 = k4; !flag2 && l2 < j2; ++l2) { - for (int i3 = i2 + 1; !flag2 && i3 >= j4 - 1; --i3) { - j3 = (k2 * 16 + l2) * 256 + i3; - - if (i3 >= 0 && i3 < 256) { - Block block = aBlocksInChunkOrPassedIn[j3]; - - if (isOceanBlock(aBlocksInChunkOrPassedIn, j3, k2, i3, l2, var1, var2)) { - flag2 = true; - } - - if (i3 != j4 - 1 && k2 != i4 && k2 != l1 - 1 && l2 != k4 && l2 != j2 - 1) { - i3 = j4; - } - } - } - } - } - - if (!flag2) { - for (k2 = i4; k2 < l1; ++k2) { - double d13 = ((double) (k2 + var1 * 16) + 0.5D - p_151540_6_) / d12; - - for (j3 = k4; j3 < j2; ++j3) { - double d14 = ((double) (j3 + var2 * 16) + 0.5D - p_151540_10_) / d12; - int k3 = (k2 * 16 + j3) * 256 + i2; - boolean flag = false; - - if (d13 * d13 + d14 * d14 < 1.0D) { - for (int l3 = i2 - 1; l3 >= j4; --l3) { - double d11 = ((double) l3 + 0.5D - p_151540_8_) / d6; - - if ((d13 * d13 + d14 * d14) * (double) this.field_75046_d[l3] - + d11 * d11 / 6.0D < 1.0D) { - Block block1 = aBlocksInChunkOrPassedIn[k3]; - - if (checkIfTopBlock(aBlocksInChunkOrPassedIn, k3, k2, l3, j3, var1, var2)) { - flag = true; - } - - Logger.WORLD("Generating Large Ravine. 2"); - digBlock(aBlocksInChunkOrPassedIn, k3, k2, l3, j3, var1, var2, flag); - } - - --k3; - } - } - } - } - - if (possibleIsUnderGroundFlag) { - break; - } - } - } - } - } - } - - // generate? - @Override - protected void func_151538_a(World p_151538_1_, int p_151538_2_, int p_151538_3_, int chunkX, int chunkZ, - Block[] blocks) { - if (this.rand.nextInt(50) == 0) { - double d0 = (double) (p_151538_2_ * 16 + this.rand.nextInt(16)); - double d1 = (double) (this.rand.nextInt(this.rand.nextInt(40) + 8) + 20); - double d2 = (double) (p_151538_3_ * 16 + this.rand.nextInt(16)); - byte b0 = 1; - - for (int i1 = 0; i1 < b0; ++i1) { - float f = this.rand.nextFloat() * (float) Math.PI * 2.0F; - float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; - float f2 = (this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F; - this.func_151540_a(this.rand.nextLong(), chunkX, chunkZ, blocks, d0, d1, d2, f2, f, f1, 0, 0, 3.0D); - } - } - } - - private static Method isTopBlock; - - // Determine if the block at the specified location is the top block for the - // biome, we take into account - private synchronized boolean checkIfTopBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) { - try { - if (isTopBlock == null) { - isTopBlock = MapGenRavine.class.getDeclaredMethod("isTopBlock", Block[].class, int.class, int.class, - int.class, int.class, int.class, int.class); - } - if (isTopBlock != null) { - return (boolean) isTopBlock.invoke(this, data, index, x, y, z, chunkX, chunkZ); - } else { - return false; - } - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException n) { - return false; - } - } - -}
\ No newline at end of file + private float[] field_75046_d = new float[1024]; + + @Override + protected void func_151540_a( + long aSeed, + int var1, + int var2, + Block[] aBlocksInChunkOrPassedIn, + double p_151540_6_, + double p_151540_8_, + double p_151540_10_, + float p_151540_12_, + float p_151540_13_, + float p_151540_14_, + int possibleCurrentY, + int possibleMaxY, + double p_151540_17_) { + Random random = CORE.RANDOM; + // gtPlusPlus.api.objects.Logger.WORLD("Generating Large Ravine. 1"); + this.range *= 2; + double d4 = (double) (var1 * 24 + 16); + double d5 = (double) (var2 * 24 + 16); + float f3 = 0.0F; + float f4 = 0.0F; + + if (possibleMaxY <= 25) { + int j1 = Math.min(this.range * 16 - 32, 200); + possibleMaxY = j1 - random.nextInt(j1 / 4); + } + + boolean possibleIsUnderGroundFlag = false; + + if (possibleCurrentY <= -1) { + possibleCurrentY = possibleMaxY / 3; + possibleIsUnderGroundFlag = true; + } + + float f5 = 1.0F; + + for (int k1 = 0; k1 < 256; ++k1) { + if (k1 == 0 || random.nextInt(3) == 0) { + f5 = 1.0F + random.nextFloat() * random.nextFloat() * 1.0F; + } + + this.field_75046_d[k1] = f5 * f5; + } + + for (; possibleCurrentY < possibleMaxY; ++possibleCurrentY) { + double d12 = 3.5D + + (double) (MathHelper.sin((float) possibleCurrentY * CORE.PI / (float) possibleMaxY) + * p_151540_12_ + * 1.0F); + double d6 = d12 * p_151540_17_; + d12 *= (double) random.nextFloat() * 0.55D + 0.75D; + d6 *= (double) random.nextFloat() * 0.55D + 0.75D; + float f6 = MathHelper.cos(p_151540_14_); + float f7 = MathHelper.sin(p_151540_14_); + p_151540_6_ += (double) (MathHelper.cos(p_151540_13_) * f6); + p_151540_8_ += (double) f7; + p_151540_10_ += (double) (MathHelper.sin(p_151540_13_) * f6); + p_151540_14_ *= 1.7F; + p_151540_14_ += f4 * 0.25F; + p_151540_13_ += f3 * 0.25F; + f4 *= 0.8F; + f3 *= 0.5F; + f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; + f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; + + if (possibleIsUnderGroundFlag || random.nextInt(4) != 0) { + double d7 = p_151540_6_ - d4; + double d8 = p_151540_10_ - d5; + double d9 = (double) (possibleMaxY - possibleCurrentY); + double d10 = (double) (p_151540_12_ + 2.0F + 16.0F); + + if (d7 * d7 + d8 * d8 - d9 * d9 > d10 * d10) { + return; + } + + if (p_151540_6_ >= d4 - 16.0D - d12 * 2.0D + && p_151540_10_ >= d5 - 16.0D - d12 * 2.0D + && p_151540_6_ <= d4 + 16.0D + d12 * 2.0D + && p_151540_10_ <= d5 + 16.0D + d12 * 2.0D) { + int i4 = MathHelper.floor_double(p_151540_6_ - d12) - var1 * 16 - 1; + int l1 = MathHelper.floor_double(p_151540_6_ + d12) - var1 * 16 + 1; + int j4 = MathHelper.floor_double(p_151540_8_ - d6) - 1; + int i2 = MathHelper.floor_double(p_151540_8_ + d6) + 1; + int k4 = MathHelper.floor_double(p_151540_10_ - d12) - var2 * 16 - 1; + int j2 = MathHelper.floor_double(p_151540_10_ + d12) - var2 * 16 + 1; + + if (i4 < 0) { + i4 = 0; + } + + if (l1 > 16) { + l1 = 16; + } + + if (j4 < 1) { + j4 = 1; + } + + if (i2 > 248) { + i2 = 248; + } + + if (k4 < 0) { + k4 = 0; + } + + if (j2 > 16) { + j2 = 16; + } + + boolean flag2 = false; + int k2; + int j3; + + for (k2 = i4; !flag2 && k2 < l1; ++k2) { + for (int l2 = k4; !flag2 && l2 < j2; ++l2) { + for (int i3 = i2 + 1; !flag2 && i3 >= j4 - 1; --i3) { + j3 = (k2 * 16 + l2) * 256 + i3; + + if (i3 >= 0 && i3 < 256) { + Block block = aBlocksInChunkOrPassedIn[j3]; + + if (isOceanBlock(aBlocksInChunkOrPassedIn, j3, k2, i3, l2, var1, var2)) { + flag2 = true; + } + + if (i3 != j4 - 1 && k2 != i4 && k2 != l1 - 1 && l2 != k4 && l2 != j2 - 1) { + i3 = j4; + } + } + } + } + } + + if (!flag2) { + for (k2 = i4; k2 < l1; ++k2) { + double d13 = ((double) (k2 + var1 * 16) + 0.5D - p_151540_6_) / d12; + + for (j3 = k4; j3 < j2; ++j3) { + double d14 = ((double) (j3 + var2 * 16) + 0.5D - p_151540_10_) / d12; + int k3 = (k2 * 16 + j3) * 256 + i2; + boolean flag = false; + + if (d13 * d13 + d14 * d14 < 1.0D) { + for (int l3 = i2 - 1; l3 >= j4; --l3) { + double d11 = ((double) l3 + 0.5D - p_151540_8_) / d6; + + if ((d13 * d13 + d14 * d14) * (double) this.field_75046_d[l3] + d11 * d11 / 6.0D + < 1.0D) { + Block block1 = aBlocksInChunkOrPassedIn[k3]; + + if (checkIfTopBlock(aBlocksInChunkOrPassedIn, k3, k2, l3, j3, var1, var2)) { + flag = true; + } + + Logger.WORLD("Generating Large Ravine. 2"); + digBlock(aBlocksInChunkOrPassedIn, k3, k2, l3, j3, var1, var2, flag); + } + + --k3; + } + } + } + } + + if (possibleIsUnderGroundFlag) { + break; + } + } + } + } + } + } + + // generate? + @Override + protected void func_151538_a( + World p_151538_1_, int p_151538_2_, int p_151538_3_, int chunkX, int chunkZ, Block[] blocks) { + if (this.rand.nextInt(50) == 0) { + double d0 = (double) (p_151538_2_ * 16 + this.rand.nextInt(16)); + double d1 = (double) (this.rand.nextInt(this.rand.nextInt(40) + 8) + 20); + double d2 = (double) (p_151538_3_ * 16 + this.rand.nextInt(16)); + byte b0 = 1; + + for (int i1 = 0; i1 < b0; ++i1) { + float f = this.rand.nextFloat() * (float) Math.PI * 2.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; + float f2 = (this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F; + this.func_151540_a(this.rand.nextLong(), chunkX, chunkZ, blocks, d0, d1, d2, f2, f, f1, 0, 0, 3.0D); + } + } + } + + private static Method isTopBlock; + + // Determine if the block at the specified location is the top block for the + // biome, we take into account + private synchronized boolean checkIfTopBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) { + try { + if (isTopBlock == null) { + isTopBlock = MapGenRavine.class.getDeclaredMethod( + "isTopBlock", Block[].class, int.class, int.class, int.class, int.class, int.class, int.class); + } + if (isTopBlock != null) { + return (boolean) isTopBlock.invoke(this, data, index, x, y, z, chunkX, chunkZ); + } else { + return false; + } + } catch (NoSuchMethodException + | SecurityException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException n) { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java b/src/main/java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java index b6b83d997b..98eb22f760 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java @@ -1,8 +1,7 @@ package gtPlusPlus.australia.gen.map.component; -import java.util.Random; - import gtPlusPlus.api.objects.Logger; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -17,180 +16,185 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraftforge.common.ChestGenHooks; public class AustraliaComponent extends StructureComponent { - public AustraliaComponent() { - } - - public AustraliaComponent(int direction, Random random, int x, int z, int dimX, int dimY, int dimZ) { - super(direction); - this.coordBaseMode = direction; - this.boundingBox = calcBox(direction, x + (16 - dimX) / 2, 64, z + (16 - dimZ) / 2, dimX, dimY, dimZ, 0); - } - - public boolean addComponentParts(World world, Random random) { - return true; - } - - protected void func_151554_b(World par1World, Block par2, int par3, int par4, int par5, int par6, - StructureBoundingBox par7StructureBoundingBox) { - int j1 = getXWithOffset(par4, par6); - int k0 = getYWithOffset(par5); - int k1 = k0; - int l1 = getZWithOffset(par4, par6); - if (par7StructureBoundingBox.isVecInside(j1, k1, l1)) { - if (par1World.isAirBlock(j1, k1, l1)) { - return; - } - k1--; - while (((par1World.isAirBlock(j1, k1, l1)) || (!par1World.getBlock(j1, k1, l1).getMaterial().isSolid()) - || (par1World.getBlock(j1, k1, l1) == Blocks.ice)) && (k1 > 1)) { - par1World.setBlock(j1, k1, l1, par2, par3, 2); - - k1--; - } - } - } - - protected void clearCurrentPositionBlocksUpwards(World par1World, int par2, int par3, int par4, - StructureBoundingBox par5StructureBoundingBox) { - int l = getXWithOffset(par2, par4); - int i1 = getYWithOffset(par3); - int j1 = getZWithOffset(par2, par4); - if (par5StructureBoundingBox.isVecInside(l, i1, j1)) { - int i = 0; - for (;;) { - i++; - if (((i >= 20) && (par1World.isAirBlock(l, i1, j1))) || (i1 >= 255)) { - break; - } - par1World.setBlock(l, i1, j1, Blocks.air, 0, 2); - i1++; - } - } - } - - protected boolean isWaterBelow(World par1World, int par4, int par5, int par6, - StructureBoundingBox par7StructureBoundingBox) { - int j1 = getXWithOffset(par4, par6); - int k1 = getYWithOffset(par5); - int l1 = getZWithOffset(par4, par6); - for (int i = 0; i < 10; i++) { - Material material = par1World.getBlock(j1, k1, l1).getMaterial(); - if ((material.isLiquid()) || (material == Material.ice)) { - return true; - } - if (!par1World.isAirBlock(j1, k1, l1)) { - return false; - } - } - return false; - } - - public void setDispenser(int x, int y, int z, Random random, World world, int facing) { - int i1 = getXWithOffset(x, z); - int j1 = getYWithOffset(y); - int k1 = getZWithOffset(x, z); - - world.setBlock(i1, j1, k1, Blocks.dispenser, facing, 0); - TileEntity tileDispenser = world.getTileEntity(i1, j1, k1); - if ((tileDispenser != null) && ((tileDispenser instanceof TileEntityDispenser))) { - ChestGenHooks info = ChestGenHooks.getInfo("mineshaftCorridor"); - WeightedRandomChestContent.generateChestContents(random, info.getItems(random), - (TileEntityDispenser) tileDispenser, info.getCount(random)); - } else { - Logger.WARNING("Failed to fetch dispenser entity at (" + i1 + ", " + j1 + ", " + k1 + ")"); - } - } - - protected void setSpawner(int x, int y, int z, String mobName, World world) { - int i1 = getXWithOffset(x, z); - int j1 = getYWithOffset(y); - int k1 = getZWithOffset(x, z); - - world.setBlock(i1, j1, k1, Blocks.mob_spawner, 0, 2); - TileEntity tileSpawner = world.getTileEntity(i1, j1, k1); - if ((tileSpawner != null) && ((tileSpawner instanceof TileEntityMobSpawner))) { - ((TileEntityMobSpawner) tileSpawner).func_145881_a().setEntityName(mobName); - } else { - Logger.WARNING("Failed to fetch mob spawner entity at (" + i1 + ", " + j1 + ", " + k1 + ")"); - } - } - - protected void setFurnace(int x, int y, int z, World world) { - int i1 = getXWithOffset(x, z); - int j1 = getYWithOffset(y); - int k1 = getZWithOffset(x, z); - - world.setBlock(i1, j1, k1, Blocks.furnace, getMetadataWithOffset(Blocks.piston, 3), 2); - } - - protected void placeAirBlockAtPos(int x, int y, int z, StructureBoundingBox bounds, World world) { - placeBlockAtCurrentPosition(world, Blocks.air, 0, x, y, z, bounds); - } - - protected void place(Block block, int meta, int x, int y, int z, StructureBoundingBox bounds, World world) { - placeBlockAtCurrentPosition(world, block, meta, x, y, z, bounds); - } - - protected StructureBoundingBox calcBox(int direction, int x, int y, int z, int xLength, int height, int zLength, - int xShift) { - int minX = 0; - int maxX = 0; - int minY = y; - int maxY = y + height; - int minZ = 0; - int maxZ = 0; - switch (direction) { - case 0: - minX = x - xShift; - maxX = x - xShift + xLength; - minZ = z; - maxZ = z + zLength; - break; - case 1: - minX = x - zLength; - maxX = x; - minZ = z - xShift; - maxZ = z - xShift + xLength; - break; - case 2: - minX = x - xShift; - maxX = x - xShift + xLength; - minZ = z - zLength; - maxZ = z; - break; - case 3: - minX = x; - maxX = x + zLength; - minZ = z - xShift; - maxZ = z - xShift + xLength; - } - return new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); - } - - protected int calcGroundHeight(World world, StructureBoundingBox boundingBox) { - int height = 0; - int count = 0; - for (int z = boundingBox.minZ; z <= boundingBox.maxZ; z++) { - for (int x = boundingBox.minX; x <= boundingBox.maxX; x++) { - if (boundingBox.isVecInside(x, 64, z)) { - height += Math.max(world.getTopSolidOrLiquidBlock(x, z), world.provider.getAverageGroundLevel()); - count++; - } - } - } - if (count == 0) { - return -1; - } - return height / count; - } - - protected void func_143012_a(NBTTagCompound nbttagcompound) { - } - - protected void func_143011_b(NBTTagCompound nbttagcompound) { - } - - public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) { - return true; - } + public AustraliaComponent() {} + + public AustraliaComponent(int direction, Random random, int x, int z, int dimX, int dimY, int dimZ) { + super(direction); + this.coordBaseMode = direction; + this.boundingBox = calcBox(direction, x + (16 - dimX) / 2, 64, z + (16 - dimZ) / 2, dimX, dimY, dimZ, 0); + } + + public boolean addComponentParts(World world, Random random) { + return true; + } + + protected void func_151554_b( + World par1World, + Block par2, + int par3, + int par4, + int par5, + int par6, + StructureBoundingBox par7StructureBoundingBox) { + int j1 = getXWithOffset(par4, par6); + int k0 = getYWithOffset(par5); + int k1 = k0; + int l1 = getZWithOffset(par4, par6); + if (par7StructureBoundingBox.isVecInside(j1, k1, l1)) { + if (par1World.isAirBlock(j1, k1, l1)) { + return; + } + k1--; + while (((par1World.isAirBlock(j1, k1, l1)) + || (!par1World.getBlock(j1, k1, l1).getMaterial().isSolid()) + || (par1World.getBlock(j1, k1, l1) == Blocks.ice)) + && (k1 > 1)) { + par1World.setBlock(j1, k1, l1, par2, par3, 2); + + k1--; + } + } + } + + protected void clearCurrentPositionBlocksUpwards( + World par1World, int par2, int par3, int par4, StructureBoundingBox par5StructureBoundingBox) { + int l = getXWithOffset(par2, par4); + int i1 = getYWithOffset(par3); + int j1 = getZWithOffset(par2, par4); + if (par5StructureBoundingBox.isVecInside(l, i1, j1)) { + int i = 0; + for (; ; ) { + i++; + if (((i >= 20) && (par1World.isAirBlock(l, i1, j1))) || (i1 >= 255)) { + break; + } + par1World.setBlock(l, i1, j1, Blocks.air, 0, 2); + i1++; + } + } + } + + protected boolean isWaterBelow( + World par1World, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { + int j1 = getXWithOffset(par4, par6); + int k1 = getYWithOffset(par5); + int l1 = getZWithOffset(par4, par6); + for (int i = 0; i < 10; i++) { + Material material = par1World.getBlock(j1, k1, l1).getMaterial(); + if ((material.isLiquid()) || (material == Material.ice)) { + return true; + } + if (!par1World.isAirBlock(j1, k1, l1)) { + return false; + } + } + return false; + } + + public void setDispenser(int x, int y, int z, Random random, World world, int facing) { + int i1 = getXWithOffset(x, z); + int j1 = getYWithOffset(y); + int k1 = getZWithOffset(x, z); + + world.setBlock(i1, j1, k1, Blocks.dispenser, facing, 0); + TileEntity tileDispenser = world.getTileEntity(i1, j1, k1); + if ((tileDispenser != null) && ((tileDispenser instanceof TileEntityDispenser))) { + ChestGenHooks info = ChestGenHooks.getInfo("mineshaftCorridor"); + WeightedRandomChestContent.generateChestContents( + random, info.getItems(random), (TileEntityDispenser) tileDispenser, info.getCount(random)); + } else { + Logger.WARNING("Failed to fetch dispenser entity at (" + i1 + ", " + j1 + ", " + k1 + ")"); + } + } + + protected void setSpawner(int x, int y, int z, String mobName, World world) { + int i1 = getXWithOffset(x, z); + int j1 = getYWithOffset(y); + int k1 = getZWithOffset(x, z); + + world.setBlock(i1, j1, k1, Blocks.mob_spawner, 0, 2); + TileEntity tileSpawner = world.getTileEntity(i1, j1, k1); + if ((tileSpawner != null) && ((tileSpawner instanceof TileEntityMobSpawner))) { + ((TileEntityMobSpawner) tileSpawner).func_145881_a().setEntityName(mobName); + } else { + Logger.WARNING("Failed to fetch mob spawner entity at (" + i1 + ", " + j1 + ", " + k1 + ")"); + } + } + + protected void setFurnace(int x, int y, int z, World world) { + int i1 = getXWithOffset(x, z); + int j1 = getYWithOffset(y); + int k1 = getZWithOffset(x, z); + + world.setBlock(i1, j1, k1, Blocks.furnace, getMetadataWithOffset(Blocks.piston, 3), 2); + } + + protected void placeAirBlockAtPos(int x, int y, int z, StructureBoundingBox bounds, World world) { + placeBlockAtCurrentPosition(world, Blocks.air, 0, x, y, z, bounds); + } + + protected void place(Block block, int meta, int x, int y, int z, StructureBoundingBox bounds, World world) { + placeBlockAtCurrentPosition(world, block, meta, x, y, z, bounds); + } + + protected StructureBoundingBox calcBox( + int direction, int x, int y, int z, int xLength, int height, int zLength, int xShift) { + int minX = 0; + int maxX = 0; + int minY = y; + int maxY = y + height; + int minZ = 0; + int maxZ = 0; + switch (direction) { + case 0: + minX = x - xShift; + maxX = x - xShift + xLength; + minZ = z; + maxZ = z + zLength; + break; + case 1: + minX = x - zLength; + maxX = x; + minZ = z - xShift; + maxZ = z - xShift + xLength; + break; + case 2: + minX = x - xShift; + maxX = x - xShift + xLength; + minZ = z - zLength; + maxZ = z; + break; + case 3: + minX = x; + maxX = x + zLength; + minZ = z - xShift; + maxZ = z - xShift + xLength; + } + return new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); + } + + protected int calcGroundHeight(World world, StructureBoundingBox boundingBox) { + int height = 0; + int count = 0; + for (int z = boundingBox.minZ; z <= boundingBox.maxZ; z++) { + for (int x = boundingBox.minX; x <= boundingBox.maxX; x++) { + if (boundingBox.isVecInside(x, 64, z)) { + height += Math.max(world.getTopSolidOrLiquidBlock(x, z), world.provider.getAverageGroundLevel()); + count++; + } + } + } + if (count == 0) { + return -1; + } + return height / count; + } + + protected void func_143012_a(NBTTagCompound nbttagcompound) {} + + protected void func_143011_b(NBTTagCompound nbttagcompound) {} + + public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentHut.java b/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentHut.java index 1f5dd59667..c43a201fd1 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentHut.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentHut.java @@ -1,14 +1,12 @@ package gtPlusPlus.australia.gen.map.component; -import java.util.Random; - import gtPlusPlus.api.interfaces.IGeneratorWorld; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.australia.GTplusplus_Australia; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.plugin.villagers.entity.EntityNativeAustralian; +import java.util.Random; import net.minecraft.block.Block; -import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -19,456 +17,454 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.structure.StructureBoundingBox; public class ComponentHut extends AustraliaComponent { - public static final int DIM_X = 7; - public static final int DIM_Y = 10; - public static final int DIM_Z = 7; - - public ComponentHut() { - } - - public ComponentHut(int direction, Random random, int x, int z) { - super(direction, random, x, z, 7, 10, 7); - } - - public boolean addComponentParts(World world, Random random) { - - BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); - int groundAvg = calcGroundHeight(world, this.boundingBox); - if (groundAvg < 0) { - return true; - } - this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); - if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { - return false; - } - - Block aWall1, aWall2, aRoof, aFloor; - - if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { - aWall1 = Blocks.sand; - aWall2 = Blocks.sandstone; - aRoof = Blocks.sandstone; - aFloor = Blocks.sandstone; - } - else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { - aWall1 = Blocks.clay; - aWall2 = Blocks.hardened_clay; - aRoof = Blocks.hardened_clay; - aFloor = Blocks.stained_hardened_clay; - } - else { - aWall1 = Blocks.sand; - aWall2 = Blocks.sandstone; - aRoof = Blocks.sandstone; - aFloor = Blocks.sandstone; - } - - //Empty Area - fillWithAir(world, this.boundingBox, 0, 1, 0, 6, 9, 6); - - //Build Floor - fillWithMetadataBlocks(world, this.boundingBox, 0, 0, 0, 6, 0, 6, aFloor, 0, aFloor, 1, false); - - //Layer 2 - int dir = MathUtils.randInt(0, 3); - - //Door First - if (dir == 0) { - placeDoorAtCurrentPosition( - world, this.boundingBox, random, 0, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); - } - else if (dir == 1) { - placeDoorAtCurrentPosition( - world, this.boundingBox, random, 3, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1)); - } - else if (dir == 2) { - placeDoorAtCurrentPosition( - world, this.boundingBox, random, 6, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); - } - else { - placeDoorAtCurrentPosition( - world, this.boundingBox, random, 3, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1)); - } - - //Layer 1 - //Wall Top - place(aWall1, 0, 0, 1, 2, this.boundingBox, world); - if (dir != 0) place(aWall1, 0, 0, 1, 3, this.boundingBox, world); - place(aWall1, 0, 0, 1, 4, this.boundingBox, world); - //Wall Right - place(aWall1, 0, 2, 1, 6, this.boundingBox, world); - if (dir != 1) place(aWall2, 0, 3, 1, 6, this.boundingBox, world); - place(aWall1, 0, 4, 1, 6, this.boundingBox, world); - //Wall Bottom - place(aWall2, 0, 6, 1, 4, this.boundingBox, world); - if (dir != 2) place(aWall1, 0, 6, 1, 3, this.boundingBox, world); - place(aWall1, 0, 6, 1, 2, this.boundingBox, world); - //Wall Left - place(aWall1, 0, 4, 1, 0, this.boundingBox, world); - if (dir != 3) place(aWall1, 0, 3, 1, 0, this.boundingBox, world); - place(aWall2, 0, 2, 1, 0, this.boundingBox, world); - //Corners - place(aWall1, 0, 1, 1, 5, this.boundingBox, world); - place(aWall2, 0, 5, 1, 5, this.boundingBox, world); - place(aWall1, 0, 5, 1, 1, this.boundingBox, world); - place(aWall1, 0, 1, 1, 1, this.boundingBox, world); - - - //Wall Top - place(aWall1, 0, 0, 2, 2, this.boundingBox, world); - //place(aWall1, 0, 0, 2, 3, this.boundingBox, world); - place(aWall2, 0, 0, 2, 4, this.boundingBox, world); - - //Wall Right - place(aWall2, 0, 2, 2, 6, this.boundingBox, world); - //place(aWall1, 0, 3, 2, 6, this.boundingBox, world); - place(aWall1, 0, 4, 2, 6, this.boundingBox, world); - - //Wall Bottom - place(aWall1, 0, 6, 2, 4, this.boundingBox, world); - //place(aWall1, 0, 6, 2, 3, this.boundingBox, world); - place(aWall2, 0, 6, 2, 2, this.boundingBox, world); - - //Wall Left - place(aWall1, 0, 4, 2, 0, this.boundingBox, world); - //place(aWall2, 0, 4, 2, 0, this.boundingBox, world); - place(aWall1, 0, 2, 2, 0, this.boundingBox, world); - - //Corners - place(aWall1, 0, 1, 2, 5, this.boundingBox, world); - place(aWall1, 0, 5, 2, 5, this.boundingBox, world); - place(aWall2, 0, 5, 2, 1, this.boundingBox, world); - place(aWall2, 0, 1, 2, 1, this.boundingBox, world); - - //Layer 3 - //Wall Top - place(aWall2, 0, 0, 3, 2, this.boundingBox, world); - place(aWall1, 0, 0, 3, 3, this.boundingBox, world); - place(aWall1, 0, 0, 3, 4, this.boundingBox, world); - //Wall Right - place(aWall1, 0, 2, 3, 6, this.boundingBox, world); - place(aWall1, 0, 3, 3, 6, this.boundingBox, world); - place(aWall1, 0, 4, 3, 6, this.boundingBox, world); - //Wall Bottom - place(aWall1, 0, 6, 3, 4, this.boundingBox, world); - place(aWall2, 0, 6, 3, 3, this.boundingBox, world); - place(aWall1, 0, 6, 3, 2, this.boundingBox, world); - //Wall Left - place(aWall1, 0, 4, 3, 0, this.boundingBox, world); - place(aWall2, 0, 3, 3, 0, this.boundingBox, world); - place(aWall1, 0, 2, 3, 0, this.boundingBox, world); - //Corners - place(aWall1, 0, 1, 3, 5, this.boundingBox, world); - place(aWall2, 0, 5, 3, 5, this.boundingBox, world); - place(aWall1, 0, 5, 3, 1, this.boundingBox, world); - place(aWall1, 0, 1, 3, 1, this.boundingBox, world); - - //Roof - //Roof 1 Top - place(aRoof, 0, 1, 4, 2, this.boundingBox, world); - place(aRoof, 0, 1, 4, 3, this.boundingBox, world); - place(aRoof, 0, 1, 4, 4, this.boundingBox, world); - //Roof 1 Right - place(aRoof, 0, 2, 4, 5, this.boundingBox, world); - place(aRoof, 0, 3, 4, 5, this.boundingBox, world); - place(aRoof, 0, 4, 4, 5, this.boundingBox, world); - //Roof 1 Bottom - place(aRoof, 0, 5, 4, 4, this.boundingBox, world); - place(aRoof, 0, 5, 4, 3, this.boundingBox, world); - place(aRoof, 0, 5, 4, 2, this.boundingBox, world); - //Roof 1 Left - place(aRoof, 0, 4, 4, 1, this.boundingBox, world); - place(aRoof, 0, 3, 4, 1, this.boundingBox, world); - place(aRoof, 0, 2, 4, 1, this.boundingBox, world); - - //Roof 2 Top - place(aRoof, 0, 2, 5, 2, this.boundingBox, world); - place(aRoof, 0, 2, 5, 3, this.boundingBox, world); - place(aRoof, 0, 2, 5, 4, this.boundingBox, world); - - //Roof 2 Right - //place(aWall1, 0, 2, 5, 4, this.boundingBox, world); - place(aRoof, 0, 3, 5, 4, this.boundingBox, world); - //place(aWall1, 0, 4, 5, 4, this.boundingBox, world); - - //Roof 2 Bottom - place(aRoof, 0, 4, 5, 4, this.boundingBox, world); - place(aRoof, 0, 4, 5, 3, this.boundingBox, world); - place(aRoof, 0, 4, 5, 2, this.boundingBox, world); - - //Roof 2 Left - //place(aWall1, 0, 4, 5, 2, this.boundingBox, world); - place(aRoof, 0, 3, 5, 2, this.boundingBox, world); - //place(aWall1, 0, 2, 5, 2, this.boundingBox, world); - - //Roof 3 Top - place(Blocks.glowstone, 0, 3, 5, 3, this.boundingBox, world); - /* - int logID = MathUtils.randInt(0, 1); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 1, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 5, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 1, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 5, this.boundingBox, world); - - int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; - - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 2, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 3, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 4, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 2, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 3, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 4, this.boundingBox, world); - - for (int x = -2; x < 9; x++) { - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 0, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 1, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 2, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 3, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 4, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 5, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 6, this.boundingBox, world); - } - - int glassMeta = Math.min(16, (coordBaseMode+MathUtils.randInt(0, 8))); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 2, 2, 1, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 2, 2, 5, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 4, 2, 5, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 0, 2, 3, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 6, 2, 3, this.boundingBox, world); - - placeDoorAtCurrentPosition(world, this.boundingBox, random, 4, 1, 1, - getMetadataWithOffset(Blocks.wooden_door, 1)); - - place(Blocks.leaves, MathUtils.randInt(0, 3), 1, 1, 4, this.boundingBox, world); - place(Blocks.torch, 0, 1, 2, 3, this.boundingBox, world); - place(Blocks.torch, 0, 3, 2, 2, this.boundingBox, world); - if (!this.hasMadeChest) { - int ic = getYWithOffset(0); - int jc = getXWithOffset(7, 1); - int kc = getZWithOffset(7, 1); - if (this.boundingBox.isVecInside(jc, ic, kc)) { - this.hasMadeChest = true; - generateStructureChestContents(world, this.boundingBox, random, 1, 1, 2, shackChestContents, - 1 + random.nextInt(3)); - } - }*/ - for (int i = 0; i < 7; i++) { - for (int j = 0; j < 7; j++) { - clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); - func_151554_b(world, aFloor, 0, j, 0, i, this.boundingBox); - } - } - spawnNatives(world, this.boundingBox, 4, 1, 3, MathUtils.randInt(3, 5)); - - return true; - - /* - BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); - int groundAvg = calcGroundHeight(world, this.boundingBox); - if (groundAvg < 0) { - return true; - } - this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); - if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { - return false; - } - Block groundID = Blocks.grass; - Block undergroundID = Blocks.dirt; - if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { - groundID = Blocks.sand; - undergroundID = Blocks.sand; - } - else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { - groundID = Blocks.hardened_clay; - undergroundID = Blocks.stained_hardened_clay; - } - - - fillWithAir(world, this.boundingBox, 0, 1, 0, 6, 9, 6); - fillWithMetadataBlocks(world, this.boundingBox, 0, 0, 1, 6, 1, 5, Blocks.dirt, 0, Blocks.dirt, 1, false); - fillWithMetadataBlocks(world, this.boundingBox, 0, 2, 1, 6, 3, 5, Blocks.cobblestone, 0, Blocks.cobblestone, 0, false); - fillWithAir(world, this.boundingBox, 1, 1, 2, 5, 3, 4); - - int logID = MathUtils.randInt(0, 1); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 1, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 5, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 1, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 1, this.boundingBox, world); - - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 5, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 5, this.boundingBox, world); - - int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; - - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 2, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 3, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 4, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 2, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 3, this.boundingBox, world); - place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 4, this.boundingBox, world); - - for (int x = -2; x < 9; x++) { - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 0, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 1, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 2, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 3, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 4, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 5, this.boundingBox, world); - place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 6, this.boundingBox, world); - } - - int glassMeta = Math.min(16, (coordBaseMode+MathUtils.randInt(0, 8))); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 2, 2, 1, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 2, 2, 5, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 4, 2, 5, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 0, 2, 3, this.boundingBox, world); - if (MathUtils.randInt(0, 5) > 4) - place(Blocks.stained_glass, glassMeta, 6, 2, 3, this.boundingBox, world); - - placeDoorAtCurrentPosition(world, this.boundingBox, random, 4, 1, 1, - getMetadataWithOffset(Blocks.wooden_door, 1)); - - place(Blocks.leaves, MathUtils.randInt(0, 3), 1, 1, 4, this.boundingBox, world); - place(Blocks.torch, 0, 1, 2, 3, this.boundingBox, world); - place(Blocks.torch, 0, 3, 2, 2, this.boundingBox, world); - if (!this.hasMadeChest) { - int ic = getYWithOffset(0); - int jc = getXWithOffset(7, 1); - int kc = getZWithOffset(7, 1); - if (this.boundingBox.isVecInside(jc, ic, kc)) { - this.hasMadeChest = true; - generateStructureChestContents(world, this.boundingBox, random, 1, 1, 2, shackChestContents, - 1 + random.nextInt(3)); - } - } - for (int i = 0; i < 7; i++) { - for (int j = 0; j < 7; j++) { - clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); - func_151554_b(world, undergroundID, 0, j, 0, i, this.boundingBox); - } - } - spawnNatives(world, this.boundingBox, 4, 1, 3, MathUtils.randInt(3, 5)); - - return true; - */} - - private int nativesSpawned = 0; - - private void spawnNatives(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, - int par5, int maxSpawned) { - if (this.nativesSpawned < maxSpawned) { - for (int i1 = this.nativesSpawned; i1 < maxSpawned; i1++) { - int j1 = getXWithOffset(par3 + i1, par5); - int k1 = getYWithOffset(par4); - int l1 = getZWithOffset(par3 + i1, par5); - if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) { - break; - } - if (par1World.rand.nextInt(MathUtils.randInt(3, 5)) != 0) { - EntityNativeAustralian entityvillager = new EntityNativeAustralian(par1World); - entityvillager.func_110163_bv(); - entityvillager.setLocationAndAngles(j1 + 0.5D, k1, l1 + 0.5D, 0.0F, 0.0F); - par1World.spawnEntityInWorld(entityvillager); - this.nativesSpawned += 1; - } - } - } - } - - public static final WeightedRandomChestContent[] shackChestContents = { - new WeightedRandomChestContent(Items.glass_bottle, 0, 1, 1, 10), - new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), - new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), - new WeightedRandomChestContent(Items.cooked_fished, 0, 1, 3, 10), - new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 1, 1, 1, 15), - // new WeightedRandomChestContent(Witchery.Items.GENERIC, - // Witchery.Items.GENERIC.itemRowanBerries.damageValue, 1, 2, 10), - new WeightedRandomChestContent(Items.iron_shovel, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5) }; - private boolean hasMadeChest; - private static final String CHEST_KEY = "AUSShackChest"; - - protected void func_143012_a(NBTTagCompound par1NBTTagCompound) { - super.func_143012_a(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("AUSShackChest", this.hasMadeChest); - par1NBTTagCompound.setInteger("AUSWCount", this.nativesSpawned); - } - - protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { - super.func_143011_b(par1NBTTagCompound); - this.hasMadeChest = par1NBTTagCompound.getBoolean("AUSShackChest"); - if (par1NBTTagCompound.hasKey("AUSWCount")) { - this.nativesSpawned = par1NBTTagCompound.getInteger("AUSWCount"); - } else { - this.nativesSpawned = 0; - } - } - - public static class WorldHandlerHut implements IGeneratorWorld { - private final double chance; - private final int range; - - public WorldHandlerHut(double chance) { - this.chance = chance; - this.range = 400; - } - - public int getExtentX() { - return 7; - } - - public int getExtentZ() { - return 7; - } - - public int getRange() { - return this.range; - } - - public boolean generate(World world, Random random, int x, int z) { - if ((MathUtils.randInt(0, 100) < (this.chance/5))) { - int direction = MathUtils.randInt(0, 3); - new ComponentHut(direction, random, x, z).addComponentParts(world, random); - Logger.WORLD("NativeHut x: " + x + " | z: " + z + " | Dir: " + direction); - return true; - } - return false; - } - - public void initiate() { - } - } - + public static final int DIM_X = 7; + public static final int DIM_Y = 10; + public static final int DIM_Z = 7; + + public ComponentHut() {} + + public ComponentHut(int direction, Random random, int x, int z) { + super(direction, random, x, z, 7, 10, 7); + } + + public boolean addComponentParts(World world, Random random) { + + BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); + int groundAvg = calcGroundHeight(world, this.boundingBox); + if (groundAvg < 0) { + return true; + } + this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); + if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) + || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { + return false; + } + + Block aWall1, aWall2, aRoof, aFloor; + + if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { + aWall1 = Blocks.sand; + aWall2 = Blocks.sandstone; + aRoof = Blocks.sandstone; + aFloor = Blocks.sandstone; + } else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { + aWall1 = Blocks.clay; + aWall2 = Blocks.hardened_clay; + aRoof = Blocks.hardened_clay; + aFloor = Blocks.stained_hardened_clay; + } else { + aWall1 = Blocks.sand; + aWall2 = Blocks.sandstone; + aRoof = Blocks.sandstone; + aFloor = Blocks.sandstone; + } + + // Empty Area + fillWithAir(world, this.boundingBox, 0, 1, 0, 6, 9, 6); + + // Build Floor + fillWithMetadataBlocks(world, this.boundingBox, 0, 0, 0, 6, 0, 6, aFloor, 0, aFloor, 1, false); + + // Layer 2 + int dir = MathUtils.randInt(0, 3); + + // Door First + if (dir == 0) { + placeDoorAtCurrentPosition( + world, this.boundingBox, random, 0, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); + } else if (dir == 1) { + placeDoorAtCurrentPosition( + world, this.boundingBox, random, 3, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1)); + } else if (dir == 2) { + placeDoorAtCurrentPosition( + world, this.boundingBox, random, 6, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); + } else { + placeDoorAtCurrentPosition( + world, this.boundingBox, random, 3, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1)); + } + + // Layer 1 + // Wall Top + place(aWall1, 0, 0, 1, 2, this.boundingBox, world); + if (dir != 0) place(aWall1, 0, 0, 1, 3, this.boundingBox, world); + place(aWall1, 0, 0, 1, 4, this.boundingBox, world); + // Wall Right + place(aWall1, 0, 2, 1, 6, this.boundingBox, world); + if (dir != 1) place(aWall2, 0, 3, 1, 6, this.boundingBox, world); + place(aWall1, 0, 4, 1, 6, this.boundingBox, world); + // Wall Bottom + place(aWall2, 0, 6, 1, 4, this.boundingBox, world); + if (dir != 2) place(aWall1, 0, 6, 1, 3, this.boundingBox, world); + place(aWall1, 0, 6, 1, 2, this.boundingBox, world); + // Wall Left + place(aWall1, 0, 4, 1, 0, this.boundingBox, world); + if (dir != 3) place(aWall1, 0, 3, 1, 0, this.boundingBox, world); + place(aWall2, 0, 2, 1, 0, this.boundingBox, world); + // Corners + place(aWall1, 0, 1, 1, 5, this.boundingBox, world); + place(aWall2, 0, 5, 1, 5, this.boundingBox, world); + place(aWall1, 0, 5, 1, 1, this.boundingBox, world); + place(aWall1, 0, 1, 1, 1, this.boundingBox, world); + + // Wall Top + place(aWall1, 0, 0, 2, 2, this.boundingBox, world); + // place(aWall1, 0, 0, 2, 3, this.boundingBox, world); + place(aWall2, 0, 0, 2, 4, this.boundingBox, world); + + // Wall Right + place(aWall2, 0, 2, 2, 6, this.boundingBox, world); + // place(aWall1, 0, 3, 2, 6, this.boundingBox, world); + place(aWall1, 0, 4, 2, 6, this.boundingBox, world); + + // Wall Bottom + place(aWall1, 0, 6, 2, 4, this.boundingBox, world); + // place(aWall1, 0, 6, 2, 3, this.boundingBox, world); + place(aWall2, 0, 6, 2, 2, this.boundingBox, world); + + // Wall Left + place(aWall1, 0, 4, 2, 0, this.boundingBox, world); + // place(aWall2, 0, 4, 2, 0, this.boundingBox, world); + place(aWall1, 0, 2, 2, 0, this.boundingBox, world); + + // Corners + place(aWall1, 0, 1, 2, 5, this.boundingBox, world); + place(aWall1, 0, 5, 2, 5, this.boundingBox, world); + place(aWall2, 0, 5, 2, 1, this.boundingBox, world); + place(aWall2, 0, 1, 2, 1, this.boundingBox, world); + + // Layer 3 + // Wall Top + place(aWall2, 0, 0, 3, 2, this.boundingBox, world); + place(aWall1, 0, 0, 3, 3, this.boundingBox, world); + place(aWall1, 0, 0, 3, 4, this.boundingBox, world); + // Wall Right + place(aWall1, 0, 2, 3, 6, this.boundingBox, world); + place(aWall1, 0, 3, 3, 6, this.boundingBox, world); + place(aWall1, 0, 4, 3, 6, this.boundingBox, world); + // Wall Bottom + place(aWall1, 0, 6, 3, 4, this.boundingBox, world); + place(aWall2, 0, 6, 3, 3, this.boundingBox, world); + place(aWall1, 0, 6, 3, 2, this.boundingBox, world); + // Wall Left + place(aWall1, 0, 4, 3, 0, this.boundingBox, world); + place(aWall2, 0, 3, 3, 0, this.boundingBox, world); + place(aWall1, 0, 2, 3, 0, this.boundingBox, world); + // Corners + place(aWall1, 0, 1, 3, 5, this.boundingBox, world); + place(aWall2, 0, 5, 3, 5, this.boundingBox, world); + place(aWall1, 0, 5, 3, 1, this.boundingBox, world); + place(aWall1, 0, 1, 3, 1, this.boundingBox, world); + + // Roof + // Roof 1 Top + place(aRoof, 0, 1, 4, 2, this.boundingBox, world); + place(aRoof, 0, 1, 4, 3, this.boundingBox, world); + place(aRoof, 0, 1, 4, 4, this.boundingBox, world); + // Roof 1 Right + place(aRoof, 0, 2, 4, 5, this.boundingBox, world); + place(aRoof, 0, 3, 4, 5, this.boundingBox, world); + place(aRoof, 0, 4, 4, 5, this.boundingBox, world); + // Roof 1 Bottom + place(aRoof, 0, 5, 4, 4, this.boundingBox, world); + place(aRoof, 0, 5, 4, 3, this.boundingBox, world); + place(aRoof, 0, 5, 4, 2, this.boundingBox, world); + // Roof 1 Left + place(aRoof, 0, 4, 4, 1, this.boundingBox, world); + place(aRoof, 0, 3, 4, 1, this.boundingBox, world); + place(aRoof, 0, 2, 4, 1, this.boundingBox, world); + + // Roof 2 Top + place(aRoof, 0, 2, 5, 2, this.boundingBox, world); + place(aRoof, 0, 2, 5, 3, this.boundingBox, world); + place(aRoof, 0, 2, 5, 4, this.boundingBox, world); + + // Roof 2 Right + // place(aWall1, 0, 2, 5, 4, this.boundingBox, world); + place(aRoof, 0, 3, 5, 4, this.boundingBox, world); + // place(aWall1, 0, 4, 5, 4, this.boundingBox, world); + + // Roof 2 Bottom + place(aRoof, 0, 4, 5, 4, this.boundingBox, world); + place(aRoof, 0, 4, 5, 3, this.boundingBox, world); + place(aRoof, 0, 4, 5, 2, this.boundingBox, world); + + // Roof 2 Left + // place(aWall1, 0, 4, 5, 2, this.boundingBox, world); + place(aRoof, 0, 3, 5, 2, this.boundingBox, world); + // place(aWall1, 0, 2, 5, 2, this.boundingBox, world); + + // Roof 3 Top + place(Blocks.glowstone, 0, 3, 5, 3, this.boundingBox, world); + /* + int logID = MathUtils.randInt(0, 1); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 1, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 5, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 1, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 5, this.boundingBox, world); + + int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; + + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 2, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 3, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 4, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 2, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 3, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 4, this.boundingBox, world); + + for (int x = -2; x < 9; x++) { + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 0, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 1, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 2, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 3, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 4, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 5, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 6, this.boundingBox, world); + } + + int glassMeta = Math.min(16, (coordBaseMode+MathUtils.randInt(0, 8))); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 2, 2, 1, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 2, 2, 5, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 4, 2, 5, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 0, 2, 3, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 6, 2, 3, this.boundingBox, world); + + placeDoorAtCurrentPosition(world, this.boundingBox, random, 4, 1, 1, + getMetadataWithOffset(Blocks.wooden_door, 1)); + + place(Blocks.leaves, MathUtils.randInt(0, 3), 1, 1, 4, this.boundingBox, world); + place(Blocks.torch, 0, 1, 2, 3, this.boundingBox, world); + place(Blocks.torch, 0, 3, 2, 2, this.boundingBox, world); + if (!this.hasMadeChest) { + int ic = getYWithOffset(0); + int jc = getXWithOffset(7, 1); + int kc = getZWithOffset(7, 1); + if (this.boundingBox.isVecInside(jc, ic, kc)) { + this.hasMadeChest = true; + generateStructureChestContents(world, this.boundingBox, random, 1, 1, 2, shackChestContents, + 1 + random.nextInt(3)); + } + }*/ + for (int i = 0; i < 7; i++) { + for (int j = 0; j < 7; j++) { + clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); + func_151554_b(world, aFloor, 0, j, 0, i, this.boundingBox); + } + } + spawnNatives(world, this.boundingBox, 4, 1, 3, MathUtils.randInt(3, 5)); + + return true; + + /* + BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); + int groundAvg = calcGroundHeight(world, this.boundingBox); + if (groundAvg < 0) { + return true; + } + this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); + if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { + return false; + } + Block groundID = Blocks.grass; + Block undergroundID = Blocks.dirt; + if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { + groundID = Blocks.sand; + undergroundID = Blocks.sand; + } + else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { + groundID = Blocks.hardened_clay; + undergroundID = Blocks.stained_hardened_clay; + } + + + fillWithAir(world, this.boundingBox, 0, 1, 0, 6, 9, 6); + fillWithMetadataBlocks(world, this.boundingBox, 0, 0, 1, 6, 1, 5, Blocks.dirt, 0, Blocks.dirt, 1, false); + fillWithMetadataBlocks(world, this.boundingBox, 0, 2, 1, 6, 3, 5, Blocks.cobblestone, 0, Blocks.cobblestone, 0, false); + fillWithAir(world, this.boundingBox, 1, 1, 2, 5, 3, 4); + + int logID = MathUtils.randInt(0, 1); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 1, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 1, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 2, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 3, 5, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 1, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 1, this.boundingBox, world); + + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 1, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 2, 5, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 3, 5, this.boundingBox, world); + + int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; + + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 2, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 3, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 0, 4, 4, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 2, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 3, this.boundingBox, world); + place(Blocks.dirt, MathUtils.randInt(0, 1), 6, 4, 4, this.boundingBox, world); + + for (int x = -2; x < 9; x++) { + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 0, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 1, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 2, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 3, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 5, 4, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 4, 5, this.boundingBox, world); + place(Blocks.leaves, MathUtils.randInt(0, 3), x, 3, 6, this.boundingBox, world); + } + + int glassMeta = Math.min(16, (coordBaseMode+MathUtils.randInt(0, 8))); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 2, 2, 1, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 2, 2, 5, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 4, 2, 5, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 0, 2, 3, this.boundingBox, world); + if (MathUtils.randInt(0, 5) > 4) + place(Blocks.stained_glass, glassMeta, 6, 2, 3, this.boundingBox, world); + + placeDoorAtCurrentPosition(world, this.boundingBox, random, 4, 1, 1, + getMetadataWithOffset(Blocks.wooden_door, 1)); + + place(Blocks.leaves, MathUtils.randInt(0, 3), 1, 1, 4, this.boundingBox, world); + place(Blocks.torch, 0, 1, 2, 3, this.boundingBox, world); + place(Blocks.torch, 0, 3, 2, 2, this.boundingBox, world); + if (!this.hasMadeChest) { + int ic = getYWithOffset(0); + int jc = getXWithOffset(7, 1); + int kc = getZWithOffset(7, 1); + if (this.boundingBox.isVecInside(jc, ic, kc)) { + this.hasMadeChest = true; + generateStructureChestContents(world, this.boundingBox, random, 1, 1, 2, shackChestContents, + 1 + random.nextInt(3)); + } + } + for (int i = 0; i < 7; i++) { + for (int j = 0; j < 7; j++) { + clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); + func_151554_b(world, undergroundID, 0, j, 0, i, this.boundingBox); + } + } + spawnNatives(world, this.boundingBox, 4, 1, 3, MathUtils.randInt(3, 5)); + + return true; + */ } + + private int nativesSpawned = 0; + + private void spawnNatives( + World par1World, + StructureBoundingBox par2StructureBoundingBox, + int par3, + int par4, + int par5, + int maxSpawned) { + if (this.nativesSpawned < maxSpawned) { + for (int i1 = this.nativesSpawned; i1 < maxSpawned; i1++) { + int j1 = getXWithOffset(par3 + i1, par5); + int k1 = getYWithOffset(par4); + int l1 = getZWithOffset(par3 + i1, par5); + if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) { + break; + } + if (par1World.rand.nextInt(MathUtils.randInt(3, 5)) != 0) { + EntityNativeAustralian entityvillager = new EntityNativeAustralian(par1World); + entityvillager.func_110163_bv(); + entityvillager.setLocationAndAngles(j1 + 0.5D, k1, l1 + 0.5D, 0.0F, 0.0F); + par1World.spawnEntityInWorld(entityvillager); + this.nativesSpawned += 1; + } + } + } + } + + public static final WeightedRandomChestContent[] shackChestContents = { + new WeightedRandomChestContent(Items.glass_bottle, 0, 1, 1, 10), + new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), + new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), + new WeightedRandomChestContent(Items.cooked_fished, 0, 1, 3, 10), + new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 1, 1, 1, 15), + // new WeightedRandomChestContent(Witchery.Items.GENERIC, + // Witchery.Items.GENERIC.itemRowanBerries.damageValue, 1, 2, 10), + new WeightedRandomChestContent(Items.iron_shovel, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5) + }; + private boolean hasMadeChest; + private static final String CHEST_KEY = "AUSShackChest"; + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("AUSShackChest", this.hasMadeChest); + par1NBTTagCompound.setInteger("AUSWCount", this.nativesSpawned); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { + super.func_143011_b(par1NBTTagCompound); + this.hasMadeChest = par1NBTTagCompound.getBoolean("AUSShackChest"); + if (par1NBTTagCompound.hasKey("AUSWCount")) { + this.nativesSpawned = par1NBTTagCompound.getInteger("AUSWCount"); + } else { + this.nativesSpawned = 0; + } + } + + public static class WorldHandlerHut implements IGeneratorWorld { + private final double chance; + private final int range; + + public WorldHandlerHut(double chance) { + this.chance = chance; + this.range = 400; + } + + public int getExtentX() { + return 7; + } + + public int getExtentZ() { + return 7; + } + + public int getRange() { + return this.range; + } + + public boolean generate(World world, Random random, int x, int z) { + if ((MathUtils.randInt(0, 100) < (this.chance / 5))) { + int direction = MathUtils.randInt(0, 3); + new ComponentHut(direction, random, x, z).addComponentParts(world, random); + Logger.WORLD("NativeHut x: " + x + " | z: " + z + " | Dir: " + direction); + return true; + } + return false; + } + + public void initiate() {} + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentShack.java b/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentShack.java index e3f501468b..acf222f655 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentShack.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/component/ComponentShack.java @@ -1,7 +1,5 @@ package gtPlusPlus.australia.gen.map.component; -import java.util.Random; - import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.api.interfaces.IGeneratorWorld; @@ -10,6 +8,7 @@ import gtPlusPlus.australia.GTplusplus_Australia; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; @@ -20,260 +19,325 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.structure.StructureBoundingBox; public class ComponentShack extends AustraliaComponent { - public static final int DIM_X = 9; - public static final int DIM_Y = 10; - public static final int DIM_Z = 9; - - public ComponentShack() { - } - - public ComponentShack(int direction, Random random, int x, int z) { - super(direction, random, x, z, DIM_X, DIM_Y, DIM_Z); - } - - public boolean addComponentParts(World world, Random random) { - BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); - int groundAvg = calcGroundHeight(world, this.boundingBox); - if (groundAvg < 0) { - return true; - } - this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); - if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) - || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { - return false; - } - Block mStone; - Block groundID = Blocks.grass; - Block undergroundID = Blocks.dirt; - if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { - groundID = Blocks.sand; - undergroundID = Blocks.sand; - mStone = Blocks.sandstone; - } - else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { - groundID = Blocks.hardened_clay; - undergroundID = Blocks.stained_hardened_clay; - mStone = Blocks.stained_hardened_clay; - } - else { - mStone = Blocks.stonebrick; - } - - int mWoodType = MathUtils.randInt(0, 5); - int logID; - Block mWoodenStairs; - Block mLog; - if (mWoodType == 1) { - mWoodenStairs = Blocks.spruce_stairs; - logID = 1; - } - else if (mWoodType == 2) { - mWoodenStairs = Blocks.birch_stairs; - logID = 2; - - } - else if (mWoodType == 3) { - mWoodenStairs = Blocks.jungle_stairs; - logID = 3; - } - else if (mWoodType == 4) { - mWoodenStairs = Blocks.acacia_stairs; - logID = 0; - } - else if (mWoodType == 5) { - mWoodenStairs = Blocks.dark_oak_stairs; - logID = 1; - } - else { - mWoodenStairs = Blocks.oak_stairs; - logID = 0; - } - if (mWoodType >= 4) { - mLog = Blocks.log2; - } - else { - mLog = Blocks.log; - } - - int mStoneMeta = MathUtils.randInt(0, mStone == Blocks.stained_hardened_clay ? 15 : mStone == Blocks.sandstone ? 2 : 3); - - fillWithAir(world, this.boundingBox, 0, 1, 0, 7, 7, 4); - fillWithMetadataBlocks(world, this.boundingBox, 1, 0, 1, 7, 1, 5, mStone, mStoneMeta, mStone, mStoneMeta, false); - fillWithMetadataBlocks(world, this.boundingBox, 1, 2, 1, 7, 3, 5, Blocks.planks, mWoodType, Blocks.planks, mWoodType, false); - fillWithAir(world, this.boundingBox, 2, 1, 2, 6, 3, 4); - - place(mLog, logID, 1, 1, 1, this.boundingBox, world); - place(mLog, logID, 1, 2, 1, this.boundingBox, world); - place(mLog, logID, 1, 3, 1, this.boundingBox, world); - - place(mLog, logID, 1, 1, 5, this.boundingBox, world); - place(mLog, logID, 1, 2, 5, this.boundingBox, world); - place(mLog, logID, 1, 3, 5, this.boundingBox, world); - - place(mLog, logID, 7, 1, 1, this.boundingBox, world); - place(mLog, logID, 7, 2, 1, this.boundingBox, world); - place(mLog, logID, 7, 3, 1, this.boundingBox, world); - - place(mLog, logID, 7, 1, 5, this.boundingBox, world); - place(mLog, logID, 7, 2, 5, this.boundingBox, world); - place(mLog, logID, 7, 3, 5, this.boundingBox, world); - - int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; - - place(mLog, logID, 1, 4, 2, this.boundingBox, world); - place(mLog, logID, 1, 4, 3, this.boundingBox, world); - place(mLog, logID, 1, 4, 4, this.boundingBox, world); - place(mLog, logID, 7, 4, 2, this.boundingBox, world); - place(mLog, logID, 7, 4, 3, this.boundingBox, world); - place(mLog, logID, 7, 4, 4, this.boundingBox, world); - - for (int x = 0; x < 9; x++) { - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 3, 0, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 4, 1, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 5, 2, this.boundingBox, world); - place(Blocks.planks, mWoodType, x, 5, 3, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 5, 4, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 4, 5, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 3, 6, this.boundingBox, world); - } - - int glassMeta = Math.min(16, (coordBaseMode+MathUtils.randInt(0, 8))); - - place(Blocks.stained_glass_pane, glassMeta, 3, 2, 1, this.boundingBox, world); - place(Blocks.stained_glass_pane, glassMeta, 3, 2, 5, this.boundingBox, world); - place(Blocks.stained_glass_pane, glassMeta, 5, 2, 5, this.boundingBox, world); - place(Blocks.stained_glass_pane, glassMeta, 1, 2, 3, this.boundingBox, world); - place(Blocks.stained_glass_pane, glassMeta, 7, 2, 3, this.boundingBox, world); - - placeDoorAtCurrentPosition(world, this.boundingBox, random, 5, 1, 1, - getMetadataWithOffset(Blocks.wooden_door, 1)); - - place(Blocks.redstone_lamp, mWoodType, 2, 1, 4, this.boundingBox, world); - place(Blocks.redstone_torch, 0, 2, 2, 4, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 1), 2, 1, 3, this.boundingBox, world); - place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 3), 3, 1, 4, this.boundingBox, world); - place(Blocks.fence, 0, 3, 1, 3, this.boundingBox, world); - place(Blocks.heavy_weighted_pressure_plate, 0, 3, 2, 3, this.boundingBox, world); - if (!this.hasMadeChest) { - int ic = getYWithOffset(0); - int jc = getXWithOffset(7, 1); - int kc = getZWithOffset(7, 1); - if (this.boundingBox.isVecInside(jc, ic, kc)) { - this.hasMadeChest = true; - generateStructureChestContents(world, this.boundingBox, random, 2, 1, 2, shackChestContents, - 1 + random.nextInt(3)); - } - } - for (int i = 0; i < 9; i++) { - for (int j = 0; j < 9; j++) { - clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); - func_151554_b(world, undergroundID, 0, j, 0, i, this.boundingBox); - } - } - spawnNatives(world, this.boundingBox, 3, 2, 3, MathUtils.randInt(3, 5)); - - return true; - } - - private int nativesSpawned = 0; - - private void spawnNatives(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, - int par5, int maxSpawned) { - if (this.nativesSpawned < maxSpawned) { - for (int i1 = this.nativesSpawned; i1 < maxSpawned; i1++) { - int j1 = getXWithOffset(par3 + i1, par5); - int k1 = getYWithOffset(par4); - int l1 = getZWithOffset(par3 + i1, par5); - if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) { - break; - } - if (par1World.rand.nextInt(MathUtils.randInt(1, 3)) != 0) { - EntityVillager entityvillager = new EntityVillager(par1World, 7736+(MathUtils.randInt(0, 1))); - entityvillager.func_110163_bv(); - entityvillager.setLocationAndAngles(j1 + 0.5D, k1, l1 + 0.5D, 0.0F, 0.0F); - par1World.spawnEntityInWorld(entityvillager); - this.nativesSpawned += 1; - } - } - } - } - - //Min, max, Weight - public static final WeightedRandomChestContent[] shackChestContents = { - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("dustIron", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 9), 50), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 6), 50), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("dustTin", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 6), 50), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("dustGold", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 3), 30), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 3), 30), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", MathUtils.randInt(1, 2)), 0, MathUtils.randInt(1, 2), 5), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("gemEmerald", MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("gemRuby", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 4), 15), - new WeightedRandomChestContent(ItemUtils.getItemStackOfAmountFromOreDict("gemSapphire", MathUtils.randInt(1, 4)), 0, MathUtils.randInt(1, 4), 15), - new WeightedRandomChestContent(ItemUtils.getSimpleStack(CI.electricMotor_LV, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), - new WeightedRandomChestContent(ItemUtils.getSimpleStack(CI.electricPiston_LV, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), - new WeightedRandomChestContent(ItemUtils.getSimpleStack(CI.robotArm_LV, MathUtils.randInt(1, 2)), 0, MathUtils.randInt(1, 2), 2), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, Materials.Copper, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 25), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, Materials.Tin, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 25), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.wireGt01, Materials.Copper, MathUtils.randInt(2, 5)), 0, MathUtils.randInt(2, 5), 35), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.wireGt01, Materials.Tin, MathUtils.randInt(2, 5)), 0, MathUtils.randInt(2, 5), 35), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.pipeSmall, Materials.Copper, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 25), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.pipeSmall, Materials.Bronze, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 15), - new WeightedRandomChestContent(ItemUtils.getGregtechOreStack(OrePrefixes.pipeTiny, Materials.Steel, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), - }; - - private boolean hasMadeChest; - private static final String CHEST_KEY = "AUSShackChest"; - - protected void func_143012_a(NBTTagCompound par1NBTTagCompound) { - super.func_143012_a(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("AUSShackChest", this.hasMadeChest); - par1NBTTagCompound.setInteger("AUSWCount", this.nativesSpawned); - } - - protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { - super.func_143011_b(par1NBTTagCompound); - this.hasMadeChest = par1NBTTagCompound.getBoolean("AUSShackChest"); - if (par1NBTTagCompound.hasKey("AUSWCount")) { - this.nativesSpawned = par1NBTTagCompound.getInteger("AUSWCount"); - } else { - this.nativesSpawned = 0; - } - } - - public static class WorldHandlerShack implements IGeneratorWorld { - private final double chance; - private final int range; - - public WorldHandlerShack(double chance) { - this.chance = chance; - this.range = 400; - } - - public int getExtentX() { - return 7; - } - - public int getExtentZ() { - return 7; - } - - public int getRange() { - return this.range; - } - - public boolean generate(World world, Random random, int x, int z) { - if ((MathUtils.randInt(0, 100) < (this.chance/5))) { - int direction = MathUtils.randInt(0, 3); - new ComponentShack(direction, random, x, z).addComponentParts(world, random); - Logger.WORLD("NativeShack x: " + x + " | z: " + z + " | dir: " + direction); - return true; - } - return false; - } - - public void initiate() { - } - } + public static final int DIM_X = 9; + public static final int DIM_Y = 10; + public static final int DIM_Z = 9; + + public ComponentShack() {} + + public ComponentShack(int direction, Random random, int x, int z) { + super(direction, random, x, z, DIM_X, DIM_Y, DIM_Z); + } + + public boolean addComponentParts(World world, Random random) { + BiomeGenBase biom = world.getBiomeGenForCoords(getXWithOffset(0, 0), getZWithOffset(0, 0)); + int groundAvg = calcGroundHeight(world, this.boundingBox); + if (groundAvg < 0) { + return true; + } + this.boundingBox.offset(0, groundAvg - this.boundingBox.maxY + 10 - 1, 0); + if ((isWaterBelow(world, 0, -1, 0, this.boundingBox)) + || (isWaterBelow(world, 0, -1, 6, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 0, this.boundingBox)) + || (isWaterBelow(world, 6, -1, 6, this.boundingBox))) { + return false; + } + Block mStone; + Block groundID = Blocks.grass; + Block undergroundID = Blocks.dirt; + if (biom.biomeID == GTplusplus_Australia.Australian_Desert_Biome_3.biomeID) { + groundID = Blocks.sand; + undergroundID = Blocks.sand; + mStone = Blocks.sandstone; + } else if (biom.biomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { + groundID = Blocks.hardened_clay; + undergroundID = Blocks.stained_hardened_clay; + mStone = Blocks.stained_hardened_clay; + } else { + mStone = Blocks.stonebrick; + } + + int mWoodType = MathUtils.randInt(0, 5); + int logID; + Block mWoodenStairs; + Block mLog; + if (mWoodType == 1) { + mWoodenStairs = Blocks.spruce_stairs; + logID = 1; + } else if (mWoodType == 2) { + mWoodenStairs = Blocks.birch_stairs; + logID = 2; + + } else if (mWoodType == 3) { + mWoodenStairs = Blocks.jungle_stairs; + logID = 3; + } else if (mWoodType == 4) { + mWoodenStairs = Blocks.acacia_stairs; + logID = 0; + } else if (mWoodType == 5) { + mWoodenStairs = Blocks.dark_oak_stairs; + logID = 1; + } else { + mWoodenStairs = Blocks.oak_stairs; + logID = 0; + } + if (mWoodType >= 4) { + mLog = Blocks.log2; + } else { + mLog = Blocks.log; + } + + int mStoneMeta = + MathUtils.randInt(0, mStone == Blocks.stained_hardened_clay ? 15 : mStone == Blocks.sandstone ? 2 : 3); + + fillWithAir(world, this.boundingBox, 0, 1, 0, 7, 7, 4); + fillWithMetadataBlocks( + world, this.boundingBox, 1, 0, 1, 7, 1, 5, mStone, mStoneMeta, mStone, mStoneMeta, false); + fillWithMetadataBlocks( + world, this.boundingBox, 1, 2, 1, 7, 3, 5, Blocks.planks, mWoodType, Blocks.planks, mWoodType, false); + fillWithAir(world, this.boundingBox, 2, 1, 2, 6, 3, 4); + + place(mLog, logID, 1, 1, 1, this.boundingBox, world); + place(mLog, logID, 1, 2, 1, this.boundingBox, world); + place(mLog, logID, 1, 3, 1, this.boundingBox, world); + + place(mLog, logID, 1, 1, 5, this.boundingBox, world); + place(mLog, logID, 1, 2, 5, this.boundingBox, world); + place(mLog, logID, 1, 3, 5, this.boundingBox, world); + + place(mLog, logID, 7, 1, 1, this.boundingBox, world); + place(mLog, logID, 7, 2, 1, this.boundingBox, world); + place(mLog, logID, 7, 3, 1, this.boundingBox, world); + + place(mLog, logID, 7, 1, 5, this.boundingBox, world); + place(mLog, logID, 7, 2, 5, this.boundingBox, world); + place(mLog, logID, 7, 3, 5, this.boundingBox, world); + + int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; + + place(mLog, logID, 1, 4, 2, this.boundingBox, world); + place(mLog, logID, 1, 4, 3, this.boundingBox, world); + place(mLog, logID, 1, 4, 4, this.boundingBox, world); + place(mLog, logID, 7, 4, 2, this.boundingBox, world); + place(mLog, logID, 7, 4, 3, this.boundingBox, world); + place(mLog, logID, 7, 4, 4, this.boundingBox, world); + + for (int x = 0; x < 9; x++) { + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 3, 0, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 4, 1, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 3), x, 5, 2, this.boundingBox, world); + place(Blocks.planks, mWoodType, x, 5, 3, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 5, 4, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 4, 5, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(Blocks.oak_stairs, 2), x, 3, 6, this.boundingBox, world); + } + + int glassMeta = Math.min(16, (coordBaseMode + MathUtils.randInt(0, 8))); + + place(Blocks.stained_glass_pane, glassMeta, 3, 2, 1, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 3, 2, 5, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 5, 2, 5, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 1, 2, 3, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 7, 2, 3, this.boundingBox, world); + + placeDoorAtCurrentPosition( + world, this.boundingBox, random, 5, 1, 1, getMetadataWithOffset(Blocks.wooden_door, 1)); + + place(Blocks.redstone_lamp, mWoodType, 2, 1, 4, this.boundingBox, world); + place(Blocks.redstone_torch, 0, 2, 2, 4, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 1), 2, 1, 3, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 3), 3, 1, 4, this.boundingBox, world); + place(Blocks.fence, 0, 3, 1, 3, this.boundingBox, world); + place(Blocks.heavy_weighted_pressure_plate, 0, 3, 2, 3, this.boundingBox, world); + if (!this.hasMadeChest) { + int ic = getYWithOffset(0); + int jc = getXWithOffset(7, 1); + int kc = getZWithOffset(7, 1); + if (this.boundingBox.isVecInside(jc, ic, kc)) { + this.hasMadeChest = true; + generateStructureChestContents( + world, this.boundingBox, random, 2, 1, 2, shackChestContents, 1 + random.nextInt(3)); + } + } + for (int i = 0; i < 9; i++) { + for (int j = 0; j < 9; j++) { + clearCurrentPositionBlocksUpwards(world, j, 6, i, this.boundingBox); + func_151554_b(world, undergroundID, 0, j, 0, i, this.boundingBox); + } + } + spawnNatives(world, this.boundingBox, 3, 2, 3, MathUtils.randInt(3, 5)); + + return true; + } + + private int nativesSpawned = 0; + + private void spawnNatives( + World par1World, + StructureBoundingBox par2StructureBoundingBox, + int par3, + int par4, + int par5, + int maxSpawned) { + if (this.nativesSpawned < maxSpawned) { + for (int i1 = this.nativesSpawned; i1 < maxSpawned; i1++) { + int j1 = getXWithOffset(par3 + i1, par5); + int k1 = getYWithOffset(par4); + int l1 = getZWithOffset(par3 + i1, par5); + if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) { + break; + } + if (par1World.rand.nextInt(MathUtils.randInt(1, 3)) != 0) { + EntityVillager entityvillager = new EntityVillager(par1World, 7736 + (MathUtils.randInt(0, 1))); + entityvillager.func_110163_bv(); + entityvillager.setLocationAndAngles(j1 + 0.5D, k1, l1 + 0.5D, 0.0F, 0.0F); + par1World.spawnEntityInWorld(entityvillager); + this.nativesSpawned += 1; + } + } + } + } + + // Min, max, Weight + public static final WeightedRandomChestContent[] shackChestContents = { + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 9), + 50), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 6), + 50), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("dustTin", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 6), + 50), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("dustGold", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 3), + 30), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 3), + 30), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", MathUtils.randInt(1, 2)), + 0, + MathUtils.randInt(1, 2), + 5), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("gemEmerald", MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 5), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("gemRuby", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 4), + 15), + new WeightedRandomChestContent( + ItemUtils.getItemStackOfAmountFromOreDict("gemSapphire", MathUtils.randInt(1, 4)), + 0, + MathUtils.randInt(1, 4), + 15), + new WeightedRandomChestContent( + ItemUtils.getSimpleStack(CI.electricMotor_LV, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), + new WeightedRandomChestContent( + ItemUtils.getSimpleStack(CI.electricPiston_LV, MathUtils.randInt(1, 3)), 0, MathUtils.randInt(1, 3), 5), + new WeightedRandomChestContent( + ItemUtils.getSimpleStack(CI.robotArm_LV, MathUtils.randInt(1, 2)), 0, MathUtils.randInt(1, 2), 2), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, Materials.Copper, MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 25), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, Materials.Tin, MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 25), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.wireGt01, Materials.Copper, MathUtils.randInt(2, 5)), + 0, + MathUtils.randInt(2, 5), + 35), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.wireGt01, Materials.Tin, MathUtils.randInt(2, 5)), + 0, + MathUtils.randInt(2, 5), + 35), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.pipeSmall, Materials.Copper, MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 25), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.pipeSmall, Materials.Bronze, MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 15), + new WeightedRandomChestContent( + ItemUtils.getGregtechOreStack(OrePrefixes.pipeTiny, Materials.Steel, MathUtils.randInt(1, 3)), + 0, + MathUtils.randInt(1, 3), + 5), + }; + + private boolean hasMadeChest; + private static final String CHEST_KEY = "AUSShackChest"; + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("AUSShackChest", this.hasMadeChest); + par1NBTTagCompound.setInteger("AUSWCount", this.nativesSpawned); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { + super.func_143011_b(par1NBTTagCompound); + this.hasMadeChest = par1NBTTagCompound.getBoolean("AUSShackChest"); + if (par1NBTTagCompound.hasKey("AUSWCount")) { + this.nativesSpawned = par1NBTTagCompound.getInteger("AUSWCount"); + } else { + this.nativesSpawned = 0; + } + } + + public static class WorldHandlerShack implements IGeneratorWorld { + private final double chance; + private final int range; + + public WorldHandlerShack(double chance) { + this.chance = chance; + this.range = 400; + } + + public int getExtentX() { + return 7; + } + + public int getExtentZ() { + return 7; + } + + public int getRange() { + return this.range; + } + + public boolean generate(World world, Random random, int x, int z) { + if ((MathUtils.randInt(0, 100) < (this.chance / 5))) { + int direction = MathUtils.randInt(0, 3); + new ComponentShack(direction, random, x, z).addComponentParts(world, random); + Logger.WORLD("NativeShack x: " + x + " | z: " + z + " | dir: " + direction); + return true; + } + return false; + } + public void initiate() {} + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/map/structure/StructureManager.java b/src/main/java/gtPlusPlus/australia/gen/map/structure/StructureManager.java index b3238a5903..16d9034b5b 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/structure/StructureManager.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/structure/StructureManager.java @@ -7,14 +7,14 @@ import net.minecraft.world.gen.structure.MapGenStructureIO; public class StructureManager { - public static void registerVillageComponents() { - try { - //Register Village - MapGenStructureIO.registerStructure(MapGenExtendedVillage.Start.class, "ExtendedVillage"); - - //Register Structures within village - MapGenStructureIO.func_143031_a(ComponentVillageBank.class, CORE.MODID+":"+"Bank"); - } catch (Throwable e) {} - } - + public static void registerVillageComponents() { + try { + // Register Village + MapGenStructureIO.registerStructure(MapGenExtendedVillage.Start.class, "ExtendedVillage"); + + // Register Structures within village + MapGenStructureIO.func_143031_a(ComponentVillageBank.class, CORE.MODID + ":" + "Bank"); + } catch (Throwable e) { + } + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/map/structure/type/ComponentVillageBank.java b/src/main/java/gtPlusPlus/australia/gen/map/structure/type/ComponentVillageBank.java index 5b7017aaf0..b88c6bfda9 100644 --- a/src/main/java/gtPlusPlus/australia/gen/map/structure/type/ComponentVillageBank.java +++ b/src/main/java/gtPlusPlus/australia/gen/map/structure/type/ComponentVillageBank.java @@ -2,10 +2,9 @@ package gtPlusPlus.australia.gen.map.structure.type; import static net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH; +import gtPlusPlus.api.objects.Logger; import java.util.List; import java.util.Random; - -import gtPlusPlus.api.objects.Logger; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -21,155 +20,177 @@ import net.minecraftforge.common.ChestGenHooks; public class ComponentVillageBank extends House2 { - /** List of items that Village's Blacksmith chest can contain. */ - public static final WeightedRandomChestContent[] villageBlacksmithChestContents = new WeightedRandomChestContent[] { - new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), - new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), - new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), - new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), - new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), - new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_sword, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_chestplate, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_helmet, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_leggings, 0, 1, 1, 5), - new WeightedRandomChestContent(Items.iron_boots, 0, 1, 1, 5), - new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5), - new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 0, 3, 7, 5), - new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), - new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), - new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), - new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1) - }; - - private boolean hasMadeChest; - - public ComponentVillageBank() { - Logger.INFO("Created a Bank."); - } - - public ComponentVillageBank(StructureVillagePieces.Start aStart, int p_i2103_2_, Random aRand, - StructureBoundingBox aBox, int aCoordBaseMode) { - super(aStart, p_i2103_2_, aRand, aBox, aCoordBaseMode); - this.coordBaseMode = aCoordBaseMode; - this.boundingBox = aBox; - } - - public static StructureVillagePieces.House2 func_74915_a(StructureVillagePieces.Start p_74915_0_, List p_74915_1_, - Random p_74915_2_, int p_74915_3_, int p_74915_4_, int p_74915_5_, int p_74915_6_, int p_74915_7_) { - StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p_74915_3_, - p_74915_4_, p_74915_5_, 0, 0, 0, 10, 6, 7, p_74915_6_); - Logger.INFO("12334453"); - return canVillageGoDeeper(structureboundingbox) - && StructureComponent.findIntersecting(p_74915_1_, structureboundingbox) == null - ? new StructureVillagePieces.House2(p_74915_0_, p_74915_7_, p_74915_2_, structureboundingbox, - p_74915_6_) - : null; - } - - protected void func_143012_a(NBTTagCompound aNBT) { - super.func_143012_a(aNBT); - aNBT.setBoolean("Chest", this.hasMadeChest); - } - - protected void func_143011_b(NBTTagCompound aNBT) { - super.func_143011_b(aNBT); - this.hasMadeChest = aNBT.getBoolean("Chest"); - } - - /** - * 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 aWorld, Random aRand, StructureBoundingBox aBox) { - if (this.field_143015_k < 0) { - this.field_143015_k = this.getAverageGroundLevel(aWorld, aBox); - - if (this.field_143015_k < 0) { - return true; - } - - this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0); - } - - this.fillWithBlocks(aWorld, aBox, 0, 1, 0, 9, 4, 6, Blocks.air, Blocks.air, false); - this.fillWithBlocks(aWorld, aBox, 0, 0, 0, 9, 0, 6, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillWithBlocks(aWorld, aBox, 0, 4, 0, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillWithBlocks(aWorld, aBox, 0, 5, 0, 9, 5, 6, Blocks.stone_slab, Blocks.stone_slab, false); - this.fillWithBlocks(aWorld, aBox, 1, 5, 1, 8, 5, 5, Blocks.air, Blocks.air, false); - this.fillWithBlocks(aWorld, aBox, 1, 1, 0, 2, 3, 0, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(aWorld, aBox, 0, 1, 0, 0, 4, 0, Blocks.log, Blocks.log, false); - this.fillWithBlocks(aWorld, aBox, 3, 1, 0, 3, 4, 0, Blocks.log, Blocks.log, false); - this.fillWithBlocks(aWorld, aBox, 0, 1, 6, 0, 4, 6, Blocks.log, Blocks.log, false); - this.placeBlockAtCurrentPosition(aWorld, Blocks.planks, 0, 3, 3, 1, aBox); - this.fillWithBlocks(aWorld, aBox, 3, 1, 2, 3, 3, 2, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(aWorld, aBox, 4, 1, 3, 5, 3, 3, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(aWorld, aBox, 0, 1, 1, 0, 3, 5, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(aWorld, aBox, 1, 1, 6, 5, 3, 6, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(aWorld, aBox, 5, 1, 0, 5, 3, 0, Blocks.fence, Blocks.fence, false); - this.fillWithBlocks(aWorld, aBox, 9, 1, 0, 9, 3, 0, Blocks.fence, Blocks.fence, false); - this.fillWithBlocks(aWorld, aBox, 6, 1, 4, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); - this.placeBlockAtCurrentPosition(aWorld, Blocks.flowing_lava, 0, 7, 1, 5, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.flowing_lava, 0, 8, 1, 5, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.iron_bars, 0, 9, 2, 5, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.iron_bars, 0, 9, 2, 4, aBox); - this.fillWithBlocks(aWorld, aBox, 7, 2, 4, 8, 2, 5, Blocks.air, Blocks.air, false); - this.placeBlockAtCurrentPosition(aWorld, Blocks.cobblestone, 0, 6, 1, 3, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.furnace, 0, 6, 2, 3, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.furnace, 0, 6, 3, 3, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.double_stone_slab, 0, 8, 1, 1, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 0, 2, 2, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 0, 2, 4, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 2, 2, 6, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 4, 2, 6, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.fence, 0, 2, 1, 4, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.wooden_pressure_plate, 0, 2, 2, 4, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.planks, 0, 1, 1, 5, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.oak_stairs, - this.getMetadataWithOffset(Blocks.oak_stairs, 3), 2, 1, 5, aBox); - this.placeBlockAtCurrentPosition(aWorld, Blocks.oak_stairs, - this.getMetadataWithOffset(Blocks.oak_stairs, 1), 1, 1, 4, aBox); - int i; - int j; - - if (!this.hasMadeChest) { - i = this.getYWithOffset(1); - j = this.getXWithOffset(5, 5); - int k = this.getZWithOffset(5, 5); - - if (aBox.isVecInside(j, i, k)) { - this.hasMadeChest = true; - this.generateStructureChestContents(aWorld, aBox, aRand, 5, 1, 5, - ChestGenHooks.getItems(VILLAGE_BLACKSMITH, aRand), - ChestGenHooks.getCount(VILLAGE_BLACKSMITH, aRand)); - } - } - - for (i = 6; i <= 8; ++i) { - if (this.getBlockAtCurrentPosition(aWorld, i, 0, -1, aBox).getMaterial() == Material.air && this - .getBlockAtCurrentPosition(aWorld, i, -1, -1, aBox).getMaterial() != Material.air) { - this.placeBlockAtCurrentPosition(aWorld, Blocks.stone_stairs, - this.getMetadataWithOffset(Blocks.stone_stairs, 3), i, 0, -1, aBox); - } - } - - for (i = 0; i < 7; ++i) { - for (j = 0; j < 10; ++j) { - this.clearCurrentPositionBlocksUpwards(aWorld, j, 6, i, aBox); - this.func_151554_b(aWorld, Blocks.cobblestone, 0, j, -1, i, aBox); - } - } - - this.spawnVillagers(aWorld, aBox, 7, 1, 1, 1); - return true; - } - - /** - * Returns the villager type to spawn in this component, based on the number of - * villagers already spawned. - */ - protected int getVillagerType(int p_74888_1_) { - return 7735; - } - + /** List of items that Village's Blacksmith chest can contain. */ + public static final WeightedRandomChestContent[] villageBlacksmithChestContents = new WeightedRandomChestContent[] { + new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), + new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), + new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), + new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), + new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), + new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_sword, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_chestplate, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_helmet, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_leggings, 0, 1, 1, 5), + new WeightedRandomChestContent(Items.iron_boots, 0, 1, 1, 5), + new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5), + new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 0, 3, 7, 5), + new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), + new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), + new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), + new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1) + }; + + private boolean hasMadeChest; + + public ComponentVillageBank() { + Logger.INFO("Created a Bank."); + } + + public ComponentVillageBank( + StructureVillagePieces.Start aStart, + int p_i2103_2_, + Random aRand, + StructureBoundingBox aBox, + int aCoordBaseMode) { + super(aStart, p_i2103_2_, aRand, aBox, aCoordBaseMode); + this.coordBaseMode = aCoordBaseMode; + this.boundingBox = aBox; + } + + public static StructureVillagePieces.House2 func_74915_a( + StructureVillagePieces.Start p_74915_0_, + List p_74915_1_, + Random p_74915_2_, + int p_74915_3_, + int p_74915_4_, + int p_74915_5_, + int p_74915_6_, + int p_74915_7_) { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox( + p_74915_3_, p_74915_4_, p_74915_5_, 0, 0, 0, 10, 6, 7, p_74915_6_); + Logger.INFO("12334453"); + return canVillageGoDeeper(structureboundingbox) + && StructureComponent.findIntersecting(p_74915_1_, structureboundingbox) == null + ? new StructureVillagePieces.House2( + p_74915_0_, p_74915_7_, p_74915_2_, structureboundingbox, p_74915_6_) + : null; + } + + protected void func_143012_a(NBTTagCompound aNBT) { + super.func_143012_a(aNBT); + aNBT.setBoolean("Chest", this.hasMadeChest); + } + + protected void func_143011_b(NBTTagCompound aNBT) { + super.func_143011_b(aNBT); + this.hasMadeChest = aNBT.getBoolean("Chest"); + } + + /** + * 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 aWorld, Random aRand, StructureBoundingBox aBox) { + if (this.field_143015_k < 0) { + this.field_143015_k = this.getAverageGroundLevel(aWorld, aBox); + + if (this.field_143015_k < 0) { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0); + } + + this.fillWithBlocks(aWorld, aBox, 0, 1, 0, 9, 4, 6, Blocks.air, Blocks.air, false); + this.fillWithBlocks(aWorld, aBox, 0, 0, 0, 9, 0, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(aWorld, aBox, 0, 4, 0, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(aWorld, aBox, 0, 5, 0, 9, 5, 6, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(aWorld, aBox, 1, 5, 1, 8, 5, 5, Blocks.air, Blocks.air, false); + this.fillWithBlocks(aWorld, aBox, 1, 1, 0, 2, 3, 0, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(aWorld, aBox, 0, 1, 0, 0, 4, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(aWorld, aBox, 3, 1, 0, 3, 4, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(aWorld, aBox, 0, 1, 6, 0, 4, 6, Blocks.log, Blocks.log, false); + this.placeBlockAtCurrentPosition(aWorld, Blocks.planks, 0, 3, 3, 1, aBox); + this.fillWithBlocks(aWorld, aBox, 3, 1, 2, 3, 3, 2, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(aWorld, aBox, 4, 1, 3, 5, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(aWorld, aBox, 0, 1, 1, 0, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(aWorld, aBox, 1, 1, 6, 5, 3, 6, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(aWorld, aBox, 5, 1, 0, 5, 3, 0, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(aWorld, aBox, 9, 1, 0, 9, 3, 0, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(aWorld, aBox, 6, 1, 4, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.placeBlockAtCurrentPosition(aWorld, Blocks.flowing_lava, 0, 7, 1, 5, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.flowing_lava, 0, 8, 1, 5, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.iron_bars, 0, 9, 2, 5, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.iron_bars, 0, 9, 2, 4, aBox); + this.fillWithBlocks(aWorld, aBox, 7, 2, 4, 8, 2, 5, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(aWorld, Blocks.cobblestone, 0, 6, 1, 3, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.furnace, 0, 6, 2, 3, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.furnace, 0, 6, 3, 3, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.double_stone_slab, 0, 8, 1, 1, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 0, 2, 2, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 0, 2, 4, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 2, 2, 6, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.glass_pane, 0, 4, 2, 6, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.fence, 0, 2, 1, 4, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.wooden_pressure_plate, 0, 2, 2, 4, aBox); + this.placeBlockAtCurrentPosition(aWorld, Blocks.planks, 0, 1, 1, 5, aBox); + this.placeBlockAtCurrentPosition( + aWorld, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 3), 2, 1, 5, aBox); + this.placeBlockAtCurrentPosition( + aWorld, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 1), 1, 1, 4, aBox); + int i; + int j; + + if (!this.hasMadeChest) { + i = this.getYWithOffset(1); + j = this.getXWithOffset(5, 5); + int k = this.getZWithOffset(5, 5); + + if (aBox.isVecInside(j, i, k)) { + this.hasMadeChest = true; + this.generateStructureChestContents( + aWorld, + aBox, + aRand, + 5, + 1, + 5, + ChestGenHooks.getItems(VILLAGE_BLACKSMITH, aRand), + ChestGenHooks.getCount(VILLAGE_BLACKSMITH, aRand)); + } + } + + for (i = 6; i <= 8; ++i) { + if (this.getBlockAtCurrentPosition(aWorld, i, 0, -1, aBox).getMaterial() == Material.air + && this.getBlockAtCurrentPosition(aWorld, i, -1, -1, aBox).getMaterial() != Material.air) { + this.placeBlockAtCurrentPosition( + aWorld, + Blocks.stone_stairs, + this.getMetadataWithOffset(Blocks.stone_stairs, 3), + i, + 0, + -1, + aBox); + } + } + + for (i = 0; i < 7; ++i) { + for (j = 0; j < 10; ++j) { + this.clearCurrentPositionBlocksUpwards(aWorld, j, 6, i, aBox); + this.func_151554_b(aWorld, Blocks.cobblestone, 0, j, -1, i, aBox); + } + } + + this.spawnVillagers(aWorld, aBox, 7, 1, 1, 1); + return true; + } + + /** + * Returns the villager type to spawn in this component, based on the number of + * villagers already spawned. + */ + protected int getVillagerType(int p_74888_1_) { + return 7735; + } } |