diff options
Diffstat (limited to 'src/Java/gtPlusPlus/australia/gen/map')
5 files changed, 712 insertions, 21 deletions
diff --git a/src/Java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java b/src/Java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java index ef49155dad..4455c81317 100644 --- a/src/Java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java +++ b/src/Java/gtPlusPlus/australia/gen/map/MapGenLargeRavine.java @@ -4,8 +4,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Random; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; @@ -17,27 +15,28 @@ 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 p_151540_15_, int p_151540_16_, double p_151540_17_) + 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_) { - Logger.INFO("Generating Large Ravine."); - Random random = new XSTR(aSeed); - double d4 = (double)(var1 * 32 + 16); - double d5 = (double)(var2 * 32 + 16); + //Logger.INFO("Generating Large Ravine."); + Random random = CORE.RANDOM; + this.range *= 2; + double d4 = (double)(var1 * 24 + 16); + double d5 = (double)(var2 * 24 + 16); float f3 = 0.0F; float f4 = 0.0F; - if (p_151540_16_ <= 0) + if (possibleMaxY <= 25) { - int j1 = this.range * 16 - 16; - p_151540_16_ = j1 - random.nextInt(j1 / 4); + int j1 = Math.min(this.range * 16 - 32, 200); + possibleMaxY = j1 - random.nextInt(j1 / 4); } - boolean flag1 = false; + boolean possibleIsUnderGroundFlag = false; - if (p_151540_15_ == -1) + if (possibleCurrentY <= -1) { - p_151540_15_ = p_151540_16_ / 2; - flag1 = true; + possibleCurrentY = possibleMaxY / 3; + possibleIsUnderGroundFlag = true; } float f5 = 1.0F; @@ -52,9 +51,9 @@ public class MapGenLargeRavine extends MapGenRavine this.field_75046_d[k1] = f5 * f5; } - for (; p_151540_15_ < p_151540_16_; ++p_151540_15_) + for (; possibleCurrentY < possibleMaxY; ++possibleCurrentY) { - double d12 = 3.5D + (double)(MathHelper.sin((float)p_151540_15_ * CORE.PI / (float)p_151540_16_) * p_151540_12_ * 1.0F); + 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; @@ -71,11 +70,11 @@ public class MapGenLargeRavine extends MapGenRavine f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; - if (flag1 || random.nextInt(4) != 0) + if (possibleIsUnderGroundFlag || random.nextInt(4) != 0) { double d7 = p_151540_6_ - d4; double d8 = p_151540_10_ - d5; - double d9 = (double)(p_151540_16_ - p_151540_15_); + double d9 = (double)(possibleMaxY - possibleCurrentY); double d10 = (double)(p_151540_12_ + 2.0F + 16.0F); if (d7 * d7 + d8 * d8 - d9 * d9 > d10 * d10) @@ -188,7 +187,7 @@ public class MapGenLargeRavine extends MapGenRavine } } - if (flag1) + if (possibleIsUnderGroundFlag) { break; } diff --git a/src/Java/gtPlusPlus/australia/gen/map/MapGenVillageLogging.java b/src/Java/gtPlusPlus/australia/gen/map/MapGenVillageLogging.java index fd5c8df5b2..69278591fe 100644 --- a/src/Java/gtPlusPlus/australia/gen/map/MapGenVillageLogging.java +++ b/src/Java/gtPlusPlus/australia/gen/map/MapGenVillageLogging.java @@ -2,6 +2,8 @@ package gtPlusPlus.australia.gen.map; import java.util.Map; import java.util.Random; + +import gtPlusPlus.api.objects.Logger; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.gen.structure.MapGenVillage; @@ -24,12 +26,16 @@ public class MapGenVillageLogging extends MapGenVillage { @Override protected boolean canSpawnStructureAtCoords(int p_75047_1_, int p_75047_2_) { - - return super.canSpawnStructureAtCoords(p_75047_1_, p_75047_2_); + boolean aBool = super.canSpawnStructureAtCoords(p_75047_1_, p_75047_2_); + if (aBool) { + Logger.INFO("Is Location Valid for Spawning a Village? "+aBool); + } + return aBool; } @Override protected StructureStart getStructureStart(int p_75049_1_, int p_75049_2_) { + Logger.INFO("Created MapGenVillageLogging Start Object"); return new MapGenVillageLogging.Start(this.worldObj, this.rand, p_75049_1_, p_75049_2_, 0); } @@ -39,10 +45,13 @@ public class MapGenVillageLogging extends MapGenVillage { private static final String __OBFID = "CL_00000515"; public StartLogging() { + super(); + Logger.INFO("Created StartLogging Object"); } public StartLogging(World p_i2092_1_, Random p_i2092_2_, int p_i2092_3_, int p_i2092_4_, int p_i2092_5_) { super(p_i2092_1_, p_i2092_2_, p_i2092_3_, p_i2092_4_, p_i2092_5_); + Logger.INFO("Created StartLogging Object"); } /** diff --git a/src/Java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java b/src/Java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java new file mode 100644 index 0000000000..b6b83d997b --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/map/component/AustraliaComponent.java @@ -0,0 +1,196 @@ +package gtPlusPlus.australia.gen.map.component; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +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; + } +} diff --git a/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java new file mode 100644 index 0000000000..de90a91fb1 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java @@ -0,0 +1,223 @@ +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 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; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +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 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 = 0; x < MathUtils.randInt(5, 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) { + EntityVillager entityvillager = new EntityVillager(par1World, 7738); + 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/Java/gtPlusPlus/australia/gen/map/component/ComponentShack.java b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentShack.java new file mode 100644 index 0000000000..0bc4249d89 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentShack.java @@ -0,0 +1,264 @@ +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 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; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.StructureBoundingBox; + +public class ComponentShack extends AustraliaComponent { + public static final int DIM_X = 7; + public static final int DIM_Y = 10; + public static final int DIM_Z = 7; + + public ComponentShack() { + } + + public ComponentShack(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 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, 6, 9, 6); + fillWithMetadataBlocks(world, this.boundingBox, 0, 0, 1, 6, 1, 5, mStone, mStoneMeta, mStone, mStoneMeta, false); + fillWithMetadataBlocks(world, this.boundingBox, 0, 2, 1, 6, 3, 5, Blocks.planks, mWoodType, Blocks.planks, mWoodType, false); + fillWithAir(world, this.boundingBox, 1, 1, 2, 5, 3, 4); + + place(mLog, logID, 0, 1, 1, this.boundingBox, world); + place(mLog, logID, 0, 2, 1, this.boundingBox, world); + place(mLog, logID, 0, 3, 1, this.boundingBox, world); + + place(mLog, logID, 0, 1, 5, this.boundingBox, world); + place(mLog, logID, 0, 2, 5, this.boundingBox, world); + place(mLog, logID, 0, 3, 5, this.boundingBox, world); + + place(mLog, logID, 6, 1, 1, this.boundingBox, world); + place(mLog, logID, 6, 2, 1, this.boundingBox, world); + place(mLog, logID, 6, 3, 1, this.boundingBox, world); + + place(mLog, logID, 6, 1, 5, this.boundingBox, world); + place(mLog, logID, 6, 2, 5, this.boundingBox, world); + place(mLog, logID, 6, 3, 5, this.boundingBox, world); + + int meta = (this.coordBaseMode == 3) || (this.coordBaseMode == 1) ? 4 : 8; + + place(mLog, logID, 0, 4, 2, this.boundingBox, world); + place(mLog, logID, 0, 4, 3, this.boundingBox, world); + place(mLog, logID, 0, 4, 4, this.boundingBox, world); + place(mLog, logID, 6, 4, 2, this.boundingBox, world); + place(mLog, logID, 6, 4, 3, this.boundingBox, world); + place(mLog, logID, 6, 4, 4, this.boundingBox, world); + + for (int x = 0; x < 7; 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, 2, 2, 1, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 2, 2, 5, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 4, 2, 5, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 0, 2, 3, this.boundingBox, world); + place(Blocks.stained_glass_pane, glassMeta, 6, 2, 3, this.boundingBox, world); + + placeDoorAtCurrentPosition(world, this.boundingBox, random, 4, 1, 1, + getMetadataWithOffset(Blocks.wooden_door, 1)); + + place(Blocks.planks, mWoodType, 1, 1, 4, this.boundingBox, world); + place(Blocks.torch, 0, 1, 2, 4, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 1), 1, 1, 3, this.boundingBox, world); + place(mWoodenStairs, getMetadataWithOffset(mWoodenStairs, 3), 2, 1, 4, this.boundingBox, world); + place(Blocks.fence, 0, 2, 1, 3, this.boundingBox, world); + place(Blocks.stone_pressure_plate, 0, 2, 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, 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(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; + } + } + } + } + + 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 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("NativeHut x: " + x + " | z: " + z + " | Dir: " + direction); + return true; + } + return false; + } + + public void initiate() { + } + } + +} |