From b5c4f19ca0b53b8e3c01cf9222583eee1f573cc4 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 12 Jan 2014 15:45:11 +1100 Subject: [PATCH] Readded the silk glades. 1 left. --- .../common/biomes/BiomeGenSilkglades.java | 234 +++++++++--------- .../biomesoplenty/common/core/BOPBiomes.java | 5 +- .../world/decoration/BOPWorldFeatures.java | 2 + .../world/features/WorldGenBOPFlora.java | 8 +- .../world/features/WorldGenCobwebNest.java | 81 ++++++ .../generation/WorldGenFieldAssociation.java | 3 + 6 files changed, 208 insertions(+), 125 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/world/features/WorldGenCobwebNest.java diff --git a/src/main/java/biomesoplenty/common/biomes/BiomeGenSilkglades.java b/src/main/java/biomesoplenty/common/biomes/BiomeGenSilkglades.java index 61d321561..99ce87122 100644 --- a/src/main/java/biomesoplenty/common/biomes/BiomeGenSilkglades.java +++ b/src/main/java/biomesoplenty/common/biomes/BiomeGenSilkglades.java @@ -1,145 +1,137 @@ package biomesoplenty.common.biomes; -import net.minecraft.world.biome.BiomeGenBase; +import java.util.HashMap; +import java.util.Random; + +import biomesoplenty.api.BOPBlockHelper; +import biomesoplenty.common.configuration.BOPConfigurationMisc; +import biomesoplenty.common.world.features.WorldGenBOPTallGrass; +import biomesoplenty.common.world.features.trees.WorldGenBOPSwampTree; +import biomesoplenty.common.world.features.trees.WorldGenDeadTree1; +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase.Height; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenerator; public class BiomeGenSilkglades extends BOPBiome { + private static final Height biomeHeight = new Height(0.3F, 0.3F); - public BiomeGenSilkglades(int par1) - { - super(par1); - /* - customBiomeDecorator.treesPerChunk = 6; - customBiomeDecorator.grassPerChunk = 2; - customBiomeDecorator.wheatGrassPerChunk = 1; - customBiomeDecorator.mushroomsPerChunk = 4; - customBiomeDecorator.flowersPerChunk = -999; - customBiomeDecorator.reedsPerChunk = -999; - customBiomeDecorator.sandPerChunk = -999; - customBiomeDecorator.sandPerChunk2 = -999; - customBiomeDecorator.gravelPerChunk = 3; - customBiomeDecorator.gravelPerChunk2 = 3; - customBiomeDecorator.sproutsPerChunk = 2; - customBiomeDecorator.poisonIvyPerChunk = 2; - customBiomeDecorator.cobwebsPerChunk = 9; - customBiomeDecorator.waterReedsPerChunk = 4; - customBiomeDecorator.koruPerChunk = 1; - customBiomeDecorator.generatePumpkins = true; - waterColorMultiplier = 16777079; - spawnableWaterCreatureList.clear(); - spawnableCreatureList.clear(); - spawnableCreatureList.add(new SpawnListEntry(EntitySpider.class, 7, 1, 2)); - */ - } + public BiomeGenSilkglades(int id) + { + super(id); + + //TODO: setHeight() + this.func_150570_a(biomeHeight); + //TODO: setColor() + this.setColor(13420973); + this.setTemperatureRainfall(0.5F, 0.9F); - /** - * Gets a WorldGen appropriate for this biome. - */ - /* - @Override - public WorldGenerator getRandomWorldGenForTrees(Random par1Random) - { - return par1Random.nextInt(5) == 0 ? new WorldGenBirchWillow() : (par1Random.nextInt(7) == 0 ? new WorldGenDeadTree(false) : (par1Random.nextInt(12) == 0 ? new WorldGenCobwebNest(0,0) : new WorldGenWillow())); - } - */ - - /** - * Gets a WorldGen appropriate for this biome. - */ - /* - @Override - public WorldGenerator getRandomWorldGenForGrass(Random par1Random) - { - return new WorldGenTallGrass(Block.tallGrass.blockID, 0); - } + this.spawnableWaterCreatureList.clear(); + this.spawnableCreatureList.clear(); - @Override - public void decorate(World par1World, Random par2Random, int par3, int par4) - { - super.decorate(par1World, par2Random, par3, par4); - int var5 = 12 + par2Random.nextInt(6); + this.spawnableCreatureList.add(new SpawnListEntry(EntitySpider.class, 7, 1, 2)); - for (int var6 = 0; var6 < var5; ++var6) - { - int var7 = par3 + par2Random.nextInt(16); - int var8 = par2Random.nextInt(28) + 4; - int var9 = par4 + par2Random.nextInt(16); - int var10 = par1World.getBlockId(var7, var8, var9); + this.waterColorMultiplier = 16777079; - Block block = Block.blocksList[var10]; - if (block != null && block.isGenMineableReplaceable(par1World, var7, var8, var9, Block.stone.blockID)) - { - par1World.setBlock(var7, var8, var9, Blocks.amethystOre.get().blockID, 10, 2); - } - } - } - */ + this.theBiomeDecorator.treesPerChunk = 6; + this.theBiomeDecorator.grassPerChunk = 2; + this.theBiomeDecorator.mushroomsPerChunk = 4; + this.theBiomeDecorator.flowersPerChunk = -999; + this.theBiomeDecorator.reedsPerChunk = -999; + this.theBiomeDecorator.sandPerChunk = -999; + this.theBiomeDecorator.sandPerChunk2 = -999; - /** - * Provides the basic grass color based on the biome temperature and rainfall - */ - /* - @Override - public int getBiomeGrassColor() - { - return 13420973; - } - */ + this.bopWorldFeatures.sproutsPerChunk = 2; + this.bopWorldFeatures.poisonIvyPerChunk = 2; + this.bopWorldFeatures.cobwebsPerChunk = 9; + this.bopWorldFeatures.waterReedsPerChunk = 4; + this.bopWorldFeatures.koruPerChunk = 1; + this.bopWorldFeatures.generatePumpkins = true; + this.bopWorldFeatures.cobwebNestsPerChunk = 2; + } - /** - * Provides the basic foliage color based on the biome temperature and rainfall - */ - /* - @Override - public int getBiomeFoliageColor() - { - return 14146486; - } - */ - - /** - * Fog Color - */ - /* + @Override + //TODO: getRandomWorldGenForTrees() + public WorldGenAbstractTree func_150567_a(Random random) + { + return random.nextInt(5) == 0 ? new WorldGenBOPSwampTree(Blocks.log, BOPBlockHelper.get("leaves2"), 0, 0, 6, 9, BOPBlockHelper.get("leaves2"), 0) : + (random.nextInt(7) == 0 ? new WorldGenDeadTree1(false, Blocks.dirt, Blocks.grass, BOPBlockHelper.get("driedDirt"), BOPBlockHelper.get("mud")) : + new WorldGenBOPSwampTree(BOPBlockHelper.get("logs3"), BOPBlockHelper.get("colorizedLeaves2"), 1, 0, 6, 9, BOPBlockHelper.get("colorizedLeaves2"), 0)); + } + + @Override + public HashMap getWeightedWorldGenForGrass() + { + HashMap grassMap = new HashMap(); + + grassMap.put(new WorldGenBOPTallGrass(BOPBlockHelper.get("foliage"), 10), 0.5D); + grassMap.put(new WorldGenBOPTallGrass(BOPBlockHelper.get("foliage"), 11), 0.5D); + grassMap.put(new WorldGenBOPTallGrass(Blocks.tallgrass, 0), 1D); + + return grassMap; + } + + @Override + public void decorate(World world, Random random, int chunkX, int chunkZ) + { + super.decorate(world, random, chunkX, chunkZ); + int var5 = 12 + random.nextInt(6); + + for (int var6 = 0; var6 < var5; ++var6) + { + int x = chunkX + random.nextInt(16); + int y = random.nextInt(28) + 4; + int z = chunkZ + random.nextInt(16); + + //TODO: getBlock() + Block block = world.func_147439_a(x, y, z); + + if (block != null && block.isReplaceableOreGen(world, x, y, z, Blocks.stone)) + { + //TODO: setBlock() + world.func_147465_d(x, y, z, BOPBlockHelper.get("gemOre"), 10, 2); + } + } + } + + @Override + //TODO: getBiomeGrassColor() + public int func_150558_b(int x, int y, int z) + { + return 13420973; + } + + @Override + //TODO: getBiomeFoliageColor() + public int func_150571_c(int x, int y, int z) + { + return 14146486; + } + + + @Override + public int getSkyColorByTemp(float par1) + { + if (BOPConfigurationMisc.skyColors) return 13553096; + else return super.getSkyColorByTemp(par1); + } + + /* @Override public int getFogColour() { return 10062450; } - + @Override public float getFogCloseness() { // TODO Auto-generated method stub return 0.8F; } - */ - - /** - * takes temperature, returns color - */ - /* - @Override - public int getSkyColorByTemp(float par1) - { - if (BOPConfigurationMisc.skyColors) - return 13553096; - else - { - par1 /= 3.0F; - - if (par1 < -1.0F) - { - par1 = -1.0F; - } - - if (par1 > 1.0F) - { - par1 = 1.0F; - } - - return Color.getHSBColor(0.62222224F - par1 * 0.05F, 0.5F + par1 * 0.1F, 1.0F).getRGB(); - } - } - */ + */ } diff --git a/src/main/java/biomesoplenty/common/core/BOPBiomes.java b/src/main/java/biomesoplenty/common/core/BOPBiomes.java index 7cccaf5ed..bef0ca1f2 100644 --- a/src/main/java/biomesoplenty/common/core/BOPBiomes.java +++ b/src/main/java/biomesoplenty/common/core/BOPBiomes.java @@ -50,6 +50,7 @@ import biomesoplenty.common.biomes.BiomeGenSacredSprings; import biomesoplenty.common.biomes.BiomeGenSeasonalForest; import biomesoplenty.common.biomes.BiomeGenShield; import biomesoplenty.common.biomes.BiomeGenShrubland; +import biomesoplenty.common.biomes.BiomeGenSilkglades; import biomesoplenty.common.biomes.BiomeGenSludgepit; import biomesoplenty.common.biomes.BiomeGenSpruceWoods; import biomesoplenty.common.biomes.BiomeGenTemperateRainforest; @@ -149,8 +150,8 @@ public class BOPBiomes registerBiome(new BOPBiomeListEntry(new BiomeGenSeasonalForest(BOPConfigurationIDs.seasonalForestID).setBiomeName("Seasonal Forest"), BOPBiomeTemperatureType.COOL)); registerBiome(new BOPBiomeListEntry(new BiomeGenShield(BOPConfigurationIDs.shieldID).setBiomeName("Shield"), BOPBiomeTemperatureType.COOL)); registerBiome(new BOPBiomeListEntry(new BiomeGenShrubland(BOPConfigurationIDs.shrublandID).setBiomeName("Shrubland"), BOPBiomeTemperatureType.COOL)); - //registerBiome(new BOPBiomeListEntry(new BiomeGenSilkglades(BOPConfigurationIDs.silkgladesID).setBiomeName("Silkglades"), BOPBiomeTemperatureType.COOL)); - registerOnlyBiome(new BOPBiomeListEntry(new BiomeGenSludgepit(BOPConfigurationIDs.sludgepitID).setBiomeName("Sludgepit"), BOPBiomeTemperatureType.WARM)); + registerBiome(new BOPBiomeListEntry(new BiomeGenSilkglades(BOPConfigurationIDs.silkgladesID).setBiomeName("Silkglades"), BOPBiomeTemperatureType.COOL)); + registerBiome(new BOPBiomeListEntry(new BiomeGenSludgepit(BOPConfigurationIDs.sludgepitID).setBiomeName("Sludgepit"), BOPBiomeTemperatureType.WARM)); registerBiome(new BOPBiomeListEntry(new BiomeGenSpruceWoods(BOPConfigurationIDs.spruceWoodsID).setBiomeName("Spruce Woods"), BOPBiomeTemperatureType.WARM)); registerBiome(new BOPBiomeListEntry(new BiomeGenTemperateRainforest(BOPConfigurationIDs.temperateRainforestID).setBiomeName("Temperate Rainforest"), BOPBiomeTemperatureType.WARM)); registerBiome(new BOPBiomeListEntry(new BiomeGenThicket(BOPConfigurationIDs.thicketID).setBiomeName("Thicket"), BOPBiomeTemperatureType.WARM)); diff --git a/src/main/java/biomesoplenty/common/world/decoration/BOPWorldFeatures.java b/src/main/java/biomesoplenty/common/world/decoration/BOPWorldFeatures.java index a390dca2f..b52be0f64 100644 --- a/src/main/java/biomesoplenty/common/world/decoration/BOPWorldFeatures.java +++ b/src/main/java/biomesoplenty/common/world/decoration/BOPWorldFeatures.java @@ -52,6 +52,8 @@ public class BOPWorldFeatures public int rockpilesPerChunk = 0; public int logsPerChunk = 0; public int lavaSpoutsPerChunk = 0; + public int cobwebsPerChunk = 0; + public int cobwebNestsPerChunk = 0; public int bopFlowersPerChunk = 0; } diff --git a/src/main/java/biomesoplenty/common/world/features/WorldGenBOPFlora.java b/src/main/java/biomesoplenty/common/world/features/WorldGenBOPFlora.java index f549ef437..39673671e 100644 --- a/src/main/java/biomesoplenty/common/world/features/WorldGenBOPFlora.java +++ b/src/main/java/biomesoplenty/common/world/features/WorldGenBOPFlora.java @@ -4,10 +4,12 @@ import java.lang.reflect.Field; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenerator; +import biomesoplenty.api.BOPBlockHelper; import biomesoplenty.common.world.decoration.IBOPDecoration; import biomesoplenty.common.world.generation.WorldGeneratorBOP; @@ -39,8 +41,10 @@ public class WorldGenBOPFlora extends WorldGeneratorBOP int j1 = y + random.nextInt(4) - random.nextInt(4); int k1 = z + random.nextInt(8) - random.nextInt(8); - //TODO: isAirBlock() canReplace() - if (world.func_147437_c(i1, j1, k1) && (!world.provider.hasNoSky || j1 < 255) && this.flora.func_149705_a(world, i1, j1, k1, 0, new ItemStack(flora, 1, floraMeta))) + //TODO: isAirBlock() + if (world.func_147437_c(i1, j1, k1) && (!world.provider.hasNoSky || j1 < 255) && + (flora == Blocks.web ? world.func_147439_a(i1, j1 + 1, k1) == BOPBlockHelper.get("leaves2") || world.func_147439_a(i1, j1 + 1, k1) == BOPBlockHelper.get("colorizedLeaves2") || world.func_147439_a(i1, j1 - 1, k1) == Blocks.grass : + this.flora.func_149705_a(world, i1, j1, k1, 0, new ItemStack(flora, 1, floraMeta)))) { //TODO: setBlock() world.func_147465_d(i1, j1, k1, this.flora, this.floraMeta, 2); diff --git a/src/main/java/biomesoplenty/common/world/features/WorldGenCobwebNest.java b/src/main/java/biomesoplenty/common/world/features/WorldGenCobwebNest.java new file mode 100644 index 000000000..b46ac7823 --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/features/WorldGenCobwebNest.java @@ -0,0 +1,81 @@ +package biomesoplenty.common.world.features; + +import java.lang.reflect.Field; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import biomesoplenty.common.world.decoration.IBOPDecoration; +import biomesoplenty.common.world.generation.WorldGeneratorBOP; + +public class WorldGenCobwebNest extends WorldGeneratorBOP +{ + @Override + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + Block var15; + + //TODO: getBlock() + for (boolean var6 = false; ((var15 = par1World.func_147439_a(par3, par4, par5)) == Blocks.air || var15 == Blocks.web) && par4 > 0; --par4) + { + ; + } + + Block block = par1World.func_147439_a(par3, par4, par5); + + if (block == Blocks.grass) + { + ++par4; + this.func_150516_a(par1World, par3, par4, par5, Blocks.web, 0); + + int var999 = par2Random.nextInt(3); + + if (var999 == 0) + { + EntitySpider spider = new EntitySpider(par1World); + spider.setLocationAndAngles((double)par3, (double)par4 + 1, (double)par5, 0.0F, 0.0F); + par1World.spawnEntityInWorld(spider); + } + + for (int var8 = par4; var8 <= par4 + 1; ++var8) + { + int var9 = var8 - par4; + int var10 = 2 - var9; + + for (int var11 = par3 - var10; var11 <= par3 + var10; ++var11) + { + int var12 = var11 - par3; + + for (int var13 = par5 - var10; var13 <= par5 + var10; ++var13) + { + int var14 = var13 - par5; + + if (Math.abs(var12) != var10 || Math.abs(var14) != var10 || par2Random.nextInt(2) != 0) + { + this.func_150516_a(par1World, var11, var8, var13, Blocks.web, 0); + } + } + } + } + } + + return true; + } + + @Override + public void doGeneration(World world, Random random, Field worldGeneratorField, WorldGenerator worldGenerator, BiomeGenBase biome, IBOPDecoration bopDecoration, int x, int z) throws Exception + { + for (int i = 0; i < worldGeneratorField.getInt(bopDecoration.getWorldFeatures()); i++) + { + int randX = x + random.nextInt(16) + 8; + int randZ = z + random.nextInt(16) + 8; + int randY = random.nextInt(world.getHeightValue(randX, randZ) * 2); + + worldGenerator.generate(world, random, randX, randY, randZ); + } + } +} diff --git a/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java b/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java index b6d7c28d5..b0d4e81af 100644 --- a/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java +++ b/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java @@ -11,6 +11,7 @@ import biomesoplenty.api.BOPBlockHelper; import biomesoplenty.common.world.features.WorldGenBOPDoubleFlora; import biomesoplenty.common.world.features.WorldGenBOPFlora; import biomesoplenty.common.world.features.WorldGenBOPTallGrass; +import biomesoplenty.common.world.features.WorldGenCobwebNest; import biomesoplenty.common.world.features.WorldGenGrassSplatter; import biomesoplenty.common.world.features.WorldGenLavaSpout; import biomesoplenty.common.world.features.WorldGenLog; @@ -78,6 +79,8 @@ public class WorldGenFieldAssociation associateField("rockpilesPerChunk", new WorldGenRockpile()); associateField("logsPerChunk", new WorldGenLog()); associateField("lavaSpoutsPerChunk", new WorldGenLavaSpout()); + associateField("cobwebsPerChunk", new WorldGenBOPFlora(Blocks.web, 0)); + associateField("cobwebNestsPerChunk", new WorldGenCobwebNest()); associateField("doubleTallGrassPerChunk", new WorldGenBOPDoubleFlora(Blocks.double_plant, Blocks.double_plant, 2, 8)); associateField("sunflowersPerChunk", new WorldGenBOPDoubleFlora(Blocks.double_plant, Blocks.double_plant, 0, 8));