diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/australia | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/australia')
51 files changed, 8410 insertions, 8222 deletions
diff --git a/src/main/java/gtPlusPlus/australia/GTplusplus_Australia.java b/src/main/java/gtPlusPlus/australia/GTplusplus_Australia.java index 9a16ad1785..16b54138e2 100644 --- a/src/main/java/gtPlusPlus/australia/GTplusplus_Australia.java +++ b/src/main/java/gtPlusPlus/australia/GTplusplus_Australia.java @@ -1,9 +1,5 @@ package gtPlusPlus.australia; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; - import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -28,131 +24,136 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.Australia; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.Configuration; @MCVersion(value = "1.7.10") -@Mod(modid = Australia.MODID, name = Australia.NAME, version = Australia.VERSION, dependencies = "required-after:Forge; after:dreamcraft; after:IC2; after:ihl; required-after:gregtech; required-after:miscutils;") +@Mod( + modid = Australia.MODID, + name = Australia.NAME, + version = Australia.VERSION, + dependencies = + "required-after:Forge; after:dreamcraft; after:IC2; after:ihl; required-after:gregtech; required-after:miscutils;") public class GTplusplus_Australia implements ActionListener { - //Mod Instance - @Mod.Instance(Australia.MODID) - public static GTplusplus_Australia instance; - public static GTPP_Config sCustomWorldgenFile = null; - - // Dark World Handler - //protected static volatile Biome_AustralianDesert Australian_Desert_Biome_1; - //protected static volatile Biome_AustralianDesert2 Australian_Desert_Biome_2; - - public static volatile Biome_AustralianDesert_Ex Australian_Desert_Biome_3; - public static volatile Biome_AustralianForest Australian_Forest_Biome; - public static volatile Biome_AustralianOcean Australian_Ocean_Biome; - public static volatile Biome_AustralianOutback Australian_Outback_Biome; - public static volatile Biome_AustralianPlains Australian_Plains_Biome; - - public static volatile Dimension_Australia Australia_Dimension; - public static AustraliaWorldGenerator Australia_World_Generator; - public static int globalAustraliaPortalSpawnTimer = 0; - - // Pre-Init - @Mod.EventHandler - public void preInit(final FMLPreInitializationEvent event) { - Logger.INFO("Loading " + Australia.MODID + " V" + Australia.VERSION); - - //Setup - setVars(event); - - Australia_Dimension = new Dimension_Australia(); - Australia_Dimension.instance = instance; - - //Australian_Desert_Biome_1 = (new Biome_AustralianDesert()); - //Australian_Desert_Biome_2 = (new Biome_AustralianDesert2()); - //Australian_Desert_Biome_1.instance = instance; - //Australian_Desert_Biome_2.instance = instance; - //Australian_Desert_Biome_1.preInit(event); - //Australian_Desert_Biome_2.preInit(event); - - - Australian_Desert_Biome_3 = (Biome_AustralianDesert_Ex.biome); - Australian_Forest_Biome = (Biome_AustralianForest.biome); - Australian_Ocean_Biome = (Biome_AustralianOcean.biome); - Australian_Outback_Biome = (Biome_AustralianOutback.biome); - Australian_Plains_Biome = Biome_AustralianPlains.biome; - - //Load Villages - StructureManager.registerVillageComponents(); - - setupWorldGenerator(); - - //Load/Set Custom Ore Gen - sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "Australia.cfg"))); - - } - - @EventHandler - public void load(final FMLInitializationEvent e) { - Logger.INFO("Begin resource allocation for " + Australia.MODID + " V" +Australia.VERSION); - - //Load World and Biome - GameRegistry.registerWorldGenerator(new WorldGen_GT_Australia_Base(), Short.MAX_VALUE); - - //Australian_Desert_Biome_1.load(); - //Australian_Desert_Biome_2.load(); - Australian_Desert_Biome_3.load(); - Australian_Forest_Biome.load(); - Australian_Ocean_Biome.load(); - Australian_Outback_Biome.load(); - Australian_Plains_Biome.load(); - - Australia_Dimension.load(); - - } - - public static synchronized void GenerateOreMaterials() { - - } - - protected synchronized void setVars(FMLPreInitializationEvent event){ - - sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "Australia.cfg"))); - - if (DimensionManager.isDimensionRegistered(Dimension_Australia.DIMID)){ - Dimension_Australia.DIMID = DimensionManager.getNextFreeDimId(); - } - - /* - * Set World Generation Values - */ - WorldGen_Australia_Ores.generateValidOreVeins(); - WorldGen_GT_Australia_Base.oreveinPercentage = 16; - WorldGen_GT_Australia_Base.oreveinAttempts = 16; - WorldGen_GT_Australia_Base.oreveinMaxPlacementAttempts = 2; - if (CORE_Preloader.DEBUG_MODE || CORE.DEVENV){ - WorldGen_GT_Australia_Base.debugWorldGen = true; - } - AustraliaContentLoader.run(); - } - - @EventHandler - public void serverLoad(FMLServerStartingEvent event) { - Australia_World_Generator.initiate(); - } - - @EventHandler - public static void postInit(final FMLPostInitializationEvent e) { - Logger.INFO("Finished loading Australia plugin for GT++."); - } - - @Override - public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub - - } - - private void setupWorldGenerator() { - Logger.INFO("Registering World Generator for Australia."); - Australia_World_Generator = new AustraliaWorldGenerator(); - GameRegistry.registerWorldGenerator(Australia_World_Generator, 0); - } - + // Mod Instance + @Mod.Instance(Australia.MODID) + public static GTplusplus_Australia instance; + + public static GTPP_Config sCustomWorldgenFile = null; + + // Dark World Handler + // protected static volatile Biome_AustralianDesert Australian_Desert_Biome_1; + // protected static volatile Biome_AustralianDesert2 Australian_Desert_Biome_2; + + public static volatile Biome_AustralianDesert_Ex Australian_Desert_Biome_3; + public static volatile Biome_AustralianForest Australian_Forest_Biome; + public static volatile Biome_AustralianOcean Australian_Ocean_Biome; + public static volatile Biome_AustralianOutback Australian_Outback_Biome; + public static volatile Biome_AustralianPlains Australian_Plains_Biome; + + public static volatile Dimension_Australia Australia_Dimension; + public static AustraliaWorldGenerator Australia_World_Generator; + public static int globalAustraliaPortalSpawnTimer = 0; + + // Pre-Init + @Mod.EventHandler + public void preInit(final FMLPreInitializationEvent event) { + Logger.INFO("Loading " + Australia.MODID + " V" + Australia.VERSION); + + // Setup + setVars(event); + + Australia_Dimension = new Dimension_Australia(); + Australia_Dimension.instance = instance; + + // Australian_Desert_Biome_1 = (new Biome_AustralianDesert()); + // Australian_Desert_Biome_2 = (new Biome_AustralianDesert2()); + // Australian_Desert_Biome_1.instance = instance; + // Australian_Desert_Biome_2.instance = instance; + // Australian_Desert_Biome_1.preInit(event); + // Australian_Desert_Biome_2.preInit(event); + + Australian_Desert_Biome_3 = (Biome_AustralianDesert_Ex.biome); + Australian_Forest_Biome = (Biome_AustralianForest.biome); + Australian_Ocean_Biome = (Biome_AustralianOcean.biome); + Australian_Outback_Biome = (Biome_AustralianOutback.biome); + Australian_Plains_Biome = Biome_AustralianPlains.biome; + + // Load Villages + StructureManager.registerVillageComponents(); + + setupWorldGenerator(); + + // Load/Set Custom Ore Gen + sCustomWorldgenFile = new GTPP_Config(new Configuration( + new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "Australia.cfg"))); + } + + @EventHandler + public void load(final FMLInitializationEvent e) { + Logger.INFO("Begin resource allocation for " + Australia.MODID + " V" + Australia.VERSION); + + // Load World and Biome + GameRegistry.registerWorldGenerator(new WorldGen_GT_Australia_Base(), Short.MAX_VALUE); + + // Australian_Desert_Biome_1.load(); + // Australian_Desert_Biome_2.load(); + Australian_Desert_Biome_3.load(); + Australian_Forest_Biome.load(); + Australian_Ocean_Biome.load(); + Australian_Outback_Biome.load(); + Australian_Plains_Biome.load(); + + Australia_Dimension.load(); + } + + public static synchronized void GenerateOreMaterials() {} + + protected synchronized void setVars(FMLPreInitializationEvent event) { + + sCustomWorldgenFile = new GTPP_Config(new Configuration( + new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "Australia.cfg"))); + + if (DimensionManager.isDimensionRegistered(Dimension_Australia.DIMID)) { + Dimension_Australia.DIMID = DimensionManager.getNextFreeDimId(); + } + + /* + * Set World Generation Values + */ + WorldGen_Australia_Ores.generateValidOreVeins(); + WorldGen_GT_Australia_Base.oreveinPercentage = 16; + WorldGen_GT_Australia_Base.oreveinAttempts = 16; + WorldGen_GT_Australia_Base.oreveinMaxPlacementAttempts = 2; + if (CORE_Preloader.DEBUG_MODE || CORE.DEVENV) { + WorldGen_GT_Australia_Base.debugWorldGen = true; + } + AustraliaContentLoader.run(); + } + + @EventHandler + public void serverLoad(FMLServerStartingEvent event) { + Australia_World_Generator.initiate(); + } + + @EventHandler + public static void postInit(final FMLPostInitializationEvent e) { + Logger.INFO("Finished loading Australia plugin for GT++."); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + + private void setupWorldGenerator() { + Logger.INFO("Registering World Generator for Australia."); + Australia_World_Generator = new AustraliaWorldGenerator(); + GameRegistry.registerWorldGenerator(Australia_World_Generator, 0); + } } diff --git a/src/main/java/gtPlusPlus/australia/biome/CustomDecorator.java b/src/main/java/gtPlusPlus/australia/biome/CustomDecorator.java index 2d9b335d52..ea6b50a478 100644 --- a/src/main/java/gtPlusPlus/australia/biome/CustomDecorator.java +++ b/src/main/java/gtPlusPlus/australia/biome/CustomDecorator.java @@ -1,11 +1,12 @@ package gtPlusPlus.australia.biome; -import java.util.Random; +import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*; +import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*; -import gtPlusPlus.api.interfaces.IGeneratorWorld; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.australia.GTplusplus_Australia; import gtPlusPlus.australia.gen.world.WorldGenAustralianOre; +import java.util.Random; import net.minecraft.block.BlockFlower; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -24,332 +25,331 @@ import net.minecraft.world.gen.feature.WorldGenReed; import net.minecraft.world.gen.feature.WorldGenSand; import net.minecraft.world.gen.feature.WorldGenWaterlily; import net.minecraft.world.gen.feature.WorldGenerator; - -import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*; -import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*; import net.minecraftforge.common.*; import net.minecraftforge.event.terraingen.*; public class CustomDecorator extends BiomeDecorator { - - public CustomDecorator() { - this.sandGen = new WorldGenSand(Blocks.sand, 10); - this.gravelAsSandGen = new WorldGenSand(Blocks.gravel, 6); - this.dirtGen = new WorldGenMinable(Blocks.dirt, 16); - this.gravelGen = new WorldGenMinable(Blocks.gravel, 16); - - this.coalGen = new WorldGenAustralianOre(Blocks.coal_ore, 4); - this.ironGen = new WorldGenAustralianOre(Blocks.clay, 4); - this.goldGen = new WorldGenAustralianOre(Blocks.soul_sand, 20); - this.redstoneGen = new WorldGenAustralianOre(Blocks.bedrock, 8); - this.diamondGen = new WorldGenAustralianOre(Blocks.diamond_ore, 1); - this.lapisGen = new WorldGenAustralianOre(Blocks.lava, 16); - - this.yellowFlowerGen = new WorldGenFlowers(Blocks.yellow_flower); - this.mushroomBrownGen = new WorldGenFlowers(Blocks.brown_mushroom); - this.mushroomRedGen = new WorldGenFlowers(Blocks.red_mushroom); - this.bigMushroomGen = new WorldGenBigMushroom(); - this.reedGen = new WorldGenReed(); - this.cactusGen = new WorldGenCactus(); - this.waterlilyGen = new WorldGenWaterlily(); - this.flowersPerChunk = 2; - this.grassPerChunk = 1; - this.sandPerChunk = 1; - this.sandPerChunk2 = 3; - this.clayPerChunk = 2; - this.generateLakes = true; - } - - int mDecoratorTimeout = 0; - - public void decorateChunk(World aWorld, Random aRand, BiomeGenBase aGen, int aX, int aZ) { - if (this.currentWorld != null && this.chunk_X == aX && this.chunk_Z == aZ) { - try { - while (this.currentWorld != null) { - if (mDecoratorTimeout % 1000 == 0) { - Logger.WORLD("Waiting for chunk @ "+aX+", "+aZ+" to generate. Waited "+mDecoratorTimeout+"ms already."); - } - if (this.currentWorld == null) { - break; - } - if (mDecoratorTimeout >= 5000) { - throw new RuntimeException("Already decorating!!"); - } - mDecoratorTimeout++; - } - } - catch (Throwable t) { - t.printStackTrace(); - throw new RuntimeException("Already decorating!!"); - } - } - if (this.currentWorld == null) { - this.currentWorld = aWorld; - this.randomGenerator = aRand; - this.chunk_X = aX; - this.chunk_Z = aZ; - this.genDecorations(aGen); - this.currentWorld = null; - this.randomGenerator = null; - } - } - - protected void genDecorations(BiomeGenBase p_150513_1_) { - MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); - this.generateOres(); - int i; - int j; - int k; - - boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND); - for (i = 0; doGen && i < this.sandPerChunk2; ++i) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.sandGen.generate(this.currentWorld, this.randomGenerator, j, - this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY); - for (i = 0; doGen && i < this.clayPerChunk; ++i) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.clayGen.generate(this.currentWorld, this.randomGenerator, j, - this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2); - for (i = 0; doGen && i < this.sandPerChunk; ++i) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, - this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - i = this.treesPerChunk; - - if (this.randomGenerator.nextInt(10) == 0) { - ++i; - } - - int l; - int i1; - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE); - for (j = 0; doGen && j < i; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = this.currentWorld.getHeightValue(k, l); - WorldGenAbstractTree worldgenabstracttree = p_150513_1_.func_150567_a(this.randomGenerator); - worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); - - if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) { - worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM); - for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, - this.currentWorld.getHeightValue(k, l), l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS); - for (j = 0; doGen && j < this.flowersPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) + 32); - String s = p_150513_1_.func_150572_a(this.randomGenerator, k, i1, l); - BlockFlower blockflower = BlockFlower.func_149857_e(s); - - if (blockflower.getMaterial() != Material.air) { - this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s)); - this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS); - for (j = 0; doGen && j < this.grassPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - WorldGenerator worldgenerator = p_150513_1_.getRandomWorldGenForGrass(this.randomGenerator); - worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH); - for (j = 0; doGen && j < this.deadBushPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - (new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD); - for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - - for (i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0 - && this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) { - ; - } - - this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM); - for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) { - if (this.randomGenerator.nextInt(4) == 0) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = this.currentWorld.getHeightValue(k, l); - this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - if (this.randomGenerator.nextInt(8) == 0) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - if (doGen && this.randomGenerator.nextInt(4) == 0) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - if (doGen && this.randomGenerator.nextInt(8) == 0) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED); - for (j = 0; doGen && j < this.reedsPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - for (j = 0; doGen && j < 10; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN); - if (doGen && this.randomGenerator.nextInt(32) == 0) { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - (new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS); - for (j = 0; doGen && j < this.cactiPerChunk; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - try { - int midX = Math.max(0, 7 / 2); - int midZ = Math.max(0, 7 / 2); - int mCurrentBiomeID = Integer.valueOf(currentWorld.getBiomeGenForCoords(chunk_X+midX, chunk_Z+midZ).biomeID); - - if (mCurrentBiomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { - this.generateLakes = false; - } - - if (mCurrentBiomeID != GTplusplus_Australia.Australian_Outback_Biome.biomeID) { - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE); - if (doGen && this.generateLakes) { - for (j = 0; j < 50; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8); - i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - (new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1); - } - - for (j = 0; j < 20; ++j) { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.randomGenerator - .nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8); - i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - (new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1); - } - } - } - } - catch (Throwable t) { - - } - - MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); - } - - /** - * Standard ore generation helper. Generates most ores. - */ - protected void genStandardOre1(int aAmount, WorldGenerator aOreGenerator, int p_76795_3_, int p_76795_4_) { - for (int l = 0; l < aAmount; ++l) { - int i1 = this.chunk_X + this.randomGenerator.nextInt(16); - int j1 = this.randomGenerator.nextInt(p_76795_4_ - p_76795_3_) + p_76795_3_; - int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); - aOreGenerator.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); - } - } - - /** - * Standard ore generation helper. Generates Lapis Lazuli. - */ - protected void genStandardOre2(int p_76793_1_, WorldGenerator p_76793_2_, int p_76793_3_, int p_76793_4_) { - for (int l = 0; l < p_76793_1_; ++l) { - int i1 = this.chunk_X + this.randomGenerator.nextInt(16); - int j1 = this.randomGenerator.nextInt(p_76793_4_) + this.randomGenerator.nextInt(p_76793_4_) - + (p_76793_3_ - p_76793_4_); - int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); - p_76793_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); - } - } - - /** - * Generates ores in the current chunk - */ - protected void generateOres() { - MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); - if (TerrainGen.generateOre(currentWorld, randomGenerator, dirtGen, chunk_X, chunk_Z, DIRT)) - this.genStandardOre1(20, this.dirtGen, 0, 256); - if (TerrainGen.generateOre(currentWorld, randomGenerator, gravelGen, chunk_X, chunk_Z, GRAVEL)) - this.genStandardOre1(10, this.gravelGen, 0, 256); - if (TerrainGen.generateOre(currentWorld, randomGenerator, coalGen, chunk_X, chunk_Z, COAL)) - this.genStandardOre1(20, this.coalGen, 0, 128); - if (TerrainGen.generateOre(currentWorld, randomGenerator, ironGen, chunk_X, chunk_Z, IRON)) - this.genStandardOre1(10, this.ironGen, 0, 64); - if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) - this.genStandardOre1(15, this.goldGen, 0, 32); - if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) - this.genStandardOre1(10, this.redstoneGen, 0, 16); - if (TerrainGen.generateOre(currentWorld, randomGenerator, diamondGen, chunk_X, chunk_Z, DIAMOND)) - this.genStandardOre1(1, this.diamondGen, 0, 16); - if (TerrainGen.generateOre(currentWorld, randomGenerator, lapisGen, chunk_X, chunk_Z, LAPIS)) - this.genStandardOre2(10, this.lapisGen, 16, 16); - MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); - } - - private int nextInt(int i) { - if (i <= 1) - return 0; - return this.randomGenerator.nextInt(i); - } -}
\ No newline at end of file + public CustomDecorator() { + this.sandGen = new WorldGenSand(Blocks.sand, 10); + this.gravelAsSandGen = new WorldGenSand(Blocks.gravel, 6); + this.dirtGen = new WorldGenMinable(Blocks.dirt, 16); + this.gravelGen = new WorldGenMinable(Blocks.gravel, 16); + + this.coalGen = new WorldGenAustralianOre(Blocks.coal_ore, 4); + this.ironGen = new WorldGenAustralianOre(Blocks.clay, 4); + this.goldGen = new WorldGenAustralianOre(Blocks.soul_sand, 20); + this.redstoneGen = new WorldGenAustralianOre(Blocks.bedrock, 8); + this.diamondGen = new WorldGenAustralianOre(Blocks.diamond_ore, 1); + this.lapisGen = new WorldGenAustralianOre(Blocks.lava, 16); + + this.yellowFlowerGen = new WorldGenFlowers(Blocks.yellow_flower); + this.mushroomBrownGen = new WorldGenFlowers(Blocks.brown_mushroom); + this.mushroomRedGen = new WorldGenFlowers(Blocks.red_mushroom); + this.bigMushroomGen = new WorldGenBigMushroom(); + this.reedGen = new WorldGenReed(); + this.cactusGen = new WorldGenCactus(); + this.waterlilyGen = new WorldGenWaterlily(); + this.flowersPerChunk = 2; + this.grassPerChunk = 1; + this.sandPerChunk = 1; + this.sandPerChunk2 = 3; + this.clayPerChunk = 2; + this.generateLakes = true; + } + + int mDecoratorTimeout = 0; + + public void decorateChunk(World aWorld, Random aRand, BiomeGenBase aGen, int aX, int aZ) { + if (this.currentWorld != null && this.chunk_X == aX && this.chunk_Z == aZ) { + try { + while (this.currentWorld != null) { + if (mDecoratorTimeout % 1000 == 0) { + Logger.WORLD("Waiting for chunk @ " + aX + ", " + aZ + " to generate. Waited " + + mDecoratorTimeout + "ms already."); + } + if (this.currentWorld == null) { + break; + } + if (mDecoratorTimeout >= 5000) { + throw new RuntimeException("Already decorating!!"); + } + mDecoratorTimeout++; + } + } catch (Throwable t) { + t.printStackTrace(); + throw new RuntimeException("Already decorating!!"); + } + } + if (this.currentWorld == null) { + this.currentWorld = aWorld; + this.randomGenerator = aRand; + this.chunk_X = aX; + this.chunk_Z = aZ; + this.genDecorations(aGen); + this.currentWorld = null; + this.randomGenerator = null; + } + } + + protected void genDecorations(BiomeGenBase p_150513_1_) { + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + this.generateOres(); + int i; + int j; + int k; + + boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND); + for (i = 0; doGen && i < this.sandPerChunk2; ++i) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.sandGen.generate( + this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY); + for (i = 0; doGen && i < this.clayPerChunk; ++i) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.clayGen.generate( + this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2); + for (i = 0; doGen && i < this.sandPerChunk; ++i) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.gravelAsSandGen.generate( + this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + i = this.treesPerChunk; + + if (this.randomGenerator.nextInt(10) == 0) { + ++i; + } + + int l; + int i1; + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE); + for (j = 0; doGen && j < i; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + WorldGenAbstractTree worldgenabstracttree = p_150513_1_.func_150567_a(this.randomGenerator); + worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); + + if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) { + worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM); + for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.bigMushroomGen.generate( + this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS); + for (j = 0; doGen && j < this.flowersPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) + 32); + String s = p_150513_1_.func_150572_a(this.randomGenerator, k, i1, l); + BlockFlower blockflower = BlockFlower.func_149857_e(s); + + if (blockflower.getMaterial() != Material.air) { + this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s)); + this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS); + for (j = 0; doGen && j < this.grassPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + WorldGenerator worldgenerator = p_150513_1_.getRandomWorldGenForGrass(this.randomGenerator); + worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH); + for (j = 0; doGen && j < this.deadBushPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + (new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD); + for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + + for (i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + i1 > 0 && this.currentWorld.isAirBlock(k, i1 - 1, l); + --i1) { + ; + } + + this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM); + for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) { + if (this.randomGenerator.nextInt(4) == 0) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + if (this.randomGenerator.nextInt(8) == 0) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + if (doGen && this.randomGenerator.nextInt(4) == 0) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + if (doGen && this.randomGenerator.nextInt(8) == 0) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED); + for (j = 0; doGen && j < this.reedsPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + for (j = 0; doGen && j < 10; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN); + if (doGen && this.randomGenerator.nextInt(32) == 0) { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + (new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS); + for (j = 0; doGen && j < this.cactiPerChunk; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + try { + int midX = Math.max(0, 7 / 2); + int midZ = Math.max(0, 7 / 2); + int mCurrentBiomeID = + Integer.valueOf(currentWorld.getBiomeGenForCoords(chunk_X + midX, chunk_Z + midZ).biomeID); + + if (mCurrentBiomeID == GTplusplus_Australia.Australian_Outback_Biome.biomeID) { + this.generateLakes = false; + } + + if (mCurrentBiomeID != GTplusplus_Australia.Australian_Outback_Biome.biomeID) { + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE); + if (doGen && this.generateLakes) { + for (j = 0; j < 50; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_water)) + .generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + + for (j = 0; j < 20; ++j) { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt( + this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_lava)) + .generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + } + } + } catch (Throwable t) { + + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } + + /** + * Standard ore generation helper. Generates most ores. + */ + protected void genStandardOre1(int aAmount, WorldGenerator aOreGenerator, int p_76795_3_, int p_76795_4_) { + for (int l = 0; l < aAmount; ++l) { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(p_76795_4_ - p_76795_3_) + p_76795_3_; + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + aOreGenerator.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + /** + * Standard ore generation helper. Generates Lapis Lazuli. + */ + protected void genStandardOre2(int p_76793_1_, WorldGenerator p_76793_2_, int p_76793_3_, int p_76793_4_) { + for (int l = 0; l < p_76793_1_; ++l) { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(p_76793_4_) + + this.randomGenerator.nextInt(p_76793_4_) + + (p_76793_3_ - p_76793_4_); + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + p_76793_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + /** + * Generates ores in the current chunk + */ + protected void generateOres() { + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + if (TerrainGen.generateOre(currentWorld, randomGenerator, dirtGen, chunk_X, chunk_Z, DIRT)) + this.genStandardOre1(20, this.dirtGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, gravelGen, chunk_X, chunk_Z, GRAVEL)) + this.genStandardOre1(10, this.gravelGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, coalGen, chunk_X, chunk_Z, COAL)) + this.genStandardOre1(20, this.coalGen, 0, 128); + if (TerrainGen.generateOre(currentWorld, randomGenerator, ironGen, chunk_X, chunk_Z, IRON)) + this.genStandardOre1(10, this.ironGen, 0, 64); + if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) + this.genStandardOre1(15, this.goldGen, 0, 32); + if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) + this.genStandardOre1(10, this.redstoneGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, diamondGen, chunk_X, chunk_Z, DIAMOND)) + this.genStandardOre1(1, this.diamondGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, lapisGen, chunk_X, chunk_Z, LAPIS)) + this.genStandardOre2(10, this.lapisGen, 16, 16); + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } + + private int nextInt(int i) { + if (i <= 1) return 0; + return this.randomGenerator.nextInt(i); + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/GenLayerAustralia.java b/src/main/java/gtPlusPlus/australia/biome/GenLayerAustralia.java index d9c328d756..598c402c60 100644 --- a/src/main/java/gtPlusPlus/australia/biome/GenLayerAustralia.java +++ b/src/main/java/gtPlusPlus/australia/biome/GenLayerAustralia.java @@ -7,26 +7,26 @@ import net.minecraft.world.gen.layer.GenLayerZoom; public class GenLayerAustralia extends GenLayer { - public GenLayerAustralia(long seed) { - super(seed); - } + public GenLayerAustralia(long seed) { + super(seed); + } - public static GenLayer[] makeTheWorld(long seed, WorldType type) { - GenLayer biomes = new GenLayerBiomesAustraliaDimension(1L); - biomes = new GenLayerZoom(1000L, biomes); - biomes = new GenLayerZoom(1001L, biomes); - biomes = new GenLayerZoom(1002L, biomes); - biomes = new GenLayerZoom(1003L, biomes); - biomes = new GenLayerZoom(1004L, biomes); - biomes = new GenLayerZoom(1005L, biomes); - GenLayer genlayervoronoizoom = new GenLayerVoronoiZoom(10L, biomes); - biomes.initWorldGenSeed(seed); - genlayervoronoizoom.initWorldGenSeed(seed); - return new GenLayer[] { biomes, genlayervoronoizoom }; - } + public static GenLayer[] makeTheWorld(long seed, WorldType type) { + GenLayer biomes = new GenLayerBiomesAustraliaDimension(1L); + biomes = new GenLayerZoom(1000L, biomes); + biomes = new GenLayerZoom(1001L, biomes); + biomes = new GenLayerZoom(1002L, biomes); + biomes = new GenLayerZoom(1003L, biomes); + biomes = new GenLayerZoom(1004L, biomes); + biomes = new GenLayerZoom(1005L, biomes); + GenLayer genlayervoronoizoom = new GenLayerVoronoiZoom(10L, biomes); + biomes.initWorldGenSeed(seed); + genlayervoronoizoom.initWorldGenSeed(seed); + return new GenLayer[] {biomes, genlayervoronoizoom}; + } - @Override - public int[] getInts(int p_75904_1_, int p_75904_2_, int p_75904_3_, int p_75904_4_) { - return new int[] {}; - } -}
\ No newline at end of file + @Override + public int[] getInts(int p_75904_1_, int p_75904_2_, int p_75904_3_, int p_75904_4_) { + return new int[] {}; + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java b/src/main/java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java index 571ae636e0..8a1f99239f 100644 --- a/src/main/java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java +++ b/src/main/java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java @@ -11,37 +11,36 @@ import net.minecraft.world.gen.layer.IntCache; public class GenLayerBiomesAustraliaDimension extends GenLayer { - protected BiomeGenBase[] allowedBiomes = { - Biome_AustralianDesert_Ex.biome, - Biome_AustralianDesert_Ex.biome, - Biome_AustralianOutback.biome, - Biome_AustralianOutback.biome, - Biome_AustralianForest.biome, - Biome_AustralianForest.biome, - Biome_AustralianPlains.biome, - Biome_AustralianPlains.biome, - Biome_AustralianOcean.biome, - }; + protected BiomeGenBase[] allowedBiomes = { + Biome_AustralianDesert_Ex.biome, + Biome_AustralianDesert_Ex.biome, + Biome_AustralianOutback.biome, + Biome_AustralianOutback.biome, + Biome_AustralianForest.biome, + Biome_AustralianForest.biome, + Biome_AustralianPlains.biome, + Biome_AustralianPlains.biome, + Biome_AustralianOcean.biome, + }; - public GenLayerBiomesAustraliaDimension(long seed) { - super(seed); - } + public GenLayerBiomesAustraliaDimension(long seed) { + super(seed); + } - public GenLayerBiomesAustraliaDimension(long seed, GenLayer genlayer) { - super(seed); - this.parent = genlayer; - } + public GenLayerBiomesAustraliaDimension(long seed, GenLayer genlayer) { + super(seed); + this.parent = genlayer; + } - @Override - public int[] getInts(int x, int z, int width, int depth) { - int[] dest = IntCache.getIntCache(width * depth); - for (int dz = 0; dz < depth; dz++) { - for (int dx = 0; dx < width; dx++) { - this.initChunkSeed(dx + x, dz + z); - dest[(dx + dz * width)] = this.allowedBiomes[nextInt(this.allowedBiomes.length)].biomeID; - } - } - return dest; - } - -}
\ No newline at end of file + @Override + public int[] getInts(int x, int z, int width, int depth) { + int[] dest = IntCache.getIntCache(width * depth); + for (int dz = 0; dz < depth; dz++) { + for (int dx = 0; dx < width; dx++) { + this.initChunkSeed(dx + x, dz + z); + dest[(dx + dz * width)] = this.allowedBiomes[nextInt(this.allowedBiomes.length)].biomeID; + } + } + return dest; + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert.java index 666360f058..585aafe308 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert.java @@ -1,8 +1,5 @@ package gtPlusPlus.australia.biome.type; -import java.lang.reflect.Field; -import java.util.Random; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.relauncher.Side; @@ -10,6 +7,8 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntitySilverfish; @@ -35,321 +34,318 @@ import net.minecraftforge.common.BiomeManager; public class Biome_AustralianDesert { + public Object instance; - public Object instance; - - public static Block blockTopLayer; - public static Block blockSecondLayer; - public static Block blockMainFiller = Blocks.stone; - public static Block blockSecondaryFiller; - public static Block blockFluidLakes; + public static Block blockTopLayer; + public static Block blockSecondLayer; + public static Block blockMainFiller = Blocks.stone; + public static Block blockSecondaryFiller; + public static Block blockFluidLakes; - public Biome_AustralianDesert() { - - } + public Biome_AustralianDesert() {} - public static BiomeGenAustralianDesert biome = new BiomeGenAustralianDesert(); - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); - BiomeManager.addSpawnBiome(biome); - } + public static BiomeGenAustralianDesert biome = new BiomeGenAustralianDesert(); - public void generateNether(World world, Random random, int chunkX, int chunkZ) { - } + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); + BiomeManager.addSpawnBiome(biome); + } - public void generateSurface(World world, Random random, int chunkX, int chunkZ) { - } + public void generateNether(World world, Random random, int chunkX, int chunkZ) {} - public void registerRenderers() { - } + public void generateSurface(World world, Random random, int chunkX, int chunkZ) {} - public int addFuel(ItemStack fuel) { - return 0; - } + public void registerRenderers() {} - public void serverLoad(FMLServerStartingEvent event) { - } + public int addFuel(ItemStack fuel) { + return 0; + } - public void preInit(FMLPreInitializationEvent event) { - } + public void serverLoad(FMLServerStartingEvent event) {} - static class BiomeGenAustralianDesert extends BiomeGenBase { - @SuppressWarnings("unchecked") - public BiomeGenAustralianDesert() { - super(CORE.AUSTRALIA_BIOME_DESERT_1_ID); - this.setBiomeName("Australian Desert"); - //this.setBiomeID(); - this.enableRain = true; - this.enableSnow = false; - this.topBlock = blockTopLayer; - this.fillerBlock = blockSecondLayer; - //this.theBiomeDecorator = new BiomeGenerator_Custom(); - this.theBiomeDecorator.generateLakes = true; - this.theBiomeDecorator.treesPerChunk = 20; - this.theBiomeDecorator.flowersPerChunk = 0; - this.theBiomeDecorator.grassPerChunk = 5; - this.theBiomeDecorator.deadBushPerChunk = 63; - this.theBiomeDecorator.mushroomsPerChunk = 0; - this.theBiomeDecorator.reedsPerChunk = 42; - this.theBiomeDecorator.cactiPerChunk = 56; - this.theBiomeDecorator.sandPerChunk = 84; - this.rainfall = 0.1F; - this.waterColorMultiplier = 13434879; - setHeight(new BiomeGenBase.Height(0.15F, 0.45F)); - this.rootHeight = -0.25f; //Ground level + public void preInit(FMLPreInitializationEvent event) {} - this.spawnableMonsterList.clear(); - this.spawnableCreatureList.clear(); - this.spawnableWaterCreatureList.clear(); - this.spawnableCaveCreatureList.clear(); + static class BiomeGenAustralianDesert extends BiomeGenBase { + @SuppressWarnings("unchecked") + public BiomeGenAustralianDesert() { + super(CORE.AUSTRALIA_BIOME_DESERT_1_ID); + this.setBiomeName("Australian Desert"); + // this.setBiomeID(); + this.enableRain = true; + this.enableSnow = false; + this.topBlock = blockTopLayer; + this.fillerBlock = blockSecondLayer; + // this.theBiomeDecorator = new BiomeGenerator_Custom(); + this.theBiomeDecorator.generateLakes = true; + this.theBiomeDecorator.treesPerChunk = 20; + this.theBiomeDecorator.flowersPerChunk = 0; + this.theBiomeDecorator.grassPerChunk = 5; + this.theBiomeDecorator.deadBushPerChunk = 63; + this.theBiomeDecorator.mushroomsPerChunk = 0; + this.theBiomeDecorator.reedsPerChunk = 42; + this.theBiomeDecorator.cactiPerChunk = 56; + this.theBiomeDecorator.sandPerChunk = 84; + this.rainfall = 0.1F; + this.waterColorMultiplier = 13434879; + setHeight(new BiomeGenBase.Height(0.15F, 0.45F)); + this.rootHeight = -0.25f; // Ground level - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySilverfish.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 5, 1, 5)); - - this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); - } + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySilverfish.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 5, 1, 5)); - private synchronized boolean setBiomeID() { - try { - Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); - Field mClone = mInternalBiomeList; - BiomeGenBase[] mOriginalList = (BiomeGenBase[]) mInternalBiomeList.get(null); - BiomeGenBase[] mTempList = new BiomeGenBase[mOriginalList.length]; - for (int index=0;index<mTempList.length;index++) { - mTempList[index] = mOriginalList[index]; - } - if (mTempList != null){ - mTempList[CORE.AUSTRALIA_BIOME_DESERT_1_ID] = this; - mInternalBiomeList.set(null, mTempList); - if (mTempList != mInternalBiomeList.get(null)){ - ReflectionUtils.setFinalFieldValue(BiomeGenBase.class, mInternalBiomeList, mTempList); - Logger.REFLECTION("Set Biome ID for "+this.biomeName+" Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); - return true; - } - else { - Logger.REFLECTION("Failed to set Biome ID for "+this.biomeName+" Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); - } - } - return false; - } - catch (Exception e) { - Logger.REFLECTION("Could not access 'biomeList' field in "+BiomeGenBase.class.getCanonicalName()+"."); - e.printStackTrace(); - return false; - } - } + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + } - @SideOnly(Side.CLIENT) - public int getBiomeGrassColor() { - return 6697728; - } + private synchronized boolean setBiomeID() { + try { + Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); + Field mClone = mInternalBiomeList; + BiomeGenBase[] mOriginalList = (BiomeGenBase[]) mInternalBiomeList.get(null); + BiomeGenBase[] mTempList = new BiomeGenBase[mOriginalList.length]; + for (int index = 0; index < mTempList.length; index++) { + mTempList[index] = mOriginalList[index]; + } + if (mTempList != null) { + mTempList[CORE.AUSTRALIA_BIOME_DESERT_1_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mTempList != mInternalBiomeList.get(null)) { + ReflectionUtils.setFinalFieldValue(BiomeGenBase.class, mInternalBiomeList, mTempList); + Logger.REFLECTION( + "Set Biome ID for " + this.biomeName + " Biome internally in 'biomeList' field from " + + BiomeGenBase.class.getCanonicalName() + "."); + return true; + } else { + Logger.REFLECTION("Failed to set Biome ID for " + this.biomeName + + " Biome internally in 'biomeList' field from " + BiomeGenBase.class.getCanonicalName() + + "."); + } + } + return false; + } catch (Exception e) { + Logger.REFLECTION( + "Could not access 'biomeList' field in " + BiomeGenBase.class.getCanonicalName() + "."); + e.printStackTrace(); + return false; + } + } - @SideOnly(Side.CLIENT) - public int getBiomeFoliageColor() { - return 6697728; - } + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor() { + return 6697728; + } - @SideOnly(Side.CLIENT) - public int getSkyColorByTemp(float par1) { - return 13421772; - } + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor() { + return 6697728; + } - @SuppressWarnings({ "unchecked", "unused" }) - private boolean addToMonsterSpawnLists(Class<?> EntityClass, int a, int b, int c){ - //this.spawnableMonsterList.add(new SpawnListEntry(EntityClass, a, b, c)); - this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityClass, a, b, c)); - return true; - } - - @Override - public WorldGenAbstractTree func_150567_a(Random par1Random){ - return (WorldGenAbstractTree)(getRandomWorldGenForTrees(par1Random)); - } - + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) { + return 13421772; + } - //TODO - DOES THIS WORK? - public WorldGenerator getRandomWorldGenForTrees(Random par1Random) - { - return new Tree(); - } + @SuppressWarnings({"unchecked", "unused"}) + private boolean addToMonsterSpawnLists(Class<?> EntityClass, int a, int b, int c) { + // this.spawnableMonsterList.add(new SpawnListEntry(EntityClass, a, b, c)); + this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityClass, a, b, c)); + return true; + } - class Tree - extends WorldGenAbstractTree - { - private final int minTreeHeight; - private final boolean vinesGrow; - private final int metaWood; - private final int metaLeaves; + @Override + public WorldGenAbstractTree func_150567_a(Random par1Random) { + return (WorldGenAbstractTree) (getRandomWorldGenForTrees(par1Random)); + } - public Tree() - { - super(false); - this.minTreeHeight = 5; - this.metaWood = 0; - this.metaLeaves = 0; - this.vinesGrow = false; - } + // TODO - DOES THIS WORK? + public WorldGenerator getRandomWorldGenForTrees(Random par1Random) { + return new Tree(); + } - public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) - { - int var6 = par2Random.nextInt(3) + this.minTreeHeight; - boolean var7 = true; - if ((par4 >= 1) && (par4 + var6 + 1 <= 256)) - { - for (int var8 = par4; var8 <= par4 + 1 + var6; var8++) - { - byte var9 = 1; - if (var8 == par4) { - var9 = 0; - } - if (var8 >= par4 + 1 + var6 - 2) { - var9 = 2; - } - for (int var10 = par3 - var9; (var10 <= par3 + var9) && (var7); var10++) { - for (int var11 = par5 - var9; (var11 <= par5 + var9) && (var7); var11++) { - if ((var8 >= 0) && (var8 < 256)) - { - Block var12s = par1World.getBlock(var10, var8, var11); - int var12 = Block.getIdFromBlock(var12s); - if ((var12 != 0) && (var12s != Blocks.air) && (var12s != Blocks.grass) && (var12s != Blocks.dirt) && (var12s != Blocks.cactus)) { - var7 = false; - } - } - else - { - var7 = false; - } - } - } - } - if (!var7) { - return false; - } - Block var8s = par1World.getBlock(par3, par4 - 1, par5); - int var8 = Block.getIdFromBlock(var8s); - if (((var8s == Blocks.grass) || (var8s == Blocks.dirt)) && (par4 < 256 - var6 - 1)) - { - par1World.setBlock(par3, par4 - 1, par5, Blocks.dirt, 0, 2); - byte var9 = 3; - byte var18 = 0; - for (int var11 = par4 - var9 + var6; var11 <= par4 + var6; var11++) - { - int var12 = var11 - (par4 + var6); - int var13 = var18 + 1 - var12 / 2; - for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) - { - int var15 = var14 - par3; - for (int var16 = par5 - var13; var16 <= par5 + var13; var16++) - { - int var17 = var16 - par5; - if ((Math.abs(var15) != var13) || (Math.abs(var17) != var13) || ((par2Random.nextInt(2) != 0) && (var12 != 0))) { - par1World.setBlock(var14, var11, var16, Blocks.air, this.metaLeaves, 2); - } - } - } - } - for (int var11 = 0; var11 < var6; var11++) - { - Block var12s = par1World.getBlock(par3, par4 + var11, par5); - int var12 = Block.getIdFromBlock(var12s); - if ((var12 == 0) || (var12s == Blocks.air)) - { - par1World.setBlock(par3, par4 + var11, par5, Blocks.cactus, this.metaWood, 2); - if ((this.vinesGrow) && (var11 > 0)) - { - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3 - 1, par4 + var11, par5))) { - par1World.setBlock(par3 - 1, par4 + var11, par5, Blocks.air, 8, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3 + 1, par4 + var11, par5))) { - par1World.setBlock(par3 + 1, par4 + var11, par5, Blocks.air, 2, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3, par4 + var11, par5 - 1))) { - par1World.setBlock(par3, par4 + var11, par5 - 1, Blocks.air, 1, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3, par4 + var11, par5 + 1))) { - par1World.setBlock(par3, par4 + var11, par5 + 1, Blocks.air, 4, 2); - } - } - } - } - if (this.vinesGrow) - { - for (int var11 = par4 - 3 + var6; var11 <= par4 + var6; var11++) - { - int var12 = var11 - (par4 + var6); - int var13 = 2 - var12 / 2; - for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { - for (int var15 = par5 - var13; var15 <= par5 + var13; var15++) { - if (par1World.getBlock(var14, var11, var15) == Blocks.air) - { - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14 - 1, var11, var15)) == 0)) { - growVines(par1World, var14 - 1, var11, var15, 8); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14 + 1, var11, var15)) == 0)) { - growVines(par1World, var14 + 1, var11, var15, 2); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14, var11, var15 - 1)) == 0)) { - growVines(par1World, var14, var11, var15 - 1, 1); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14, var11, var15 + 1)) == 0)) { - growVines(par1World, var14, var11, var15 + 1, 4); - } - } - } - } - } - if ((par2Random.nextInt(5) == 0) && (var6 > 5)) { - for (int var11 = 0; var11 < 2; var11++) { - for (int var12 = 0; var12 < 4; var12++) { - if (par2Random.nextInt(4 - var11) == 0) - { - int var13 = par2Random.nextInt(3); - par1World.setBlock(par3 + net.minecraft.util.Direction.offsetX[net.minecraft.util.Direction.rotateOpposite[var12]], par4 + var6 - 5 + var11, par5 + net.minecraft.util.Direction.offsetZ[net.minecraft.util.Direction.rotateOpposite[var12]], Blocks.air, var13 << 2 | var12, 2); - } - } - } - } - } - return true; - } - return false; - } - return false; - } + class Tree extends WorldGenAbstractTree { + private final int minTreeHeight; + private final boolean vinesGrow; + private final int metaWood; + private final int metaLeaves; - private void growVines(World par1World, int par2, int par3, int par4, int par5) - { - par1World.setBlock(par2, par3, par4, Blocks.vine, par5, 2); - int var6 = 4; - for (;;) - { - par3--; - if ((Block.getIdFromBlock(par1World.getBlock(par2, par3, par4)) != 0) || (var6 <= 0)) { - return; - } - par1World.setBlock(par2, par3, par4, Blocks.air, par5, 2); - var6--; - } - } - } + public Tree() { + super(false); + this.minTreeHeight = 5; + this.metaWood = 0; + this.metaLeaves = 0; + this.vinesGrow = false; + } - } + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { + int var6 = par2Random.nextInt(3) + this.minTreeHeight; + boolean var7 = true; + if ((par4 >= 1) && (par4 + var6 + 1 <= 256)) { + for (int var8 = par4; var8 <= par4 + 1 + var6; var8++) { + byte var9 = 1; + if (var8 == par4) { + var9 = 0; + } + if (var8 >= par4 + 1 + var6 - 2) { + var9 = 2; + } + for (int var10 = par3 - var9; (var10 <= par3 + var9) && (var7); var10++) { + for (int var11 = par5 - var9; (var11 <= par5 + var9) && (var7); var11++) { + if ((var8 >= 0) && (var8 < 256)) { + Block var12s = par1World.getBlock(var10, var8, var11); + int var12 = Block.getIdFromBlock(var12s); + if ((var12 != 0) + && (var12s != Blocks.air) + && (var12s != Blocks.grass) + && (var12s != Blocks.dirt) + && (var12s != Blocks.cactus)) { + var7 = false; + } + } else { + var7 = false; + } + } + } + } + if (!var7) { + return false; + } + Block var8s = par1World.getBlock(par3, par4 - 1, par5); + int var8 = Block.getIdFromBlock(var8s); + if (((var8s == Blocks.grass) || (var8s == Blocks.dirt)) && (par4 < 256 - var6 - 1)) { + par1World.setBlock(par3, par4 - 1, par5, Blocks.dirt, 0, 2); + byte var9 = 3; + byte var18 = 0; + for (int var11 = par4 - var9 + var6; var11 <= par4 + var6; var11++) { + int var12 = var11 - (par4 + var6); + int var13 = var18 + 1 - var12 / 2; + for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { + int var15 = var14 - par3; + for (int var16 = par5 - var13; var16 <= par5 + var13; var16++) { + int var17 = var16 - par5; + if ((Math.abs(var15) != var13) + || (Math.abs(var17) != var13) + || ((par2Random.nextInt(2) != 0) && (var12 != 0))) { + par1World.setBlock(var14, var11, var16, Blocks.air, this.metaLeaves, 2); + } + } + } + } + for (int var11 = 0; var11 < var6; var11++) { + Block var12s = par1World.getBlock(par3, par4 + var11, par5); + int var12 = Block.getIdFromBlock(var12s); + if ((var12 == 0) || (var12s == Blocks.air)) { + par1World.setBlock(par3, par4 + var11, par5, Blocks.cactus, this.metaWood, 2); + if ((this.vinesGrow) && (var11 > 0)) { + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3 - 1, par4 + var11, par5))) { + par1World.setBlock(par3 - 1, par4 + var11, par5, Blocks.air, 8, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3 + 1, par4 + var11, par5))) { + par1World.setBlock(par3 + 1, par4 + var11, par5, Blocks.air, 2, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3, par4 + var11, par5 - 1))) { + par1World.setBlock(par3, par4 + var11, par5 - 1, Blocks.air, 1, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3, par4 + var11, par5 + 1))) { + par1World.setBlock(par3, par4 + var11, par5 + 1, Blocks.air, 4, 2); + } + } + } + } + if (this.vinesGrow) { + for (int var11 = par4 - 3 + var6; var11 <= par4 + var6; var11++) { + int var12 = var11 - (par4 + var6); + int var13 = 2 - var12 / 2; + for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { + for (int var15 = par5 - var13; var15 <= par5 + var13; var15++) { + if (par1World.getBlock(var14, var11, var15) == Blocks.air) { + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14 - 1, var11, var15)) + == 0)) { + growVines(par1World, var14 - 1, var11, var15, 8); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14 + 1, var11, var15)) + == 0)) { + growVines(par1World, var14 + 1, var11, var15, 2); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14, var11, var15 - 1)) + == 0)) { + growVines(par1World, var14, var11, var15 - 1, 1); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14, var11, var15 + 1)) + == 0)) { + growVines(par1World, var14, var11, var15 + 1, 4); + } + } + } + } + } + if ((par2Random.nextInt(5) == 0) && (var6 > 5)) { + for (int var11 = 0; var11 < 2; var11++) { + for (int var12 = 0; var12 < 4; var12++) { + if (par2Random.nextInt(4 - var11) == 0) { + int var13 = par2Random.nextInt(3); + par1World.setBlock( + par3 + + net.minecraft.util.Direction.offsetX[ + net.minecraft.util.Direction.rotateOpposite[var12]], + par4 + var6 - 5 + var11, + par5 + + net.minecraft.util.Direction.offsetZ[ + net.minecraft.util.Direction.rotateOpposite[var12]], + Blocks.air, + var13 << 2 | var12, + 2); + } + } + } + } + } + return true; + } + return false; + } + return false; + } + private void growVines(World par1World, int par2, int par3, int par4, int par5) { + par1World.setBlock(par2, par3, par4, Blocks.vine, par5, 2); + int var6 = 4; + for (; ; ) { + par3--; + if ((Block.getIdFromBlock(par1World.getBlock(par2, par3, par4)) != 0) || (var6 <= 0)) { + return; + } + par1World.setBlock(par2, par3, par4, Blocks.air, par5, 2); + var6--; + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert2.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert2.java index 2ac11bb412..4704b97be6 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert2.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert2.java @@ -1,8 +1,5 @@ package gtPlusPlus.australia.biome.type; -import java.lang.reflect.Field; -import java.util.Random; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.relauncher.Side; @@ -11,6 +8,8 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntitySilverfish; @@ -30,326 +29,324 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenAbstractTree; -import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeManager; public class Biome_AustralianDesert2 { - public static BiomeGenAustralianDesert2 biome = new BiomeGenAustralianDesert2(); - - public Object instance; + public static BiomeGenAustralianDesert2 biome = new BiomeGenAustralianDesert2(); - public static Block blockTopLayer; - public static Block blockSecondLayer; - public static Block blockMainFiller = Blocks.stone; - public static Block blockSecondaryFiller; - public static Block blockFluidLakes; + public Object instance; - public Biome_AustralianDesert2() { - } + public static Block blockTopLayer; + public static Block blockSecondLayer; + public static Block blockMainFiller = Blocks.stone; + public static Block blockSecondaryFiller; + public static Block blockFluidLakes; - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); - BiomeManager.addSpawnBiome(biome); - } + public Biome_AustralianDesert2() {} - public void generateNether(World world, Random random, int chunkX, int chunkZ) { - } + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); + BiomeManager.addSpawnBiome(biome); + } - public void generateSurface(World world, Random random, int chunkX, int chunkZ) { - } + public void generateNether(World world, Random random, int chunkX, int chunkZ) {} - public void registerRenderers() { - } + public void generateSurface(World world, Random random, int chunkX, int chunkZ) {} - public int addFuel(ItemStack fuel) { - return 0; - } + public void registerRenderers() {} - public void serverLoad(FMLServerStartingEvent event) { - } + public int addFuel(ItemStack fuel) { + return 0; + } - public void preInit(FMLPreInitializationEvent event) { - } + public void serverLoad(FMLServerStartingEvent event) {} - static class BiomeGenAustralianDesert2 extends BiomeGenBase { - @SuppressWarnings("unchecked") - public BiomeGenAustralianDesert2() { - super(CORE.AUSTRALIA_BIOME_DESERT_2_ID); - this.setBiomeName("Australian Desert II"); - //this.setBiomeID(); - this.enableRain = true; - this.enableSnow = false; - this.topBlock = blockTopLayer; - this.fillerBlock = blockSecondLayer; - //this.theBiomeDecorator = new BiomeGenerator_Custom(); - this.theBiomeDecorator.generateLakes = true; - this.theBiomeDecorator.treesPerChunk = 40; - this.theBiomeDecorator.flowersPerChunk = 0; - this.theBiomeDecorator.grassPerChunk = 0; - this.theBiomeDecorator.deadBushPerChunk = 63; - this.theBiomeDecorator.mushroomsPerChunk = 0; - this.theBiomeDecorator.reedsPerChunk = 42; - this.theBiomeDecorator.cactiPerChunk = 84; - this.theBiomeDecorator.sandPerChunk = 84; - this.rainfall = 0.1F; - this.waterColorMultiplier = 13434879; - setHeight(new BiomeGenBase.Height(0.10F, 0.35F)); - this.rootHeight = -0.15f; //Ground level + public void preInit(FMLPreInitializationEvent event) {} - this.spawnableMonsterList.clear(); - this.spawnableCreatureList.clear(); - this.spawnableWaterCreatureList.clear(); - this.spawnableCaveCreatureList.clear(); + static class BiomeGenAustralianDesert2 extends BiomeGenBase { + @SuppressWarnings("unchecked") + public BiomeGenAustralianDesert2() { + super(CORE.AUSTRALIA_BIOME_DESERT_2_ID); + this.setBiomeName("Australian Desert II"); + // this.setBiomeID(); + this.enableRain = true; + this.enableSnow = false; + this.topBlock = blockTopLayer; + this.fillerBlock = blockSecondLayer; + // this.theBiomeDecorator = new BiomeGenerator_Custom(); + this.theBiomeDecorator.generateLakes = true; + this.theBiomeDecorator.treesPerChunk = 40; + this.theBiomeDecorator.flowersPerChunk = 0; + this.theBiomeDecorator.grassPerChunk = 0; + this.theBiomeDecorator.deadBushPerChunk = 63; + this.theBiomeDecorator.mushroomsPerChunk = 0; + this.theBiomeDecorator.reedsPerChunk = 42; + this.theBiomeDecorator.cactiPerChunk = 84; + this.theBiomeDecorator.sandPerChunk = 84; + this.rainfall = 0.1F; + this.waterColorMultiplier = 13434879; + setHeight(new BiomeGenBase.Height(0.10F, 0.35F)); + this.rootHeight = -0.15f; // Ground level - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySilverfish.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 1, 5)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 5, 1, 5)); - - this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); - } + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySilverfish.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 1, 5)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 5, 1, 5)); - private synchronized boolean setBiomeID() { - try { - Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); - Field mClone = mInternalBiomeList; - BiomeGenBase[] mOriginalList = (BiomeGenBase[]) mInternalBiomeList.get(null); - BiomeGenBase[] mTempList = new BiomeGenBase[mOriginalList.length]; - for (int index=0;index<mTempList.length;index++) { - mTempList[index] = mOriginalList[index]; - } - if (mTempList != null){ - mTempList[CORE.AUSTRALIA_BIOME_DESERT_1_ID] = this; - mInternalBiomeList.set(null, mTempList); - if (mTempList != mInternalBiomeList.get(null)){ - ReflectionUtils.setFinalFieldValue(BiomeGenBase.class, mInternalBiomeList, mTempList); - Logger.REFLECTION("Set Biome ID for "+this.biomeName+" Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); - return true; - } - else { - Logger.REFLECTION("Failed to set Biome ID for "+this.biomeName+" Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); - } - } - return false; - } - catch (Exception e) { - Logger.REFLECTION("Could not access 'biomeList' field in "+BiomeGenBase.class.getCanonicalName()+"."); - e.printStackTrace(); - return false; - } - } + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + } - @SideOnly(Side.CLIENT) - public int getBiomeGrassColor() { - return 6697728; - } + private synchronized boolean setBiomeID() { + try { + Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); + Field mClone = mInternalBiomeList; + BiomeGenBase[] mOriginalList = (BiomeGenBase[]) mInternalBiomeList.get(null); + BiomeGenBase[] mTempList = new BiomeGenBase[mOriginalList.length]; + for (int index = 0; index < mTempList.length; index++) { + mTempList[index] = mOriginalList[index]; + } + if (mTempList != null) { + mTempList[CORE.AUSTRALIA_BIOME_DESERT_1_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mTempList != mInternalBiomeList.get(null)) { + ReflectionUtils.setFinalFieldValue(BiomeGenBase.class, mInternalBiomeList, mTempList); + Logger.REFLECTION( + "Set Biome ID for " + this.biomeName + " Biome internally in 'biomeList' field from " + + BiomeGenBase.class.getCanonicalName() + "."); + return true; + } else { + Logger.REFLECTION("Failed to set Biome ID for " + this.biomeName + + " Biome internally in 'biomeList' field from " + BiomeGenBase.class.getCanonicalName() + + "."); + } + } + return false; + } catch (Exception e) { + Logger.REFLECTION( + "Could not access 'biomeList' field in " + BiomeGenBase.class.getCanonicalName() + "."); + e.printStackTrace(); + return false; + } + } - @SideOnly(Side.CLIENT) - public int getBiomeFoliageColor() { - return 6697728; - } + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor() { + return 6697728; + } - @SideOnly(Side.CLIENT) - public int getSkyColorByTemp(float par1) { - return 13421772; - } + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor() { + return 6697728; + } - @SuppressWarnings({ "unchecked", "unused" }) - private boolean addToMonsterSpawnLists(Class<?> EntityClass, int a, int b, int c){ - //this.spawnableMonsterList.add(new SpawnListEntry(EntityClass, a, b, c)); - this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityClass, a, b, c)); - return true; - } - - @Override - public WorldGenAbstractTree func_150567_a(Random par1Random){ - boolean a = (MathUtils.randInt(0, 100) < MathUtils.randInt(30, 65)); - return a ? getRandomWorldGenForTrees(par1Random) : super.func_150567_a(par1Random); - } + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) { + return 13421772; + } - //TODO - DOES THIS WORK? - public WorldGenAbstractTree getRandomWorldGenForTrees(Random par1Random) - { - return new Tree(); - } + @SuppressWarnings({"unchecked", "unused"}) + private boolean addToMonsterSpawnLists(Class<?> EntityClass, int a, int b, int c) { + // this.spawnableMonsterList.add(new SpawnListEntry(EntityClass, a, b, c)); + this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityClass, a, b, c)); + return true; + } - class Tree - extends WorldGenAbstractTree - { - private final int minTreeHeight; - private final boolean vinesGrow; - private final int metaWood; - private final int metaLeaves; + @Override + public WorldGenAbstractTree func_150567_a(Random par1Random) { + boolean a = (MathUtils.randInt(0, 100) < MathUtils.randInt(30, 65)); + return a ? getRandomWorldGenForTrees(par1Random) : super.func_150567_a(par1Random); + } - public Tree() - { - super(false); - this.minTreeHeight = 3; - this.metaWood = 0; - this.metaLeaves = 0; - this.vinesGrow = false; - } + // TODO - DOES THIS WORK? + public WorldGenAbstractTree getRandomWorldGenForTrees(Random par1Random) { + return new Tree(); + } - public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) - { - int var6 = par2Random.nextInt(3) + this.minTreeHeight; - boolean var7 = true; - if ((par4 >= 1) && (par4 + var6 + 1 <= 256)) - { - for (int var8 = par4; var8 <= par4 + 1 + var6; var8++) - { - byte var9 = 1; - if (var8 == par4) { - var9 = 0; - } - if (var8 >= par4 + 1 + var6 - 2) { - var9 = 2; - } - for (int var10 = par3 - var9; (var10 <= par3 + var9) && (var7); var10++) { - for (int var11 = par5 - var9; (var11 <= par5 + var9) && (var7); var11++) { - if ((var8 >= 0) && (var8 < 256)) - { - Block var12s = par1World.getBlock(var10, var8, var11); - int var12 = Block.getIdFromBlock(var12s); - if ((var12 != 0) && (var12s != Blocks.air) && (var12s != Blocks.grass) && (var12s != Blocks.dirt) && (var12s != Blocks.cactus)) { - var7 = false; - } - } - else - { - var7 = false; - } - } - } - } - if (!var7) { - return false; - } - Block var8s = par1World.getBlock(par3, par4 - 1, par5); - int var8 = Block.getIdFromBlock(var8s); - if (((var8s == Blocks.grass) || (var8s == Blocks.dirt)) && (par4 < 256 - var6 - 1)) - { - par1World.setBlock(par3, par4 - 1, par5, Blocks.dirt, 0, 2); - byte var9 = 3; - byte var18 = 0; - for (int var11 = par4 - var9 + var6; var11 <= par4 + var6; var11++) - { - int var12 = var11 - (par4 + var6); - int var13 = var18 + 1 - var12 / 2; - for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) - { - int var15 = var14 - par3; - for (int var16 = par5 - var13; var16 <= par5 + var13; var16++) - { - int var17 = var16 - par5; - if ((Math.abs(var15) != var13) || (Math.abs(var17) != var13) || ((par2Random.nextInt(2) != 0) && (var12 != 0))) { - par1World.setBlock(var14, var11, var16, Blocks.air, this.metaLeaves, 2); - } - } - } - } - for (int var11 = 0; var11 < var6; var11++) - { - Block var12s = par1World.getBlock(par3, par4 + var11, par5); - int var12 = Block.getIdFromBlock(var12s); - if ((var12 == 0) || (var12s == Blocks.air)) - { - par1World.setBlock(par3, par4 + var11, par5, Blocks.cactus, this.metaWood, 2); - if ((this.vinesGrow) && (var11 > 0)) - { - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3 - 1, par4 + var11, par5))) { - par1World.setBlock(par3 - 1, par4 + var11, par5, Blocks.air, 8, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3 + 1, par4 + var11, par5))) { - par1World.setBlock(par3 + 1, par4 + var11, par5, Blocks.air, 2, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3, par4 + var11, par5 - 1))) { - par1World.setBlock(par3, par4 + var11, par5 - 1, Blocks.air, 1, 2); - } - if ((par2Random.nextInt(3) > 0) && (par1World.isAirBlock(par3, par4 + var11, par5 + 1))) { - par1World.setBlock(par3, par4 + var11, par5 + 1, Blocks.air, 4, 2); - } - } - } - } - if (this.vinesGrow) - { - for (int var11 = par4 - 3 + var6; var11 <= par4 + var6; var11++) - { - int var12 = var11 - (par4 + var6); - int var13 = 2 - var12 / 2; - for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { - for (int var15 = par5 - var13; var15 <= par5 + var13; var15++) { - if (par1World.getBlock(var14, var11, var15) == Blocks.air) - { - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14 - 1, var11, var15)) == 0)) { - growVines(par1World, var14 - 1, var11, var15, 8); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14 + 1, var11, var15)) == 0)) { - growVines(par1World, var14 + 1, var11, var15, 2); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14, var11, var15 - 1)) == 0)) { - growVines(par1World, var14, var11, var15 - 1, 1); - } - if ((par2Random.nextInt(4) == 0) && - (Block.getIdFromBlock(par1World.getBlock(var14, var11, var15 + 1)) == 0)) { - growVines(par1World, var14, var11, var15 + 1, 4); - } - } - } - } - } - if ((par2Random.nextInt(5) == 0) && (var6 > 5)) { - for (int var11 = 0; var11 < 2; var11++) { - for (int var12 = 0; var12 < 4; var12++) { - if (par2Random.nextInt(4 - var11) == 0) - { - int var13 = par2Random.nextInt(3); - par1World.setBlock(par3 + net.minecraft.util.Direction.offsetX[net.minecraft.util.Direction.rotateOpposite[var12]], par4 + var6 - 5 + var11, par5 + net.minecraft.util.Direction.offsetZ[net.minecraft.util.Direction.rotateOpposite[var12]], Blocks.air, var13 << 2 | var12, 2); - } - } - } - } - } - return true; - } - return false; - } - return false; - } + class Tree extends WorldGenAbstractTree { + private final int minTreeHeight; + private final boolean vinesGrow; + private final int metaWood; + private final int metaLeaves; - private void growVines(World par1World, int par2, int par3, int par4, int par5) - { - par1World.setBlock(par2, par3, par4, Blocks.vine, par5, 2); - int var6 = 4; - for (;;) - { - par3--; - if ((Block.getIdFromBlock(par1World.getBlock(par2, par3, par4)) != 0) || (var6 <= 0)) { - return; - } - par1World.setBlock(par2, par3, par4, Blocks.air, par5, 2); - var6--; - } - } - } + public Tree() { + super(false); + this.minTreeHeight = 3; + this.metaWood = 0; + this.metaLeaves = 0; + this.vinesGrow = false; + } - } + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { + int var6 = par2Random.nextInt(3) + this.minTreeHeight; + boolean var7 = true; + if ((par4 >= 1) && (par4 + var6 + 1 <= 256)) { + for (int var8 = par4; var8 <= par4 + 1 + var6; var8++) { + byte var9 = 1; + if (var8 == par4) { + var9 = 0; + } + if (var8 >= par4 + 1 + var6 - 2) { + var9 = 2; + } + for (int var10 = par3 - var9; (var10 <= par3 + var9) && (var7); var10++) { + for (int var11 = par5 - var9; (var11 <= par5 + var9) && (var7); var11++) { + if ((var8 >= 0) && (var8 < 256)) { + Block var12s = par1World.getBlock(var10, var8, var11); + int var12 = Block.getIdFromBlock(var12s); + if ((var12 != 0) + && (var12s != Blocks.air) + && (var12s != Blocks.grass) + && (var12s != Blocks.dirt) + && (var12s != Blocks.cactus)) { + var7 = false; + } + } else { + var7 = false; + } + } + } + } + if (!var7) { + return false; + } + Block var8s = par1World.getBlock(par3, par4 - 1, par5); + int var8 = Block.getIdFromBlock(var8s); + if (((var8s == Blocks.grass) || (var8s == Blocks.dirt)) && (par4 < 256 - var6 - 1)) { + par1World.setBlock(par3, par4 - 1, par5, Blocks.dirt, 0, 2); + byte var9 = 3; + byte var18 = 0; + for (int var11 = par4 - var9 + var6; var11 <= par4 + var6; var11++) { + int var12 = var11 - (par4 + var6); + int var13 = var18 + 1 - var12 / 2; + for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { + int var15 = var14 - par3; + for (int var16 = par5 - var13; var16 <= par5 + var13; var16++) { + int var17 = var16 - par5; + if ((Math.abs(var15) != var13) + || (Math.abs(var17) != var13) + || ((par2Random.nextInt(2) != 0) && (var12 != 0))) { + par1World.setBlock(var14, var11, var16, Blocks.air, this.metaLeaves, 2); + } + } + } + } + for (int var11 = 0; var11 < var6; var11++) { + Block var12s = par1World.getBlock(par3, par4 + var11, par5); + int var12 = Block.getIdFromBlock(var12s); + if ((var12 == 0) || (var12s == Blocks.air)) { + par1World.setBlock(par3, par4 + var11, par5, Blocks.cactus, this.metaWood, 2); + if ((this.vinesGrow) && (var11 > 0)) { + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3 - 1, par4 + var11, par5))) { + par1World.setBlock(par3 - 1, par4 + var11, par5, Blocks.air, 8, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3 + 1, par4 + var11, par5))) { + par1World.setBlock(par3 + 1, par4 + var11, par5, Blocks.air, 2, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3, par4 + var11, par5 - 1))) { + par1World.setBlock(par3, par4 + var11, par5 - 1, Blocks.air, 1, 2); + } + if ((par2Random.nextInt(3) > 0) + && (par1World.isAirBlock(par3, par4 + var11, par5 + 1))) { + par1World.setBlock(par3, par4 + var11, par5 + 1, Blocks.air, 4, 2); + } + } + } + } + if (this.vinesGrow) { + for (int var11 = par4 - 3 + var6; var11 <= par4 + var6; var11++) { + int var12 = var11 - (par4 + var6); + int var13 = 2 - var12 / 2; + for (int var14 = par3 - var13; var14 <= par3 + var13; var14++) { + for (int var15 = par5 - var13; var15 <= par5 + var13; var15++) { + if (par1World.getBlock(var14, var11, var15) == Blocks.air) { + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14 - 1, var11, var15)) + == 0)) { + growVines(par1World, var14 - 1, var11, var15, 8); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14 + 1, var11, var15)) + == 0)) { + growVines(par1World, var14 + 1, var11, var15, 2); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14, var11, var15 - 1)) + == 0)) { + growVines(par1World, var14, var11, var15 - 1, 1); + } + if ((par2Random.nextInt(4) == 0) + && (Block.getIdFromBlock( + par1World.getBlock(var14, var11, var15 + 1)) + == 0)) { + growVines(par1World, var14, var11, var15 + 1, 4); + } + } + } + } + } + if ((par2Random.nextInt(5) == 0) && (var6 > 5)) { + for (int var11 = 0; var11 < 2; var11++) { + for (int var12 = 0; var12 < 4; var12++) { + if (par2Random.nextInt(4 - var11) == 0) { + int var13 = par2Random.nextInt(3); + par1World.setBlock( + par3 + + net.minecraft.util.Direction.offsetX[ + net.minecraft.util.Direction.rotateOpposite[var12]], + par4 + var6 - 5 + var11, + par5 + + net.minecraft.util.Direction.offsetZ[ + net.minecraft.util.Direction.rotateOpposite[var12]], + Blocks.air, + var13 << 2 | var12, + 2); + } + } + } + } + } + return true; + } + return false; + } + return false; + } + private void growVines(World par1World, int par2, int par3, int par4, int par5) { + par1World.setBlock(par2, par3, par4, Blocks.vine, par5, 2); + int var6 = 4; + for (; ; ) { + par3--; + if ((Block.getIdFromBlock(par1World.getBlock(par2, par3, par4)) != 0) || (var6 <= 0)) { + return; + } + par1World.setBlock(par2, par3, par4, Blocks.air, par5, 2); + var6--; + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert_Ex.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert_Ex.java index bfb0fb8631..476e990b3c 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert_Ex.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianDesert_Ex.java @@ -1,9 +1,8 @@ package gtPlusPlus.australia.biome.type; -import java.util.Random; - import gtPlusPlus.australia.biome.CustomDecorator; import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; @@ -14,8 +13,7 @@ import net.minecraftforge.common.BiomeManager; public class Biome_AustralianDesert_Ex extends BiomeGenDesert { - public Biome_AustralianDesert_Ex(int aID) - { + public Biome_AustralianDesert_Ex(int aID) { super(aID); this.spawnableCreatureList.clear(); this.topBlock = Blocks.sand; @@ -23,30 +21,29 @@ public class Biome_AustralianDesert_Ex extends BiomeGenDesert { this.theBiomeDecorator.treesPerChunk = -999; this.theBiomeDecorator.deadBushPerChunk = 2; this.theBiomeDecorator.reedsPerChunk = 50; - this.theBiomeDecorator.cactiPerChunk = 20; + this.theBiomeDecorator.cactiPerChunk = 20; this.setColor(16421912); this.setBiomeName("Australian Desert III"); this.setDisableRain(); this.setTemperatureRainfall(2.0F, 0.0F); - this.setHeight(height_LowPlains); + this.setHeight(height_LowPlains); this.spawnableCreatureList.clear(); } - public static Biome_AustralianDesert_Ex biome = new Biome_AustralianDesert_Ex(CORE.AUSTRALIA_BIOME_DESERT_3_ID); - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); - BiomeManager.addSpawnBiome(biome); - } + public static Biome_AustralianDesert_Ex biome = new Biome_AustralianDesert_Ex(CORE.AUSTRALIA_BIOME_DESERT_3_ID); - public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) - { + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); + BiomeManager.addSpawnBiome(biome); + } + + public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) { super.decorate(p_76728_1_, p_76728_2_, p_76728_3_, p_76728_4_); - if (p_76728_2_.nextInt(850) == 0) - { + if (p_76728_2_.nextInt(850) == 0) { int k = p_76728_3_ + p_76728_2_.nextInt(16) + 8; int l = p_76728_4_ + p_76728_2_.nextInt(16) + 8; WorldGenDesertWells worldgendesertwells = new WorldGenDesertWells(); @@ -54,12 +51,11 @@ public class Biome_AustralianDesert_Ex extends BiomeGenDesert { } } - /** - * Allocate a new BiomeDecorator for this BiomeGenBase - */ - @Override - public BiomeDecorator createBiomeDecorator() - { - return getModdedBiomeDecorator(new CustomDecorator()); - } -}
\ No newline at end of file + /** + * Allocate a new BiomeDecorator for this BiomeGenBase + */ + @Override + public BiomeDecorator createBiomeDecorator() { + return getModdedBiomeDecorator(new CustomDecorator()); + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianForest.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianForest.java index c00fd5edef..ed828ed09a 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianForest.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianForest.java @@ -6,7 +6,6 @@ import gtPlusPlus.australia.biome.CustomDecorator; import gtPlusPlus.australia.gen.world.WorldGenAustralianTrees; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; - import java.util.Random; import net.minecraft.block.BlockFlower; import net.minecraft.entity.passive.EntityWolf; @@ -24,175 +23,168 @@ import net.minecraftforge.common.BiomeManager; public class Biome_AustralianForest extends BiomeGenForest { - private int mWoodMeta; - protected static final WorldGenForest mGenTreeForest = new WorldGenForest(false, true); - protected static final WorldGenForest mGenTreeForest2 = new WorldGenForest(false, false); - protected static final WorldGenCanopyTree mGenTreeCanopy = new WorldGenCanopyTree(false); - protected static final WorldGenAustralianTrees mGenTreeAustralian = new WorldGenAustralianTrees(true); - - public static Biome_AustralianForest biome = new Biome_AustralianForest(CORE.AUSTRALIA_BIOME_FOREST_ID, 2); - - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.FOREST); - BiomeManager.addSpawnBiome(biome); - } - - public Biome_AustralianForest(int p_i45377_1_, int aWoodMeta) { - super(p_i45377_1_, aWoodMeta); - this.mWoodMeta = aWoodMeta; - this.setColor(353825); - this.setBiomeName("Australian Forest"); - this.setTemperatureRainfall(1.1F, 0.75F); - this.theBiomeDecorator.treesPerChunk = 16; - this.theBiomeDecorator.grassPerChunk = 5; - this.theBiomeDecorator.flowersPerChunk = 2; - this.func_76733_a(5159473); - this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 4, 4)); - } - - public BiomeGenBase func_150557_a(int p_150557_1_, boolean p_150557_2_) { - if (this.mWoodMeta == 2) { - this.field_150609_ah = 353825; - this.color = p_150557_1_; - - if (p_150557_2_) { - this.field_150609_ah = (this.field_150609_ah & 16711422) >> 1; - } - - return this; - } else { - return super.func_150557_a(p_150557_1_, p_150557_2_); - } - } - - public WorldGenAbstractTree func_150567_a(Random p_150567_1_) { - int mTreeType = MathUtils.getRandomFromArray(new int[] { - 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5 - }); - if (mTreeType == 0) { - return mGenTreeCanopy; - } - else if (mTreeType == 1) { - return mGenTreeAustralian; - } - else if (mTreeType == 2) { - return mGenTreeForest; - } - else if (mTreeType == 3) { - return mGenTreeForest2; - } - else if (mTreeType == 4) { - return this.worldGeneratorSwamp; - } - else { - return MathUtils.randInt(0, 1) == 0 ? this.worldGeneratorTrees : this.worldGeneratorBigTree; - } - } - - public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) { - if (this.mWoodMeta == 1) { - double d0 = MathHelper.clamp_double( - (1.0D + plantNoise.func_151601_a((double) p_150572_2_ / 48.0D, (double) p_150572_4_ / 48.0D)) - / 2.0D, - 0.0D, 0.9999D); - int l = (int) (d0 * (double) BlockFlower.field_149859_a.length); - - if (l == 1) { - l = 0; - } - - return BlockFlower.field_149859_a[l]; - } else { - return super.func_150572_a(p_150572_1_, p_150572_2_, p_150572_3_, p_150572_4_); - } - } - - public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) { - int k; - int l; - int i1; - int j1; - int k1; - - if (this.mWoodMeta == 3) { - for (k = 0; k < 4; ++k) { - for (l = 0; l < 4; ++l) { - i1 = p_76728_3_ + k * 4 + 1 + 8 + p_76728_2_.nextInt(3); - j1 = p_76728_4_ + l * 4 + 1 + 8 + p_76728_2_.nextInt(3); - k1 = p_76728_1_.getHeightValue(i1, j1); - - if (p_76728_2_.nextInt(20) == 0) { - WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom(); - worldgenbigmushroom.generate(p_76728_1_, p_76728_2_, i1, k1, j1); - } else { - WorldGenAbstractTree worldgenabstracttree = this.func_150567_a(p_76728_2_); - worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); - - if (worldgenabstracttree.generate(p_76728_1_, p_76728_2_, i1, k1, j1)) { - worldgenabstracttree.func_150524_b(p_76728_1_, p_76728_2_, i1, k1, j1); - } - } - } - } - } - - k = p_76728_2_.nextInt(5) - 3; - - if (this.mWoodMeta == 1) { - k += 2; - } - - l = 0; - - while (l < k) { - i1 = p_76728_2_.nextInt(3); - - if (i1 == 0) { - genTallFlowers.func_150548_a(1); - } else if (i1 == 1) { - genTallFlowers.func_150548_a(4); - } else if (i1 == 2) { - genTallFlowers.func_150548_a(5); - } - - j1 = 0; - - while (true) { - if (j1 < 5) { - k1 = p_76728_3_ + p_76728_2_.nextInt(16) + 8; - int i2 = p_76728_4_ + p_76728_2_.nextInt(16) + 8; - int l1 = p_76728_2_.nextInt(p_76728_1_.getHeightValue(k1, i2) + 32); - - if (!genTallFlowers.generate(p_76728_1_, p_76728_2_, k1, l1, i2)) { - ++j1; - continue; - } - } - - ++l; - break; - } - } - - super.decorate(p_76728_1_, p_76728_2_, p_76728_3_, p_76728_4_); - } - - /** - * Provides the basic grass color based on the biome temperature and rainfall - */ - @SideOnly(Side.CLIENT) - public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) { - int l = super.getBiomeGrassColor(p_150558_1_, p_150558_2_, p_150558_3_); - return this.mWoodMeta == 3 ? (l & 16711422) + 2634762 >> 1 : l; - } - - /** - * Allocate a new BiomeDecorator for this BiomeGenBase - */ - @Override - public BiomeDecorator createBiomeDecorator() - { - return getModdedBiomeDecorator(new CustomDecorator()); - } - -}
\ No newline at end of file + private int mWoodMeta; + protected static final WorldGenForest mGenTreeForest = new WorldGenForest(false, true); + protected static final WorldGenForest mGenTreeForest2 = new WorldGenForest(false, false); + protected static final WorldGenCanopyTree mGenTreeCanopy = new WorldGenCanopyTree(false); + protected static final WorldGenAustralianTrees mGenTreeAustralian = new WorldGenAustralianTrees(true); + + public static Biome_AustralianForest biome = new Biome_AustralianForest(CORE.AUSTRALIA_BIOME_FOREST_ID, 2); + + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.FOREST); + BiomeManager.addSpawnBiome(biome); + } + + public Biome_AustralianForest(int p_i45377_1_, int aWoodMeta) { + super(p_i45377_1_, aWoodMeta); + this.mWoodMeta = aWoodMeta; + this.setColor(353825); + this.setBiomeName("Australian Forest"); + this.setTemperatureRainfall(1.1F, 0.75F); + this.theBiomeDecorator.treesPerChunk = 16; + this.theBiomeDecorator.grassPerChunk = 5; + this.theBiomeDecorator.flowersPerChunk = 2; + this.func_76733_a(5159473); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 4, 4)); + } + + public BiomeGenBase func_150557_a(int p_150557_1_, boolean p_150557_2_) { + if (this.mWoodMeta == 2) { + this.field_150609_ah = 353825; + this.color = p_150557_1_; + + if (p_150557_2_) { + this.field_150609_ah = (this.field_150609_ah & 16711422) >> 1; + } + + return this; + } else { + return super.func_150557_a(p_150557_1_, p_150557_2_); + } + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) { + int mTreeType = MathUtils.getRandomFromArray( + new int[] {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5}); + if (mTreeType == 0) { + return mGenTreeCanopy; + } else if (mTreeType == 1) { + return mGenTreeAustralian; + } else if (mTreeType == 2) { + return mGenTreeForest; + } else if (mTreeType == 3) { + return mGenTreeForest2; + } else if (mTreeType == 4) { + return this.worldGeneratorSwamp; + } else { + return MathUtils.randInt(0, 1) == 0 ? this.worldGeneratorTrees : this.worldGeneratorBigTree; + } + } + + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) { + if (this.mWoodMeta == 1) { + double d0 = MathHelper.clamp_double( + (1.0D + plantNoise.func_151601_a((double) p_150572_2_ / 48.0D, (double) p_150572_4_ / 48.0D)) + / 2.0D, + 0.0D, + 0.9999D); + int l = (int) (d0 * (double) BlockFlower.field_149859_a.length); + + if (l == 1) { + l = 0; + } + + return BlockFlower.field_149859_a[l]; + } else { + return super.func_150572_a(p_150572_1_, p_150572_2_, p_150572_3_, p_150572_4_); + } + } + + public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) { + int k; + int l; + int i1; + int j1; + int k1; + + if (this.mWoodMeta == 3) { + for (k = 0; k < 4; ++k) { + for (l = 0; l < 4; ++l) { + i1 = p_76728_3_ + k * 4 + 1 + 8 + p_76728_2_.nextInt(3); + j1 = p_76728_4_ + l * 4 + 1 + 8 + p_76728_2_.nextInt(3); + k1 = p_76728_1_.getHeightValue(i1, j1); + + if (p_76728_2_.nextInt(20) == 0) { + WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom(); + worldgenbigmushroom.generate(p_76728_1_, p_76728_2_, i1, k1, j1); + } else { + WorldGenAbstractTree worldgenabstracttree = this.func_150567_a(p_76728_2_); + worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); + + if (worldgenabstracttree.generate(p_76728_1_, p_76728_2_, i1, k1, j1)) { + worldgenabstracttree.func_150524_b(p_76728_1_, p_76728_2_, i1, k1, j1); + } + } + } + } + } + + k = p_76728_2_.nextInt(5) - 3; + + if (this.mWoodMeta == 1) { + k += 2; + } + + l = 0; + + while (l < k) { + i1 = p_76728_2_.nextInt(3); + + if (i1 == 0) { + genTallFlowers.func_150548_a(1); + } else if (i1 == 1) { + genTallFlowers.func_150548_a(4); + } else if (i1 == 2) { + genTallFlowers.func_150548_a(5); + } + + j1 = 0; + + while (true) { + if (j1 < 5) { + k1 = p_76728_3_ + p_76728_2_.nextInt(16) + 8; + int i2 = p_76728_4_ + p_76728_2_.nextInt(16) + 8; + int l1 = p_76728_2_.nextInt(p_76728_1_.getHeightValue(k1, i2) + 32); + + if (!genTallFlowers.generate(p_76728_1_, p_76728_2_, k1, l1, i2)) { + ++j1; + continue; + } + } + + ++l; + break; + } + } + + super.decorate(p_76728_1_, p_76728_2_, p_76728_3_, p_76728_4_); + } + + /** + * Provides the basic grass color based on the biome temperature and rainfall + */ + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) { + int l = super.getBiomeGrassColor(p_150558_1_, p_150558_2_, p_150558_3_); + return this.mWoodMeta == 3 ? (l & 16711422) + 2634762 >> 1 : l; + } + + /** + * Allocate a new BiomeDecorator for this BiomeGenBase + */ + @Override + public BiomeDecorator createBiomeDecorator() { + return getModdedBiomeDecorator(new CustomDecorator()); + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOcean.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOcean.java index ebfb455882..0cba0efab8 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOcean.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOcean.java @@ -1,9 +1,8 @@ package gtPlusPlus.australia.biome.type; -import java.util.Random; - import gtPlusPlus.australia.biome.CustomDecorator; import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; @@ -14,8 +13,7 @@ import net.minecraftforge.common.BiomeManager; public class Biome_AustralianOcean extends BiomeGenOcean { - public Biome_AustralianOcean(int p_i1985_1_) - { + public Biome_AustralianOcean(int p_i1985_1_) { super(p_i1985_1_); this.setColor(48); this.setBiomeName("Australian Ocean"); @@ -23,30 +21,36 @@ public class Biome_AustralianOcean extends BiomeGenOcean { this.spawnableCreatureList.clear(); } - public static Biome_AustralianOcean biome = new Biome_AustralianOcean(CORE.AUSTRALIA_BIOME_OCEAN_ID); - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.COLD); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.OCEAN); - BiomeManager.addSpawnBiome(biome); - } + public static Biome_AustralianOcean biome = new Biome_AustralianOcean(CORE.AUSTRALIA_BIOME_OCEAN_ID); + + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.COLD); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.OCEAN); + BiomeManager.addSpawnBiome(biome); + } - public BiomeGenBase.TempCategory getTempCategory() - { + public BiomeGenBase.TempCategory getTempCategory() { return BiomeGenBase.TempCategory.OCEAN; } - public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) - { - super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + public void genTerrainBlocks( + World p_150573_1_, + Random p_150573_2_, + Block[] p_150573_3_, + byte[] p_150573_4_, + int p_150573_5_, + int p_150573_6_, + double p_150573_7_) { + super.genTerrainBlocks( + p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); } - /** + /** * Allocate a new BiomeDecorator for this BiomeGenBase */ - @Override - public BiomeDecorator createBiomeDecorator() - { + @Override + public BiomeDecorator createBiomeDecorator() { return getModdedBiomeDecorator(new CustomDecorator()); } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOutback.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOutback.java index 439c213ac7..58533728a5 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOutback.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianOutback.java @@ -4,7 +4,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.australia.biome.CustomDecorator; import gtPlusPlus.core.lib.CORE; - import java.util.Arrays; import java.util.Random; import net.minecraft.block.Block; @@ -12,15 +11,13 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenMesa; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeManager; -public class Biome_AustralianOutback extends BiomeGenMesa -{ +public class Biome_AustralianOutback extends BiomeGenMesa { private byte[] field_150621_aC; private long field_150622_aD; private NoiseGeneratorPerlin field_150623_aE; @@ -29,7 +26,7 @@ public class Biome_AustralianOutback extends BiomeGenMesa private boolean field_150626_aH; private boolean field_150620_aI; - public Biome_AustralianOutback(int p_i45380_1_){ + public Biome_AustralianOutback(int p_i45380_1_) { super(p_i45380_1_, false, false); this.setColor(14238997); this.setBiomeName("Australian Outback"); @@ -47,37 +44,42 @@ public class Biome_AustralianOutback extends BiomeGenMesa this.theBiomeDecorator.cactiPerChunk = 20; this.theBiomeDecorator.flowersPerChunk = 0; this.spawnableCreatureList.clear(); - this.theBiomeDecorator.treesPerChunk = 5; + this.theBiomeDecorator.treesPerChunk = 5; } - public static Biome_AustralianOutback biome = new Biome_AustralianOutback(CORE.AUSTRALIA_BIOME_OUTBACK_ID); - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); - BiomeManager.addSpawnBiome(biome); - } - - public WorldGenAbstractTree func_150567_a(Random p_150567_1_) - { + public static Biome_AustralianOutback biome = new Biome_AustralianOutback(CORE.AUSTRALIA_BIOME_OUTBACK_ID); + + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.HOT); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); + BiomeManager.addSpawnBiome(biome); + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) { return this.worldGeneratorTrees; } - public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) - { + public void decorate(World p_76728_1_, Random p_76728_2_, int p_76728_3_, int p_76728_4_) { super.decorate(p_76728_1_, p_76728_2_, p_76728_3_, p_76728_4_); } - public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) - { - if (this.field_150621_aC == null || this.field_150622_aD != p_150573_1_.getSeed()) - { + public void genTerrainBlocks( + World p_150573_1_, + Random p_150573_2_, + Block[] p_150573_3_, + byte[] p_150573_4_, + int p_150573_5_, + int p_150573_6_, + double p_150573_7_) { + if (this.field_150621_aC == null || this.field_150622_aD != p_150573_1_.getSeed()) { this.func_150619_a(p_150573_1_.getSeed()); } - if (this.field_150623_aE == null || this.field_150624_aF == null || this.field_150622_aD != p_150573_1_.getSeed()) - { + if (this.field_150623_aE == null + || this.field_150624_aF == null + || this.field_150622_aD != p_150573_1_.getSeed()) { Random random1 = new Random(this.field_150622_aD); this.field_150623_aE = new NoiseGeneratorPerlin(random1, 3); this.field_150624_aF = new NoiseGeneratorPerlin(random1, 3); @@ -88,21 +90,19 @@ public class Biome_AustralianOutback extends BiomeGenMesa int k; int l; - if (this.field_150626_aH) - { + if (this.field_150626_aH) { k = (p_150573_5_ & -16) + (p_150573_6_ & 15); l = (p_150573_6_ & -16) + (p_150573_5_ & 15); - double d1 = Math.min(Math.abs(p_150573_7_), this.field_150623_aE.func_151601_a((double)k * 0.25D, (double)l * 0.25D)); + double d1 = Math.min( + Math.abs(p_150573_7_), this.field_150623_aE.func_151601_a((double) k * 0.25D, (double) l * 0.25D)); - if (d1 > 0.0D) - { + if (d1 > 0.0D) { double d2 = 0.001953125D; - double d3 = Math.abs(this.field_150624_aF.func_151601_a((double)k * d2, (double)l * d2)); + double d3 = Math.abs(this.field_150624_aF.func_151601_a((double) k * d2, (double) l * d2)); d5 = d1 * d1 * 2.5D; double d4 = Math.ceil(d3 * 50.0D) + 32.0D; - if (d5 > d4) - { + if (d5 > d4) { d5 = d4; } @@ -115,163 +115,120 @@ public class Biome_AustralianOutback extends BiomeGenMesa boolean flag = true; Block block = Blocks.stained_hardened_clay; Block block2 = this.fillerBlock; - int i1 = (int)(p_150573_7_ / 3.0D + 3.0D + p_150573_2_.nextDouble() * 0.25D); + int i1 = (int) (p_150573_7_ / 3.0D + 3.0D + p_150573_2_.nextDouble() * 0.25D); boolean flag1 = Math.cos(p_150573_7_ / 3.0D * Math.PI) > 0.0D; int j1 = -1; boolean flag2 = false; int k1 = p_150573_3_.length / 256; - for (int l1 = 255; l1 >= 0; --l1) - { + for (int l1 = 255; l1 >= 0; --l1) { int i2 = (l * 16 + k) * k1 + l1; - if ((p_150573_3_[i2] == null || p_150573_3_[i2].getMaterial() == Material.air) && l1 < (int)d5) - { + if ((p_150573_3_[i2] == null || p_150573_3_[i2].getMaterial() == Material.air) && l1 < (int) d5) { p_150573_3_[i2] = Blocks.stone; } - if (l1 <= 0 + p_150573_2_.nextInt(5)) - { + if (l1 <= 0 + p_150573_2_.nextInt(5)) { p_150573_3_[i2] = Blocks.bedrock; - } - else - { + } else { Block block1 = p_150573_3_[i2]; - if (block1 != null && block1.getMaterial() != Material.air) - { - if (block1 == Blocks.stone) - { + if (block1 != null && block1.getMaterial() != Material.air) { + if (block1 == Blocks.stone) { byte b0; - if (j1 == -1) - { + if (j1 == -1) { flag2 = false; - if (i1 <= 0) - { + if (i1 <= 0) { block = null; block2 = Blocks.stone; - } - else if (l1 >= 59 && l1 <= 64) - { + } else if (l1 >= 59 && l1 <= 64) { block = Blocks.stained_hardened_clay; block2 = this.fillerBlock; } - if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) - { + if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) { block = Blocks.sandstone; } j1 = i1 + Math.max(0, l1 - 63); - if (l1 >= 62) - { - if (this.field_150620_aI && l1 > 86 + i1 * 2) - { - if (flag1) - { + if (l1 >= 62) { + if (this.field_150620_aI && l1 > 86 + i1 * 2) { + if (flag1) { p_150573_3_[i2] = Blocks.dirt; p_150573_4_[i2] = 1; - } - else - { + } else { p_150573_3_[i2] = Blocks.grass; } - } - else if (l1 > 66 + i1) - { + } else if (l1 > 66 + i1) { b0 = 16; - if (l1 >= 64 && l1 <= 127) - { - if (!flag1) - { + if (l1 >= 64 && l1 <= 127) { + if (!flag1) { b0 = this.func_150618_d(p_150573_5_, l1, p_150573_6_); } - } - else - { + } else { b0 = 1; } - if (b0 < 16) - { + if (b0 < 16) { p_150573_3_[i2] = Blocks.stained_hardened_clay; - p_150573_4_[i2] = (byte)b0; - } - else - { + p_150573_4_[i2] = (byte) b0; + } else { p_150573_3_[i2] = Blocks.hardened_clay; } - } - else - { + } else { p_150573_3_[i2] = this.topBlock; - p_150573_4_[i2] = (byte)this.field_150604_aj; + p_150573_4_[i2] = (byte) this.field_150604_aj; flag2 = true; } - } - else - { + } else { p_150573_3_[i2] = block2; - if (block2 == Blocks.stained_hardened_clay) - { + if (block2 == Blocks.stained_hardened_clay) { p_150573_4_[i2] = 1; } } - } - else if (j1 > 0) - { + } else if (j1 > 0) { --j1; - if (flag2) - { + if (flag2) { p_150573_3_[i2] = Blocks.stained_hardened_clay; p_150573_4_[i2] = 1; - } - else - { + } else { b0 = this.func_150618_d(p_150573_5_, l1, p_150573_6_); - if (b0 < 16) - { + if (b0 < 16) { p_150573_3_[i2] = Blocks.stained_hardened_clay; p_150573_4_[i2] = b0; - } - else - { + } else { p_150573_3_[i2] = Blocks.hardened_clay; } } } } - } - else - { + } else { j1 = -1; } } } - super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + super.genTerrainBlocks( + p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); } - public void func_150619_a(long p_150619_1_) - { + public void func_150619_a(long p_150619_1_) { this.field_150621_aC = new byte[128]; - Arrays.fill(this.field_150621_aC, (byte)16); + Arrays.fill(this.field_150621_aC, (byte) 16); Random random = new Random(p_150619_1_); this.field_150625_aG = new NoiseGeneratorPerlin(random, 3); int j; - for (j = 0; j < 128; ++j) - { + for (j = 0; j < 128; ++j) { j += random.nextInt(8) + 1; - if (j < 128) - { + if (j < 128) { this.field_150621_aC[j] = 1; } } @@ -282,13 +239,11 @@ public class Biome_AustralianOutback extends BiomeGenMesa int i1; int j1; - for (k = 0; k < j; ++k) - { + for (k = 0; k < j; ++k) { l = random.nextInt(7) + 1; i1 = random.nextInt(128); - for (j1 = 0; i1 + j1 < 128 && j1 < l; ++j1) - { + for (j1 = 0; i1 + j1 < 128 && j1 < l; ++j1) { this.field_150621_aC[i1 + j1] = 4; } } @@ -296,26 +251,22 @@ public class Biome_AustralianOutback extends BiomeGenMesa k = random.nextInt(6) + 2; int k1; - for (l = 0; l < k; ++l) - { + for (l = 0; l < k; ++l) { i1 = random.nextInt(7) + 2; j1 = random.nextInt(128); - for (k1 = 0; j1 + k1 < 128 && k1 < i1; ++k1) - { + for (k1 = 0; j1 + k1 < 128 && k1 < i1; ++k1) { this.field_150621_aC[j1 + k1] = 12; } } l = random.nextInt(7) + 2; - for (i1 = 0; i1 < l; ++i1) - { + for (i1 = 0; i1 < l; ++i1) { j1 = random.nextInt(5) + 1; k1 = random.nextInt(128); - for (int l1 = 0; k1 + l1 < 128 && l1 < j1; ++l1) - { + for (int l1 = 0; k1 + l1 < 128 && l1 < j1; ++l1) { this.field_150621_aC[k1 + l1] = 14; } } @@ -323,22 +274,18 @@ public class Biome_AustralianOutback extends BiomeGenMesa i1 = random.nextInt(8) + 3; j1 = 0; - for (k1 = 0; k1 < i1; ++k1) - { + for (k1 = 0; k1 < i1; ++k1) { byte b0 = 1; j1 += random.nextInt(8) + 4; - for (int i2 = 0; j1 + i2 < 128 && i2 < b0; ++i2) - { + for (int i2 = 0; j1 + i2 < 128 && i2 < b0; ++i2) { this.field_150621_aC[j1 + i2] = 0; - if (j1 + i2 > 1 && random.nextBoolean()) - { + if (j1 + i2 > 1 && random.nextBoolean()) { this.field_150621_aC[j1 + i2 - 1] = 8; } - if (j1 + i2 < 63 && random.nextBoolean()) - { + if (j1 + i2 < 63 && random.nextBoolean()) { this.field_150621_aC[j1 + i2 + 1] = 8; } } @@ -349,8 +296,7 @@ public class Biome_AustralianOutback extends BiomeGenMesa * Provides the basic foliage color based on the biome temperature and rainfall */ @SideOnly(Side.CLIENT) - public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) - { + public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) { return 10387789; } @@ -358,24 +304,22 @@ public class Biome_AustralianOutback extends BiomeGenMesa * Provides the basic grass color based on the biome temperature and rainfall */ @SideOnly(Side.CLIENT) - public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) - { + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) { return 9470285; } - public byte func_150618_d(int p_150618_1_, int p_150618_2_, int p_150618_3_) - { - int l = (int)Math.round(this.field_150625_aG.func_151601_a((double)p_150618_1_ * 1.0D / 512.0D, (double)p_150618_1_ * 1.0D / 512.0D) * 2.0D); + public byte func_150618_d(int p_150618_1_, int p_150618_2_, int p_150618_3_) { + int l = (int) Math.round(this.field_150625_aG.func_151601_a( + (double) p_150618_1_ * 1.0D / 512.0D, (double) p_150618_1_ * 1.0D / 512.0D) + * 2.0D); return this.field_150621_aC[(p_150618_2_ + l + 64) % 64]; } - /** - * Allocate a new BiomeDecorator for this BiomeGenBase - */ - @Override - public BiomeDecorator createBiomeDecorator() - { - return getModdedBiomeDecorator(new CustomDecorator()); - } - -}
\ No newline at end of file + /** + * Allocate a new BiomeDecorator for this BiomeGenBase + */ + @Override + public BiomeDecorator createBiomeDecorator() { + return getModdedBiomeDecorator(new CustomDecorator()); + } +} diff --git a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java index c04f211fd3..23da681eab 100644 --- a/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java +++ b/src/main/java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java @@ -1,9 +1,8 @@ package gtPlusPlus.australia.biome.type; -import java.util.Random; - import gtPlusPlus.australia.biome.CustomDecorator; import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.block.BlockFlower; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.init.Blocks; @@ -14,11 +13,9 @@ import net.minecraft.world.biome.BiomeGenPlains; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeManager; -public class Biome_AustralianPlains extends BiomeGenPlains -{ +public class Biome_AustralianPlains extends BiomeGenPlains { - public Biome_AustralianPlains(int p_i1986_1_) - { + public Biome_AustralianPlains(int p_i1986_1_) { super(p_i1986_1_); this.setTemperatureRainfall(0.8F, 0.4F); this.setColor(9286496); @@ -29,65 +26,57 @@ public class Biome_AustralianPlains extends BiomeGenPlains this.theBiomeDecorator.flowersPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 20; this.flowers.clear(); - this.addFlower(Blocks.red_flower, 4, 3); - this.addFlower(Blocks.red_flower, 5, 3); - this.addFlower(Blocks.red_flower, 6, 3); - this.addFlower(Blocks.red_flower, 7, 3); - this.addFlower(Blocks.red_flower, 0, 20); - this.addFlower(Blocks.red_flower, 3, 20); - this.addFlower(Blocks.red_flower, 8, 20); + this.addFlower(Blocks.red_flower, 4, 3); + this.addFlower(Blocks.red_flower, 5, 3); + this.addFlower(Blocks.red_flower, 6, 3); + this.addFlower(Blocks.red_flower, 7, 3); + this.addFlower(Blocks.red_flower, 0, 20); + this.addFlower(Blocks.red_flower, 3, 20); + this.addFlower(Blocks.red_flower, 8, 20); this.addFlower(Blocks.yellow_flower, 0, 30); } - public static Biome_AustralianPlains biome = new Biome_AustralianPlains(CORE.AUSTRALIA_BIOME_PLAINS_ID); - public void load() { - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); - BiomeManager.addSpawnBiome(biome); - } + public static Biome_AustralianPlains biome = new Biome_AustralianPlains(CORE.AUSTRALIA_BIOME_PLAINS_ID); + + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DRY); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.SPARSE); + BiomeManager.addSpawnBiome(biome); + } - public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) - { - double d0 = plantNoise.func_151601_a((double)p_150572_2_ / 200.0D, (double)p_150572_4_ / 200.0D); + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) { + double d0 = plantNoise.func_151601_a((double) p_150572_2_ / 200.0D, (double) p_150572_4_ / 200.0D); int l; - if (d0 < -0.8D) - { + if (d0 < -0.8D) { l = p_150572_1_.nextInt(4); return BlockFlower.field_149859_a[4 + l]; - } - else if (p_150572_1_.nextInt(3) > 0) - { + } else if (p_150572_1_.nextInt(3) > 0) { l = p_150572_1_.nextInt(3); - return l == 0 ? BlockFlower.field_149859_a[0] : (l == 1 ? BlockFlower.field_149859_a[3] : BlockFlower.field_149859_a[8]); - } - else - { + return l == 0 + ? BlockFlower.field_149859_a[0] + : (l == 1 ? BlockFlower.field_149859_a[3] : BlockFlower.field_149859_a[8]); + } else { return BlockFlower.field_149858_b[0]; } } - public void decorate(World aWorld, Random aRand, int aX, int aZ) - { - double d0 = plantNoise.func_151601_a((double)(aX + 8) / 200.0D, (double)(aZ + 8) / 200.0D); + public void decorate(World aWorld, Random aRand, int aX, int aZ) { + double d0 = plantNoise.func_151601_a((double) (aX + 8) / 200.0D, (double) (aZ + 8) / 200.0D); int k; int l; int i1; int j1; - if (d0 < -0.8D) - { + if (d0 < -0.8D) { this.theBiomeDecorator.flowersPerChunk = 15; this.theBiomeDecorator.grassPerChunk = 5; - } - else - { + } else { this.theBiomeDecorator.flowersPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 10; genTallFlowers.func_150548_a(2); - for (k = 0; k < 7; ++k) - { + for (k = 0; k < 7; ++k) { l = aX + aRand.nextInt(16) + 8; i1 = aZ + aRand.nextInt(16) + 8; j1 = aRand.nextInt(aWorld.getHeightValue(l, i1) + 32); @@ -95,12 +84,10 @@ public class Biome_AustralianPlains extends BiomeGenPlains } } - if (this.field_150628_aC) - { + if (this.field_150628_aC) { genTallFlowers.func_150548_a(0); - for (k = 0; k < 10; ++k) - { + for (k = 0; k < 10; ++k) { l = aX + aRand.nextInt(16) + 8; i1 = aZ + aRand.nextInt(16) + 8; j1 = aRand.nextInt(aWorld.getHeightValue(l, i1) + 32); @@ -111,12 +98,11 @@ public class Biome_AustralianPlains extends BiomeGenPlains this.theBiomeDecorator.decorateChunk(aWorld, aRand, this, aX, aZ); } - /** - * Allocate a new BiomeDecorator for this BiomeGenBase - */ - @Override - public BiomeDecorator createBiomeDecorator() - { - return getModdedBiomeDecorator(new CustomDecorator()); - } -}
\ No newline at end of file + /** + * Allocate a new BiomeDecorator for this BiomeGenBase + */ + @Override + public BiomeDecorator createBiomeDecorator() { + return getModdedBiomeDecorator(new CustomDecorator()); + } +} diff --git a/src/main/java/gtPlusPlus/australia/block/AustraliaContentLoader.java b/src/main/java/gtPlusPlus/australia/block/AustraliaContentLoader.java index 0df84500e1..b1a1d7b66e 100644 --- a/src/main/java/gtPlusPlus/australia/block/AustraliaContentLoader.java +++ b/src/main/java/gtPlusPlus/australia/block/AustraliaContentLoader.java @@ -3,65 +3,64 @@ package gtPlusPlus.australia.block; import static gtPlusPlus.australia.dimension.Dimension_Australia.*; import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.australia.biome.type.Biome_AustralianDesert; import gtPlusPlus.australia.biome.type.Biome_AustralianDesert2; import gtPlusPlus.australia.item.ItemAustraliaPortalTrigger; import gtPlusPlus.australia.item.ItemBlockAustralia; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; public class AustraliaContentLoader { - private static Block blockAustralianSand; - private static Block blockAustralianTopSoil; - - public static AutoMap<Block> mValidGenerationBlocks = new AutoMap<Block>(); + private static Block blockAustralianSand; + private static Block blockAustralianTopSoil; + + public static AutoMap<Block> mValidGenerationBlocks = new AutoMap<Block>(); + + public static synchronized void run() { + initMisc(); + initItems(); + initBlocks(); + } - public synchronized static void run() { - initMisc(); - initItems(); - initBlocks(); - } + public static synchronized boolean initMisc() { + return true; + } - public synchronized static boolean initMisc(){ - return true; - } + public static synchronized boolean initItems() { + portalItem = + (ItemAustraliaPortalTrigger) (new ItemAustraliaPortalTrigger().setUnlocalizedName("australia.trigger")); + GameRegistry.registerItem(portalItem, "australia.trigger"); + return true; + } - public synchronized static boolean initItems(){ - portalItem = (ItemAustraliaPortalTrigger) (new ItemAustraliaPortalTrigger().setUnlocalizedName("australia.trigger")); - GameRegistry.registerItem(portalItem, "australia.trigger"); - return true; - } + public static synchronized boolean initBlocks() { - public synchronized static boolean initBlocks(){ + // Create Block Instances + portalBlock = new BlockAustraliaPortal(); + blockPortalFrame = new BlockDarkWorldPortalFrame(); + blockAustralianSand = new BlockAustraliaSand(); + blockAustralianTopSoil = new BlockAustraliaTopSoil(); + mValidGenerationBlocks.put(blockAustralianSand); + mValidGenerationBlocks.put(blockAustralianTopSoil); - //Create Block Instances - portalBlock = new BlockAustraliaPortal(); - blockPortalFrame = new BlockDarkWorldPortalFrame(); - blockAustralianSand = new BlockAustraliaSand(); - blockAustralianTopSoil = new BlockAustraliaTopSoil(); - mValidGenerationBlocks.put(blockAustralianSand); - mValidGenerationBlocks.put(blockAustralianTopSoil); - - //Registry - GameRegistry.registerBlock(portalBlock, ItemBlockAustralia.class, "dimensionAustraliaPortalBlock"); - GameRegistry.registerBlock(blockPortalFrame, ItemBlockAustralia.class, "blockAustraliaPortalFrame"); - - GameRegistry.registerBlock(blockAustralianSand, ItemBlockAustralia.class, "blockAustralianTopSoil"); - GameRegistry.registerBlock(blockAustralianTopSoil, ItemBlockAustralia.class, "blockAustralianSand"); + // Registry + GameRegistry.registerBlock(portalBlock, ItemBlockAustralia.class, "dimensionAustraliaPortalBlock"); + GameRegistry.registerBlock(blockPortalFrame, ItemBlockAustralia.class, "blockAustraliaPortalFrame"); - //Set Biome Blocks up - Biome_AustralianDesert.blockFluidLakes = Blocks.water; - Biome_AustralianDesert.blockTopLayer = blockAustralianSand; - Biome_AustralianDesert.blockSecondLayer = blockAustralianTopSoil; - - Biome_AustralianDesert2.blockFluidLakes = Blocks.water; - Biome_AustralianDesert2.blockTopLayer = blockAustralianSand; - Biome_AustralianDesert2.blockSecondLayer = blockAustralianTopSoil; + GameRegistry.registerBlock(blockAustralianSand, ItemBlockAustralia.class, "blockAustralianTopSoil"); + GameRegistry.registerBlock(blockAustralianTopSoil, ItemBlockAustralia.class, "blockAustralianSand"); - return true; - } + // Set Biome Blocks up + Biome_AustralianDesert.blockFluidLakes = Blocks.water; + Biome_AustralianDesert.blockTopLayer = blockAustralianSand; + Biome_AustralianDesert.blockSecondLayer = blockAustralianTopSoil; + Biome_AustralianDesert2.blockFluidLakes = Blocks.water; + Biome_AustralianDesert2.blockTopLayer = blockAustralianSand; + Biome_AustralianDesert2.blockSecondLayer = blockAustralianTopSoil; + return true; + } } diff --git a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaPortal.java b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaPortal.java index 44ece25e43..a5c7356620 100644 --- a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaPortal.java +++ b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaPortal.java @@ -1,10 +1,14 @@ package gtPlusPlus.australia.block; -import java.util.Random; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.australia.dimension.Dimension_Australia; +import gtPlusPlus.australia.world.AustraliaTeleporterDimensionMod; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockBreakable; import net.minecraft.block.material.Material; @@ -19,385 +23,382 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.australia.dimension.Dimension_Australia; -import gtPlusPlus.australia.world.AustraliaTeleporterDimensionMod; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - -public class BlockAustraliaPortal extends BlockBreakable implements ITileTooltip{ - IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null; - - public BlockAustraliaPortal() { - super("portal", Material.portal, false); - this.setTickRandomly(true); - this.setHardness(-1.0F); - this.setLightLevel(0.75F); - this.setCreativeTab(CreativeTabs.tabBlock); - this.setBlockName("dimensionAustraliaPortalBlock"); - - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int i, int par2) { - - if (i == 0) - return gor; - - else if (i == 1) - return dol; - - else if (i == 2) - return st1; - - else if (i == 3) - return st2; - - else if (i == 4) - return st4; - - else if (i == 5) - return st3; - - else - return gor; - - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister reg) { - this.gor = reg.registerIcon("portal"); - this.dol = reg.registerIcon("portal"); - this.st1 = reg.registerIcon("portal"); - this.st2 = reg.registerIcon("portal"); - this.st3 = reg.registerIcon("portal"); - this.st4 = reg.registerIcon("portal"); - } - - /** - * Ticks the block if it's been scheduled - */ - @Override - public void updateTick(World par1World, int x, int y, int z, Random par5Random) { - super.updateTick(par1World, x, y, z, par5Random); - - int blockCount = 0; - BlockPos portal = new BlockPos(x, y, z, par1World.provider.dimensionId); - - for (BlockPos side : portal.getSurroundingBlocks()) { - Block b = side.getBlockAtPos(); - if (b == Dimension_Australia.blockPortalFrame || b == Dimension_Australia.portalBlock) { - blockCount++; - } - } - if (blockCount < 4) { - par1World.setBlockToAir(x, y, z); - } - - } - - /** - * Returns a bounding box from the pool of bounding boxes (this means - * this box can change after the pool has been cleared to be reused) - */ - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - return null; - } - - /** - * Updates the blocks bounds based on its current state. Args: world, x, - * y, z - */ - @Override - public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { - float f; - float f1; - if (par1IBlockAccess.getBlock(par2 - 1, par3, par4) != this && par1IBlockAccess.getBlock(par2 + 1, par3, par4) != this) { - f = 0.125F; - f1 = 0.5F; - this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); - } else { - f = 0.5F; - f1 = 0.125F; - this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); - } - } - - /** - * Is this block (a) opaque and (B) a full 1m cube? This determines - * whether or not to render the shared face of two adjacent blocks and - * also whether the player can attach torches, redstone wire, etc to - * this block. - */ - @Override - public boolean isOpaqueCube() { - return false; - } - - /** - * If this block doesn't render as an ordinary block it will return - * False (examples: signs, buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() { - return false; - } - - /** - * Checks to see if this location is valid to create a portal and will - * return True if it does. Args: world, x, y, z - */ - public boolean tryToCreatePortal(World par1World, int par2, int par3, int par4) { - byte b0 = 0; - byte b1 = 0; - if (par1World.getBlock(par2 - 1, par3, par4) == Dimension_Australia.blockPortalFrame - || par1World.getBlock(par2 + 1, par3, par4) == Dimension_Australia.blockPortalFrame) { - b0 = 1; - } - if (par1World.getBlock(par2, par3, par4 - 1) == Dimension_Australia.blockPortalFrame - || par1World.getBlock(par2, par3, par4 + 1) == Dimension_Australia.blockPortalFrame) { - b1 = 1; - } - if (b0 == b1) { - return false; - } else { - if (par1World.getBlock(par2 - b0, par3, par4 - b1) == Blocks.air) { - par2 -= b0; - par4 -= b1; - } - int l; - int i1; - for (l = -1; l <= 2; ++l) { - for (i1 = -1; i1 <= 3; ++i1) { - boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; - if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { - Block j1 = par1World.getBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); - if (flag) { - if (j1 != Dimension_Australia.blockPortalFrame) { - return false; - } - } - /* - * else if (j1 != 0 && j1 != - * Main.TutorialFire.blockID) { return false; } - */ - } - } - } - for (l = 0; l < 2; ++l) { - for (i1 = 0; i1 < 3; ++i1) { - par1World.setBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l, this, 0, 2); - } - } - return true; - } - } - - /** - * Lets the block know when one of its neighbor changes. Doesn't know - * which neighbor changed (coordinates passed are their own) Args: x, y, - * z, neighbor blockID - */ - public void onNeighborBlockChange(BlockPos pos) { - int x = pos.xPos, y = pos.yPos, z = pos.zPos; - //Logger.INFO("Trigger"); - int blockCount = 0; - BlockPos portal = pos; - World par1World = portal.world; - for (BlockPos side : portal.getSurroundingBlocks()) { - Block b = side.getBlockAtPos(); - if (b == Dimension_Australia.blockPortalFrame || b == Dimension_Australia.portalBlock) { - blockCount++; - } - } - if (blockCount < 4) { - par1World.setBlockToAir(x, y, z); - par1World.scheduleBlockUpdate(x, y, z, portal.getBlockAtPos(), 0); - } - - - - byte b0 = 0; - byte b1 = 1; - if (par1World.getBlock(x - 1, y, z) == this || par1World.getBlock(x + 1, y, z) == this) { - b0 = 1; - b1 = 0; - } - int i1; - for (i1 = y; par1World.getBlock(x, i1 - 1, z) == this; --i1) { - ; - } - if (par1World.getBlock(x, i1 - 1, z) != Dimension_Australia.blockPortalFrame) { - par1World.setBlockToAir(x, y, z); - } else { - int j1; - for (j1 = 1; j1 < 4 && par1World.getBlock(x, i1 + j1, z) == this; ++j1) { - ; - } - if (j1 == 3 && par1World.getBlock(x, i1 + j1, z) == Dimension_Australia.blockPortalFrame) { - boolean flag = par1World.getBlock(x - 1, y, z) == this || par1World.getBlock(x + 1, y, z) == this; - boolean flag1 = par1World.getBlock(x, y, z - 1) == this || par1World.getBlock(x, y, z + 1) == this; - if (flag && flag1) { - par1World.setBlockToAir(x, y, z); - } else { - if ((par1World.getBlock(x + b0, y, z + b1) != Dimension_Australia.blockPortalFrame || par1World - .getBlock(x - b0, y, z - b1) != this) - && (par1World.getBlock(x - b0, y, z - b1) != Dimension_Australia.blockPortalFrame || par1World.getBlock(x + b0, y, - z + b1) != this)) { - par1World.setBlockToAir(x, y, z); - } - } - } else { - par1World.setBlockToAir(x, y, z); - } - } - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - onNeighborBlockChange(new BlockPos(x, y, z, world.provider.dimensionId)); - super.onNeighborBlockChange(world, x, y, z, block); - } - - /*@Override - public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { - onNeighborBlockChange(new BlockPos(x, y, z, world.)); - super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ); - }*/ - - @Override - @SideOnly(Side.CLIENT) - /** - * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given - * coordinates. Args: blockAccess, x, y, z, side - */ - public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { - if (par1IBlockAccess.getBlock(par2, par3, par4) == this) { - return false; - } else { - boolean flag = par1IBlockAccess.getBlock(par2 - 1, par3, par4) == this && par1IBlockAccess.getBlock(par2 - 2, par3, par4) != this; - boolean flag1 = par1IBlockAccess.getBlock(par2 + 1, par3, par4) == this && par1IBlockAccess.getBlock(par2 + 2, par3, par4) != this; - boolean flag2 = par1IBlockAccess.getBlock(par2, par3, par4 - 1) == this && par1IBlockAccess.getBlock(par2, par3, par4 - 2) != this; - boolean flag3 = par1IBlockAccess.getBlock(par2, par3, par4 + 1) == this && par1IBlockAccess.getBlock(par2, par3, par4 + 2) != this; - boolean flag4 = flag || flag1; - boolean flag5 = flag2 || flag3; - return flag4 && par5 == 4 ? true : (flag4 && par5 == 5 ? true : (flag5 && par5 == 2 ? true : flag5 && par5 == 3)); - } - } - - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) { - return 0; - } - - /** - * Triggered whenever an entity collides with this block (enters into - * the block). Args: world, x, y, z, entity - */ - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - if ((par5Entity.ridingEntity == null) && (par5Entity.riddenByEntity == null) && ((par5Entity instanceof EntityPlayerMP))) { - EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity; - if (thePlayer.timeUntilPortal > 0) { - thePlayer.timeUntilPortal = 100; - } else if (thePlayer.dimension != Dimension_Australia.DIMID) { - thePlayer.timeUntilPortal = 100; - thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, Dimension_Australia.DIMID, - new AustraliaTeleporterDimensionMod(thePlayer.mcServer.worldServerForDimension(Dimension_Australia.DIMID))); - } else { - thePlayer.timeUntilPortal = 100; - thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, - new AustraliaTeleporterDimensionMod(thePlayer.mcServer.worldServerForDimension(0))); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - /** - * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha - */ - public int getRenderBlockPass() { - return 1; - } - - @Override - @SideOnly(Side.CLIENT) - /** - * A randomly called display update to be able to add particles or other items for display - */ - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - if (CORE.RANDOM.nextInt(100) == 0) { - par1World.playSound(par2 + 0.5D, par3 + 0.5D, par4 + 0.5D, "portal.portal", 0.5F, - CORE.RANDOM.nextFloat() * 0.4F + 0.8F, false); - } - for (int l = 0; l < 4; ++l) { - double d0 = par2 + CORE.RANDOM.nextFloat(); - double d1 = par3 + CORE.RANDOM.nextFloat(); - double d2 = par4 + CORE.RANDOM.nextFloat(); - double d3 = 0.0D; - double d4 = 0.0D; - double d5 = 0.0D; - int i1 = CORE.RANDOM.nextInt(2) * 2 - 1; - d3 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; - d4 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; - d5 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; - if (par1World.getBlock(par2 - 1, par3, par4) != this && par1World.getBlock(par2 + 1, par3, par4) != this) { - d0 = par2 + 0.5D + 0.25D * i1; - d3 = CORE.RANDOM.nextFloat() * 2.0F * i1; - } else { - d2 = par4 + 0.5D + 0.25D * i1; - d5 = CORE.RANDOM.nextFloat() * 2.0F * i1; - } - par1World.spawnParticle("reddust", d0+0.1D, d1, d2, d3, d4, d5); - par1World.spawnParticle("smoke", d0, d1+0.1D, d2, 0, 0, 0); - - Random R = new Random(); - - if (R.nextInt(10) == 0){ - par1World.spawnParticle("largesmoke", d0, d1, d2, 0, 0+0.2D, 0); - } - else if (R.nextInt(5)==1){ - par1World.spawnParticle("flame", d0, d1, d2, 0, 0+0.1D, 0); - } - } - } - - @SideOnly(Side.CLIENT) - /** - * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) - */ - public int idPicked(World par1World, int par2, int par3, int par4) { - return 0; - } - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - return Utils.rgbtoHexValue(0, 255, 0); - } - - @Override - public int getRenderColor(final int aMeta) { - return Utils.rgbtoHexValue(0, 255, 0); - } - - @Override - public String getLocalizedName() { - return EnumChatFormatting.OBFUSCATED+super.getLocalizedName(); - } - - @Override - public int getTooltipID() { - return 1; - } +public class BlockAustraliaPortal extends BlockBreakable implements ITileTooltip { + IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null; + + public BlockAustraliaPortal() { + super("portal", Material.portal, false); + this.setTickRandomly(true); + this.setHardness(-1.0F); + this.setLightLevel(0.75F); + this.setCreativeTab(CreativeTabs.tabBlock); + this.setBlockName("dimensionAustraliaPortalBlock"); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int i, int par2) { + + if (i == 0) return gor; + else if (i == 1) return dol; + else if (i == 2) return st1; + else if (i == 3) return st2; + else if (i == 4) return st4; + else if (i == 5) return st3; + else return gor; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister reg) { + this.gor = reg.registerIcon("portal"); + this.dol = reg.registerIcon("portal"); + this.st1 = reg.registerIcon("portal"); + this.st2 = reg.registerIcon("portal"); + this.st3 = reg.registerIcon("portal"); + this.st4 = reg.registerIcon("portal"); + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(World par1World, int x, int y, int z, Random par5Random) { + super.updateTick(par1World, x, y, z, par5Random); + + int blockCount = 0; + BlockPos portal = new BlockPos(x, y, z, par1World.provider.dimensionId); + + for (BlockPos side : portal.getSurroundingBlocks()) { + Block b = side.getBlockAtPos(); + if (b == Dimension_Australia.blockPortalFrame || b == Dimension_Australia.portalBlock) { + blockCount++; + } + } + if (blockCount < 4) { + par1World.setBlockToAir(x, y, z); + } + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means + * this box can change after the pool has been cleared to be reused) + */ + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { + return null; + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, + * y, z + */ + @Override + public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + float f; + float f1; + if (par1IBlockAccess.getBlock(par2 - 1, par3, par4) != this + && par1IBlockAccess.getBlock(par2 + 1, par3, par4) != this) { + f = 0.125F; + f1 = 0.5F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); + } else { + f = 0.5F; + f1 = 0.125F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); + } + } + + /** + * Is this block (a) opaque and (B) a full 1m cube? This determines + * whether or not to render the shared face of two adjacent blocks and + * also whether the player can attach torches, redstone wire, etc to + * this block. + */ + @Override + public boolean isOpaqueCube() { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return + * False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * Checks to see if this location is valid to create a portal and will + * return True if it does. Args: world, x, y, z + */ + public boolean tryToCreatePortal(World par1World, int par2, int par3, int par4) { + byte b0 = 0; + byte b1 = 0; + if (par1World.getBlock(par2 - 1, par3, par4) == Dimension_Australia.blockPortalFrame + || par1World.getBlock(par2 + 1, par3, par4) == Dimension_Australia.blockPortalFrame) { + b0 = 1; + } + if (par1World.getBlock(par2, par3, par4 - 1) == Dimension_Australia.blockPortalFrame + || par1World.getBlock(par2, par3, par4 + 1) == Dimension_Australia.blockPortalFrame) { + b1 = 1; + } + if (b0 == b1) { + return false; + } else { + if (par1World.getBlock(par2 - b0, par3, par4 - b1) == Blocks.air) { + par2 -= b0; + par4 -= b1; + } + int l; + int i1; + for (l = -1; l <= 2; ++l) { + for (i1 = -1; i1 <= 3; ++i1) { + boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; + if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { + Block j1 = par1World.getBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); + if (flag) { + if (j1 != Dimension_Australia.blockPortalFrame) { + return false; + } + } + /* + * else if (j1 != 0 && j1 != + * Main.TutorialFire.blockID) { return false; } + */ + } + } + } + for (l = 0; l < 2; ++l) { + for (i1 = 0; i1 < 3; ++i1) { + par1World.setBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l, this, 0, 2); + } + } + return true; + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know + * which neighbor changed (coordinates passed are their own) Args: x, y, + * z, neighbor blockID + */ + public void onNeighborBlockChange(BlockPos pos) { + int x = pos.xPos, y = pos.yPos, z = pos.zPos; + // Logger.INFO("Trigger"); + int blockCount = 0; + BlockPos portal = pos; + World par1World = portal.world; + for (BlockPos side : portal.getSurroundingBlocks()) { + Block b = side.getBlockAtPos(); + if (b == Dimension_Australia.blockPortalFrame || b == Dimension_Australia.portalBlock) { + blockCount++; + } + } + if (blockCount < 4) { + par1World.setBlockToAir(x, y, z); + par1World.scheduleBlockUpdate(x, y, z, portal.getBlockAtPos(), 0); + } + + byte b0 = 0; + byte b1 = 1; + if (par1World.getBlock(x - 1, y, z) == this || par1World.getBlock(x + 1, y, z) == this) { + b0 = 1; + b1 = 0; + } + int i1; + for (i1 = y; par1World.getBlock(x, i1 - 1, z) == this; --i1) { + ; + } + if (par1World.getBlock(x, i1 - 1, z) != Dimension_Australia.blockPortalFrame) { + par1World.setBlockToAir(x, y, z); + } else { + int j1; + for (j1 = 1; j1 < 4 && par1World.getBlock(x, i1 + j1, z) == this; ++j1) { + ; + } + if (j1 == 3 && par1World.getBlock(x, i1 + j1, z) == Dimension_Australia.blockPortalFrame) { + boolean flag = par1World.getBlock(x - 1, y, z) == this || par1World.getBlock(x + 1, y, z) == this; + boolean flag1 = par1World.getBlock(x, y, z - 1) == this || par1World.getBlock(x, y, z + 1) == this; + if (flag && flag1) { + par1World.setBlockToAir(x, y, z); + } else { + if ((par1World.getBlock(x + b0, y, z + b1) != Dimension_Australia.blockPortalFrame + || par1World.getBlock(x - b0, y, z - b1) != this) + && (par1World.getBlock(x - b0, y, z - b1) != Dimension_Australia.blockPortalFrame + || par1World.getBlock(x + b0, y, z + b1) != this)) { + par1World.setBlockToAir(x, y, z); + } + } + } else { + par1World.setBlockToAir(x, y, z); + } + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + onNeighborBlockChange(new BlockPos(x, y, z, world.provider.dimensionId)); + super.onNeighborBlockChange(world, x, y, z, block); + } + + /*@Override + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { + onNeighborBlockChange(new BlockPos(x, y, z, world.)); + super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ); + }*/ + + @Override + @SideOnly(Side.CLIENT) + /** + * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given + * coordinates. Args: blockAccess, x, y, z, side + */ + public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { + if (par1IBlockAccess.getBlock(par2, par3, par4) == this) { + return false; + } else { + boolean flag = par1IBlockAccess.getBlock(par2 - 1, par3, par4) == this + && par1IBlockAccess.getBlock(par2 - 2, par3, par4) != this; + boolean flag1 = par1IBlockAccess.getBlock(par2 + 1, par3, par4) == this + && par1IBlockAccess.getBlock(par2 + 2, par3, par4) != this; + boolean flag2 = par1IBlockAccess.getBlock(par2, par3, par4 - 1) == this + && par1IBlockAccess.getBlock(par2, par3, par4 - 2) != this; + boolean flag3 = par1IBlockAccess.getBlock(par2, par3, par4 + 1) == this + && par1IBlockAccess.getBlock(par2, par3, par4 + 2) != this; + boolean flag4 = flag || flag1; + boolean flag5 = flag2 || flag3; + return flag4 && par5 == 4 + ? true + : (flag4 && par5 == 5 ? true : (flag5 && par5 == 2 ? true : flag5 && par5 == 3)); + } + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) { + return 0; + } + + /** + * Triggered whenever an entity collides with this block (enters into + * the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + if ((par5Entity.ridingEntity == null) + && (par5Entity.riddenByEntity == null) + && ((par5Entity instanceof EntityPlayerMP))) { + EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity; + if (thePlayer.timeUntilPortal > 0) { + thePlayer.timeUntilPortal = 100; + } else if (thePlayer.dimension != Dimension_Australia.DIMID) { + thePlayer.timeUntilPortal = 100; + thePlayer + .mcServer + .getConfigurationManager() + .transferPlayerToDimension( + thePlayer, + Dimension_Australia.DIMID, + new AustraliaTeleporterDimensionMod( + thePlayer.mcServer.worldServerForDimension(Dimension_Australia.DIMID))); + } else { + thePlayer.timeUntilPortal = 100; + thePlayer + .mcServer + .getConfigurationManager() + .transferPlayerToDimension( + thePlayer, + 0, + new AustraliaTeleporterDimensionMod(thePlayer.mcServer.worldServerForDimension(0))); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + public int getRenderBlockPass() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + /** + * A randomly called display update to be able to add particles or other items for display + */ + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + if (CORE.RANDOM.nextInt(100) == 0) { + par1World.playSound( + par2 + 0.5D, + par3 + 0.5D, + par4 + 0.5D, + "portal.portal", + 0.5F, + CORE.RANDOM.nextFloat() * 0.4F + 0.8F, + false); + } + for (int l = 0; l < 4; ++l) { + double d0 = par2 + CORE.RANDOM.nextFloat(); + double d1 = par3 + CORE.RANDOM.nextFloat(); + double d2 = par4 + CORE.RANDOM.nextFloat(); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + int i1 = CORE.RANDOM.nextInt(2) * 2 - 1; + d3 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; + d4 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; + d5 = (CORE.RANDOM.nextFloat() - 0.5D) * 0.5D; + if (par1World.getBlock(par2 - 1, par3, par4) != this && par1World.getBlock(par2 + 1, par3, par4) != this) { + d0 = par2 + 0.5D + 0.25D * i1; + d3 = CORE.RANDOM.nextFloat() * 2.0F * i1; + } else { + d2 = par4 + 0.5D + 0.25D * i1; + d5 = CORE.RANDOM.nextFloat() * 2.0F * i1; + } + par1World.spawnParticle("reddust", d0 + 0.1D, d1, d2, d3, d4, d5); + par1World.spawnParticle("smoke", d0, d1 + 0.1D, d2, 0, 0, 0); + + Random R = new Random(); + + if (R.nextInt(10) == 0) { + par1World.spawnParticle("largesmoke", d0, d1, d2, 0, 0 + 0.2D, 0); + } else if (R.nextInt(5) == 1) { + par1World.spawnParticle("flame", d0, d1, d2, 0, 0 + 0.1D, 0); + } + } + } + + @SideOnly(Side.CLIENT) + /** + * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) + */ + public int idPicked(World par1World, int par2, int par3, int par4) { + return 0; + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return Utils.rgbtoHexValue(0, 255, 0); + } + + @Override + public int getRenderColor(final int aMeta) { + return Utils.rgbtoHexValue(0, 255, 0); + } + + @Override + public String getLocalizedName() { + return EnumChatFormatting.OBFUSCATED + super.getLocalizedName(); + } + + @Override + public int getTooltipID() { + return 1; + } } - - diff --git a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaSand.java b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaSand.java index 62d443bc13..99a7a45668 100644 --- a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaSand.java +++ b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaSand.java @@ -1,25 +1,22 @@ package gtPlusPlus.australia.block; import cpw.mods.fml.common.registry.LanguageRegistry; - -import net.minecraft.block.BlockGrass; -import net.minecraft.block.BlockSand; import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.BlockSand; -public class BlockAustraliaSand extends BlockSand implements ITileTooltip{ - - public BlockAustraliaSand() { - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setBlockName("blockAustralianSand"); - this.setHardness(0.1F); - this.setBlockTextureName("minecraft" + ":" + "sand"); - LanguageRegistry.addName(this, "Sandy Earth"); - } +public class BlockAustraliaSand extends BlockSand implements ITileTooltip { - @Override - public int getTooltipID() { - return 2; - } + public BlockAustraliaSand() { + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockAustralianSand"); + this.setHardness(0.1F); + this.setBlockTextureName("minecraft" + ":" + "sand"); + LanguageRegistry.addName(this, "Sandy Earth"); + } + @Override + public int getTooltipID() { + return 2; + } } diff --git a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java index 09c7dbf22d..80a4c4f001 100644 --- a/src/main/java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java +++ b/src/main/java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java @@ -3,74 +3,66 @@ package gtPlusPlus.australia.block; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.BlockDirt; +import gtPlusPlus.api.interfaces.ITileTooltip; import net.minecraft.block.BlockSand; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.core.creative.AddToCreativeTab; - -public class BlockAustraliaTopSoil extends BlockSand implements ITileTooltip{ +public class BlockAustraliaTopSoil extends BlockSand implements ITileTooltip { - public BlockAustraliaTopSoil() { - this.setHardness(0.5F); - this.setBlockTextureName("minecraft" + ":" + "dirt"); - this.setCreativeTab(CreativeTabs.tabBlock); - this.setBlockName("blockAustralianTopSoil"); - LanguageRegistry.addName(this, "Desert Earth"); - } - - @Override - @SideOnly(Side.CLIENT) - public int getBlockColor() - { - double d0 = 0.5D; - double d1 = 1.0D; - return ColorizerGrass.getGrassColor(d0, d1); - } + public BlockAustraliaTopSoil() { + this.setHardness(0.5F); + this.setBlockTextureName("minecraft" + ":" + "dirt"); + this.setCreativeTab(CreativeTabs.tabBlock); + this.setBlockName("blockAustralianTopSoil"); + LanguageRegistry.addName(this, "Desert Earth"); + } - /** - * Returns the color this block should be rendered. Used by leaves. - */ - @Override - @SideOnly(Side.CLIENT) - public int getRenderColor(int p_149741_1_) - { - return this.getBlockColor(); - } + @Override + @SideOnly(Side.CLIENT) + public int getBlockColor() { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } - /** - * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called - * when first determining what to render. - */ - @Override - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) - { - int l = 0; - int i1 = 0; - int j1 = 0; + /** + * Returns the color this block should be rendered. Used by leaves. + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) { + return this.getBlockColor(); + } - for (int k1 = -1; k1 <= 1; ++k1) - { - for (int l1 = -1; l1 <= 1; ++l1) - { - int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getBiomeGrassColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1); - l += (i2 & 16711680) >> 16; - i1 += (i2 & 65280) >> 8; - j1 += i2 & 255; - } - } + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) { + int l = 0; + int i1 = 0; + int j1 = 0; - return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; - } + for (int k1 = -1; k1 <= 1; ++k1) { + for (int l1 = -1; l1 <= 1; ++l1) { + int i2 = p_149720_1_ + .getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1) + .getBiomeGrassColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } - @Override - public int getTooltipID() { - return 3; - } + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } + @Override + public int getTooltipID() { + return 3; + } } diff --git a/src/main/java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java b/src/main/java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java index 1de7425f6a..34845f5266 100644 --- a/src/main/java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java +++ b/src/main/java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java @@ -1,30 +1,26 @@ package gtPlusPlus.australia.block; import cpw.mods.fml.common.registry.LanguageRegistry; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; - import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; -public class BlockDarkWorldPortalFrame extends Block implements ITileTooltip{ - - public BlockDarkWorldPortalFrame() { - super(Material.iron); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setBlockName("blockAustraliaPortalFrame"); - this.setHardness(3.0F); - this.setLightLevel(0.5F); - this.setBlockTextureName(CORE.MODID + ":" + "metro/TEXTURE_TECH_PANEL_A"); - LanguageRegistry.addName(this, "Containment Frame"); - - } - - @Override - public int getTooltipID() { - return 0; - } - +public class BlockDarkWorldPortalFrame extends Block implements ITileTooltip { + + public BlockDarkWorldPortalFrame() { + super(Material.iron); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockAustraliaPortalFrame"); + this.setHardness(3.0F); + this.setLightLevel(0.5F); + this.setBlockTextureName(CORE.MODID + ":" + "metro/TEXTURE_TECH_PANEL_A"); + LanguageRegistry.addName(this, "Containment Frame"); + } + + @Override + public int getTooltipID() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java b/src/main/java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java index 07f5f969e2..5649cc4c78 100644 --- a/src/main/java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java +++ b/src/main/java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java @@ -3,14 +3,13 @@ package gtPlusPlus.australia.chunk; import static net.minecraft.world.gen.structure.MapGenVillage.villageSpawnBiomes; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS; +import cpw.mods.fml.common.eventhandler.Event.Result; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.australia.gen.map.MapGenLargeRavine; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; - -import cpw.mods.fml.common.eventhandler.Event.Result; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.australia.gen.map.MapGenLargeRavine; import net.minecraft.block.Block; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; @@ -38,784 +37,810 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; public class ChunkProviderAustralia extends ChunkProviderGenerate implements IChunkProvider { - private Random rand; - private NoiseGeneratorOctaves noiseGen1; - private NoiseGeneratorOctaves noiseGen2; - private NoiseGeneratorOctaves noiseGen3; - private NoiseGeneratorPerlin noiseGen4; - /** - * Reference to the World object. - */ - private World worldObj; - private WorldType worldType; - private final double[] field_147434_q; - private final float[] parabolicField; - private double[] stoneNoise = new double[256]; - private MapGenBase caveGenerator = new MapGenCaves(); - /** - * Holds Stronghold Generator - */ - // private MapGenStronghold strongholdGenerator = new - // MapGenStronghold(); - - /** - * Holds Mineshaft Generator - */ - private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); - private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); - /** - * Holds ravine generator - */ - private MapGenBase ravineGenerator = new MapGenLargeRavine(); - /** - * The biomes that are used to generate the chunk - */ - private BiomeGenBase[] biomesForGeneration; - double[] doubleArray1; - double[] doubleArray2; - double[] doubleArray3; - double[] doubleArray4; - - int[][] field_73219_j = new int[32][32]; - Map map; - - // Some Init Field? - { - - try { - List<BiomeGenBase> y = new ArrayList<BiomeGenBase>(); - if (!villageSpawnBiomes.isEmpty()) { - y.addAll(villageSpawnBiomes); - } - - for (BiomeGenBase h : gtPlusPlus.australia.gen.map.MapGenExtendedVillage.villageSpawnBiomes) { - if (!y.contains(h)) { - if (h instanceof BiomeGenBase) { - try { - y.add(h); - } - catch (Throwable t) {} - } - } - } - if (y.size() > villageSpawnBiomes.size()) { - villageSpawnBiomes = y; - } - } - catch (Throwable t) {} - - caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, - net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); - mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, - net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); - scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, - net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); - ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, - net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); - } - - public ChunkProviderAustralia(World par1World, long par2) { - super(par1World, par2, true); - this.worldObj = par1World; - this.worldType = par1World.getWorldInfo().getTerrainType(); - this.rand = new Random(par2); - this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16); - this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16); - this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8); - this.noiseGen4 = new NoiseGeneratorPerlin(this.rand, 4); - this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); - this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); - this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); - this.field_147434_q = new double[2500]; - this.parabolicField = new float[25]; - for (int j = -2; j <= 2; j++) { - for (int k = -2; k <= 2; k++) { - float f = 10.0F / MathHelper.sqrt_float(j * j + k * k + 0.2F); - this.parabolicField[(j + 2 + (k + 2) * 5)] = f; - } - } - NoiseGenerator[] noiseGens = { this.noiseGen1, this.noiseGen2, this.noiseGen3, this.noiseGen4, this.noiseGen5, - this.noiseGen6, this.mobSpawnerNoise }; - noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); - this.noiseGen1 = ((NoiseGeneratorOctaves) noiseGens[0]); - this.noiseGen2 = ((NoiseGeneratorOctaves) noiseGens[1]); - this.noiseGen3 = ((NoiseGeneratorOctaves) noiseGens[2]); - this.noiseGen4 = ((NoiseGeneratorPerlin) noiseGens[3]); - this.noiseGen5 = ((NoiseGeneratorOctaves) noiseGens[4]); - this.noiseGen6 = ((NoiseGeneratorOctaves) noiseGens[5]); - this.mobSpawnerNoise = ((NoiseGeneratorOctaves) noiseGens[6]); - } - - public void func_147424_a(int p_147424_1_, int p_147424_2_, Block[] p_147424_3_) { - byte b0 = 63; - this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, - p_147424_1_ * 4 - 2, p_147424_2_ * 4 - 2, 10, 10); - - func_147423_a(p_147424_1_ * 4, 0, p_147424_2_ * 4); - for (int k = 0; k < 4; k++) { - int l = k * 5; - int i1 = (k + 1) * 5; - for (int j1 = 0; j1 < 4; j1++) { - int k1 = (l + j1) * 33; - int l1 = (l + j1 + 1) * 33; - int i2 = (i1 + j1) * 33; - int j2 = (i1 + j1 + 1) * 33; - for (int k2 = 0; k2 < 32; k2++) { - double d0 = 0.125D; - double d1 = this.field_147434_q[(k1 + k2)]; - double d2 = this.field_147434_q[(l1 + k2)]; - double d3 = this.field_147434_q[(i2 + k2)]; - double d4 = this.field_147434_q[(j2 + k2)]; - double d5 = (this.field_147434_q[(k1 + k2 + 1)] - d1) * d0; - double d6 = (this.field_147434_q[(l1 + k2 + 1)] - d2) * d0; - double d7 = (this.field_147434_q[(i2 + k2 + 1)] - d3) * d0; - double d8 = (this.field_147434_q[(j2 + k2 + 1)] - d4) * d0; - for (int l2 = 0; l2 < 8; l2++) { - double d9 = 0.25D; - double d10 = d1; - double d11 = d2; - double d12 = (d3 - d1) * d9; - double d13 = (d4 - d2) * d9; - for (int i3 = 0; i3 < 4; i3++) { - int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; - short short1 = 256; - j3 -= short1; - double d14 = 0.25D; - double d16 = (d11 - d10) * d14; - double d15 = d10 - d16; - for (int k3 = 0; k3 < 4; k3++) { - if ((d15 += d16) > 0.0D) { - p_147424_3_[(j3 += short1)] = Blocks.stone; - } else if (k2 * 8 + l2 < b0) { - p_147424_3_[(j3 += short1)] = Blocks.water; - } else { - p_147424_3_[(j3 += short1)] = null; - } - } - d10 += d12; - d11 += d13; - } - d1 += d5; - d2 += d6; - d3 += d7; - d4 += d8; - } - } - } - } - } - - public void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, - BiomeGenBase[] p_147422_5_) { - ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, - p_147422_2_, p_147422_3_, p_147422_5_); - MinecraftForge.EVENT_BUS.post(event); - if (event.getResult() == Result.DENY) { - return; - } - double d0 = 0.03125D; - this.stoneNoise = this.noiseGen4.func_151599_a(this.stoneNoise, p_147422_1_ * 16, p_147422_2_ * 16, 16, 16, - d0 * 2.0D, d0 * 2.0D, 1.0D); - for (int k = 0; k < 16; k++) { - for (int l = 0; l < 16; l++) { - BiomeGenBase biomegenbase = p_147422_5_[(l + k * 16)]; - biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_147422_3_, p_147422_4_, p_147422_1_ * 16 + k, - p_147422_2_ * 16 + l, this.stoneNoise[(l + k * 16)]); - } - } - } - - /** - * loads or generates the chunk at the chunk location specified - */ - @Override - public Chunk loadChunk(int par1, int par2) { - return this.provideChunk(par1, par2); - } - - /** - * Will return back a chunk, if it doesn't exist and its not a MP client it will - * generates all the blocks for the specified chunk from the map seed and chunk - * seed - */ - @Override - public Chunk provideChunk(int x, int z) { - try { - Block[] ablock = new Block[65536]; - //generateTerrain(x, z, ablock); - caveGenerator.func_151539_a(this, worldObj, x, z, ablock); - ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); - } catch (Exception e) { - e.printStackTrace(); - } - return super.provideChunk(x, z); - /* - * rand.setSeed(x * 341873128712L + z * 132897987541L); Block[] ablock = new - * Block[65536]; byte[] abyte = new byte[65536]; generateTerrain(x, z, ablock); - * biomesForGeneration = - * worldObj.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, x - * * 16, z * 16, 16, 16); replaceBlocksForBiome(x, z, ablock, abyte, - * biomesForGeneration); - * - * caveGenerator.func_151539_a(this, worldObj, x, z, ablock); - * caveGenerator.func_151539_a(this, worldObj, x, z, ablock); - * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); - * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); - * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); - * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); - * //villageGenerator.func_151539_a(this, worldObj, x, z, ablock); - * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); - * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); - * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); - * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); - * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); - * mineshaftGenerator.func_151539_a(this, worldObj, x, z, ablock); - * - * Chunk chunk = new Chunk(worldObj, ablock, abyte, x, z); byte[] abyte1 = - * chunk.getBiomeArray(); - * - * for (int k = 0; k < abyte1.length; ++k) abyte1[k] = - * (byte)biomesForGeneration[k].biomeID; - * - * chunk.generateSkylightMap(); return chunk; - */ - } - - public void generateTerrain(int x, int z, Block[] par3BlockArray) { - byte b0 = 63; - biomesForGeneration = worldObj.getWorldChunkManager().getBiomesForGeneration(biomesForGeneration, x * 4 - 2, - z * 4 - 2, 10, 10); - generateNoise(x * 4, 0, z * 4); - - for (int k = 0; k < 4; ++k) { - int l = k * 5; - int i1 = (k + 1) * 5; - - for (int j1 = 0; j1 < 4; ++j1) { - int k1 = (l + j1) * 33; - int l1 = (l + j1 + 1) * 33; - int i2 = (i1 + j1) * 33; - int j2 = (i1 + j1 + 1) * 33; - - for (int k2 = 0; k2 < 32; ++k2) { - double d0 = 0.125D; - double d1 = field_147434_q[k1 + k2]; - double d2 = field_147434_q[l1 + k2]; - double d3 = field_147434_q[i2 + k2]; - double d4 = field_147434_q[j2 + k2]; - double d5 = (field_147434_q[k1 + k2 + 1] - d1) * d0; - double d6 = (field_147434_q[l1 + k2 + 1] - d2) * d0; - double d7 = (field_147434_q[i2 + k2 + 1] - d3) * d0; - double d8 = (field_147434_q[j2 + k2 + 1] - d4) * d0; - - for (int l2 = 0; l2 < 8; ++l2) { - double d9 = 0.25D; - double d10 = d1; - double d11 = d2; - double d12 = (d3 - d1) * d9; - double d13 = (d4 - d2) * d9; - - for (int i3 = 0; i3 < 4; ++i3) { - int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; - short short1 = 256; - j3 -= short1; - double d14 = 0.25D; - double d16 = (d11 - d10) * d14; - double d15 = d10 - d16; - - for (int k3 = 0; k3 < 4; ++k3) - if ((d15 += d16) > 0.0D) - par3BlockArray[j3 += short1] = Blocks.stone; - else if (k2 * 8 + l2 < b0) - par3BlockArray[j3 += short1] = Blocks.water; - else - par3BlockArray[j3 += short1] = null; - - d10 += d12; - d11 += d13; - } - - d1 += d5; - d2 += d6; - d3 += d7; - d4 += d8; - } - } - } - } - } - - private void generateNoise(int x, int y, int z) { - doubleArray4 = noiseGen6.generateNoiseOctaves(doubleArray4, x, z, 5, 5, 200.0D, 200.0D, 0.5D); - doubleArray1 = noiseGen3.generateNoiseOctaves(doubleArray1, x, y, z, 5, 33, 5, 8.555150000000001D, - 4.277575000000001D, 8.555150000000001D); - doubleArray2 = noiseGen1.generateNoiseOctaves(doubleArray2, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); - doubleArray3 = noiseGen2.generateNoiseOctaves(doubleArray3, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); - int l = 0; - int i1 = 0; - for (int j1 = 0; j1 < 5; ++j1) - for (int k1 = 0; k1 < 5; ++k1) { - float f = 0.0F; - float f1 = 0.0F; - float f2 = 0.0F; - byte b0 = 2; - BiomeGenBase biomegenbase = biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; - - for (int l1 = -b0; l1 <= b0; ++l1) - for (int i2 = -b0; i2 <= b0; ++i2) { - BiomeGenBase biomegenbase1 = biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; - float f3 = biomegenbase1.rootHeight; - float f4 = biomegenbase1.heightVariation; - - if (worldType == WorldType.AMPLIFIED && f3 > 0.0F) { - f3 = 1.0F + f3 * 2.0F; - f4 = 1.0F + f4 * 4.0F; - } - - float f5 = parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); - - if (biomegenbase1.rootHeight > biomegenbase.rootHeight) - f5 /= 2.0F; - - f += f4 * f5; - f1 += f3 * f5; - f2 += f5; - } - - f /= f2; - f1 /= f2; - f = f * 0.9F + 0.1F; - f1 = (f1 * 4.0F - 1.0F) / 8.0F; - double d13 = doubleArray4[i1] / 8000.0D; - - if (d13 < 0.0D) - d13 = -d13 * 0.3D; - - d13 = d13 * 3.0D - 2.0D; - - if (d13 < 0.0D) { - d13 /= 2.0D; - - if (d13 < -1.0D) - d13 = -1.0D; - - d13 /= 1.4D; - d13 /= 2.0D; - } else { - if (d13 > 1.0D) - d13 = 1.0D; - - d13 /= 8.0D; - } - - ++i1; - double d12 = f1; - double d14 = f; - d12 += d13 * 0.2D; - d12 = d12 * 8.5D / 8.0D; - double d5 = 8.5D + d12 * 4.0D; - - for (int j2 = 0; j2 < 33; ++j2) { - double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14; - - if (d6 < 0.0D) - d6 *= 4.0D; - - double d7 = doubleArray2[l] / 512.0D; - double d8 = doubleArray3[l] / 512.0D; - double d9 = (doubleArray1[l] / 10.0D + 1.0D) / 2.0D; - double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; - - if (j2 > 29) { - double d11 = (j2 - 29) / 3.0F; - d10 = d10 * (1.0D - d11) + -10.0D * d11; - } - - field_147434_q[l] = d10; - ++l; - } - } - } - - private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_) { - double d0 = 684.412D; - double d1 = 684.412D; - double d2 = 512.0D; - double d3 = 512.0D; - this.doubleArray4 = this.noiseGen6.generateNoiseOctaves(this.doubleArray4, p_147423_1_, p_147423_3_, 5, 5, - 200.0D, 200.0D, 0.5D); - this.doubleArray1 = this.noiseGen3.generateNoiseOctaves(this.doubleArray1, p_147423_1_, p_147423_2_, - p_147423_3_, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); - - this.doubleArray2 = this.noiseGen1.generateNoiseOctaves(this.doubleArray2, p_147423_1_, p_147423_2_, - p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); - - this.doubleArray3 = this.noiseGen2.generateNoiseOctaves(this.doubleArray3, p_147423_1_, p_147423_2_, - p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); - - boolean flag1 = false; - boolean flag = false; - int l = 0; - int i1 = 0; - double d4 = 8.5D; - for (int j1 = 0; j1 < 5; j1++) { - for (int k1 = 0; k1 < 5; k1++) { - float f = 0.0F; - float f1 = 0.0F; - float f2 = 0.0F; - byte b0 = 2; - BiomeGenBase biomegenbase = this.biomesForGeneration[(j1 + 2 + (k1 + 2) * 10)]; - for (int l1 = -b0; l1 <= b0; l1++) { - for (int i2 = -b0; i2 <= b0; i2++) { - BiomeGenBase biomegenbase1 = this.biomesForGeneration[(j1 + l1 + 2 + (k1 + i2 + 2) * 10)]; - float f3 = biomegenbase1.rootHeight; - float f4 = biomegenbase1.heightVariation; - if ((this.worldType == WorldType.AMPLIFIED) && (f3 > 0.0F)) { - f3 = 1.0F + f3 * 2.0F; - f4 = 1.0F + f4 * 4.0F; - } - float f5 = this.parabolicField[(l1 + 2 + (i2 + 2) * 5)] / (f3 + 2.0F); - if (biomegenbase1.rootHeight > biomegenbase.rootHeight) { - f5 /= 2.0F; - } - f += f4 * f5; - f1 += f3 * f5; - f2 += f5; - } - } - f /= f2; - f1 /= f2; - f = f * 0.9F + 0.1F; - f1 = (f1 * 4.0F - 1.0F) / 8.0F; - double d13 = this.doubleArray4[i1] / 8000.0D; - if (d13 < 0.0D) { - d13 = -d13 * 0.3D; - } - d13 = d13 * 3.0D - 2.0D; - if (d13 < 0.0D) { - d13 /= 2.0D; - if (d13 < -1.0D) { - d13 = -1.0D; - } - d13 /= 1.4D; - d13 /= 2.0D; - } else { - if (d13 > 1.0D) { - d13 = 1.0D; - } - d13 /= 8.0D; - } - i1++; - double d12 = f1; - double d14 = f; - d12 += d13 * 0.2D; - d12 = d12 * 8.5D / 8.0D; - double d5 = 8.5D + d12 * 4.0D; - for (int j2 = 0; j2 < 33; j2++) { - double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14; - if (d6 < 0.0D) { - d6 *= 4.0D; - } - double d7 = this.doubleArray2[l] / 512.0D; - double d8 = this.doubleArray3[l] / 512.0D; - double d9 = (this.doubleArray1[l] / 10.0D + 1.0D) / 2.0D; - double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; - if (j2 > 29) { - double d11 = (j2 - 29) / 3.0F; - d10 = d10 * (1.0D - d11) + -10.0D * d11; - } - this.field_147434_q[l] = d10; - l++; - } - } - } - } - - /** - * Checks to see if a chunk exists at x, y - */ - @Override - public boolean chunkExists(int par1, int par2) { - return super.chunkExists(par1, par2); - } - - /** - * Populates chunk with ores etc etc - */ - @Override - public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { - - if (this.worldObj.getChunkFromChunkCoords(par2, par3) != null) { - super.populate(par1IChunkProvider, par2, par3); - try { - //Maybe Custom stuff? - boolean doGen = false; - boolean flag = false; - int k1; - int l1; - int i2; - int x = par2 * 16; - int z = par3 * 16; - BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(x + 16, z + 16); - MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); - doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); - for (k1 = 0; doGen && k1 < 8; ++k1) { - l1 = x + this.rand.nextInt(16) + 8; - i2 = this.rand.nextInt(256); - int j2 = z + this.rand.nextInt(16) + 8; - (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); - } - - if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { - SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); - SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); - } - MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - - - /*boolean generateStructures = true; - - BlockFalling.fallInstantly = true; - int x = par2 * 16; - int z = par3 * 16; - BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(x + 16, z + 16); - this.rand.setSeed(this.worldObj.getSeed()); - long i1 = this.rand.nextLong() / 2L * 2L + 1L; - long j1 = this.rand.nextLong() / 2L * 2L + 1L; - this.rand.setSeed(par2 * i1 + par3 * j1 ^ this.worldObj.getSeed()); - boolean flag = false; - - MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); - - if (generateStructures) { - this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); - // flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, - // this.rand, par2, par3); - this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); - } - - int k1; - int l1; - int i2; - - if (generateStructures) { - if (generateStructures) { - // No specific liquid dimlets specified: we generate default lakes (water and - // lava were appropriate). - if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag - && this.rand.nextInt(4) == 0 - && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, - net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) { - k1 = x + this.rand.nextInt(16) + 8; - l1 = this.rand.nextInt(256); - i2 = z + this.rand.nextInt(16) + 8; - (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2); - } - - if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, - net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA) && !flag - && this.rand.nextInt(8) == 0) { - k1 = x + this.rand.nextInt(16) + 8; - l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); - i2 = z + this.rand.nextInt(16) + 8; - - if (l1 < 63 || this.rand.nextInt(10) == 0) { - (new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2); - } - } - } - * else { // Generate lakes for the specified biomes. for (Block liquid : - * dimensionInformation.getFluidsForLakes()) { if (!flag && this.rand.nextInt(4) - * == 0 && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, - * flag, - * net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType. - * LAKE)) { k1 = x + this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(256); i2 - * = z + this.rand.nextInt(16) + 8; (new - * WorldGenLakes(liquid)).generate(this.worldObj, this.rand, k1, l1, i2); } } } - - } - - boolean doGen = false; - if (generateStructures) { - doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, - net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); - for (k1 = 0; doGen && k1 < 8; ++k1) { - l1 = x + this.rand.nextInt(16) + 8; - i2 = this.rand.nextInt(256); - int j2 = z + this.rand.nextInt(16) + 8; - (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); - } - } - - biomegenbase.decorate(this.worldObj, this.rand, x, z); - if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { - SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); - } - x += 8; - z += 8; - - doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, - net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE); - for (k1 = 0; doGen && k1 < 16; ++k1) { - for (l1 = 0; l1 < 16; ++l1) { - i2 = this.worldObj.getPrecipitationHeight(x + k1, z + l1); - - if (this.worldObj.isBlockFreezable(k1 + x, i2 - 1, l1 + z)) { - this.worldObj.setBlock(k1 + x, i2 - 1, l1 + z, Blocks.ice, 0, 2); - } - - if (this.worldObj.func_147478_e(k1 + x, i2, l1 + z, true)) { - this.worldObj.setBlock(k1 + x, i2, l1 + z, Blocks.snow_layer, 0, 2); - } - } - } - - MinecraftForge.EVENT_BUS - .post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); - - BlockFalling.fallInstantly = false;*/ - // super.populate(par1IChunkProvider, par2, par3); - /* - * net.minecraft.block.BlockFalling.fallInstantly = false; int k = par2 * 16; - * int l = par3 * 16; BiomeGenBase biomegenbase = - * this.worldObj.getBiomeGenForCoords(k + 16, l + 16); - * this.rand.setSeed(this.worldObj.getSeed()); long i1 = this.rand.nextLong() / - * 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; - * this.rand.setSeed(par2 * i1 + par3 * j1 ^ this.worldObj.getSeed()); boolean - * flag = false; - * - * MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, - * this.worldObj, this.rand, par2, par3, flag)); - * - * - * this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, - * par2, par3); flag = - * this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, - * par2, par3); - * this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, - * this.rand, par2, par3); if (flag) { Logger.INFO("Did Generate? "+flag); } - * else { - * //Logger.INFO("Can village spawn here? "+villageGenerator.villageSpawnBiomes. - * contains(biomegenbase)); } - * - * - * if ((biomegenbase != BiomeGenBase.desert) && (biomegenbase != - * BiomeGenBase.desertHills) && (!flag)) { if ((this.rand.nextInt(4) == 0) && - * (TerrainGen.populate(par1IChunkProvider, this.worldObj, this.rand, par2, - * par3, flag, PopulateChunkEvent.Populate.EventType.LAKE))) { int k1 = k + - * this.rand.nextInt(16) + 8; int l1 = this.rand.nextInt(256); int i2 = l + - * this.rand.nextInt(16) + 8; new - * WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, k1, l1, i2); } - * } if ((TerrainGen.populate(par1IChunkProvider, this.worldObj, this.rand, - * par2, par3, flag, PopulateChunkEvent.Populate.EventType.LAVA)) && (!flag) && - * (this.rand.nextInt(8) == 0)) { int k1 = k + this.rand.nextInt(16) + 8; int l1 - * = this.rand.nextInt(this.rand.nextInt(248) + 8); int i2 = l + - * this.rand.nextInt(16) + 8; if ((l1 < 63) || (this.rand.nextInt(10) == 0)) { - * new WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, k1, l1, - * i2); } } int var4 = par2 * 16; int var5 = par3 * 16; - * - * biomegenbase.decorate(this.worldObj, this.rand, k, l); - * SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l - * + 8, 16, 16, this.rand); if (TerrainGen.populate(this, worldObj, rand, par2, - * par3, flag, ANIMALS)) { SpawnerAnimals.performWorldGenSpawning(this.worldObj, - * biomegenbase, k + 8, l + 8, 16, 16, this.rand); } k += 8; l += 8; - * - * MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, - * this.worldObj, this.rand, par2, par3, flag)); - * - * net.minecraft.block.BlockFalling.fallInstantly = false; - */ - } - - /** - * Two modes of operation: if passed true, save all Chunks in one go. If passed - * false, save up to two chunks. Return true if all chunks have been saved. - */ - @Override - public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) { - return super.saveChunks(par1, par2IProgressUpdate); - } - - /** - * Save extra data not associated with any Chunk. Not saved during autosave, - * only during world unload. Currently unimplemented. - */ - @Override - public void saveExtraData() { - super.saveExtraData(); - } - - /** - * Unloads chunks that are marked to be unloaded. This is not guaranteed to - * unload every such chunk. - */ - @Override - public boolean unloadQueuedChunks() { - return super.unloadQueuedChunks(); - } - - /** - * Returns if the IChunkProvider supports saving. - */ - @Override - public boolean canSave() { - return super.canSave(); - } - - /** - * Converts the instance data to a readable string. - */ - @Override - public String makeString() { - return "RandomLevelSource"; - } - - /** - * Returns a list of creatures of the specified type that can spawn at the given - * location. - */ - @SuppressWarnings("rawtypes") - @Override - public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) { - BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); - return (par1EnumCreatureType == EnumCreatureType.monster) - && (this.scatteredFeatureGenerator.func_143030_a(par2, par3, par4)) - ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() - : biomegenbase.getSpawnableList(par1EnumCreatureType); - } - - @Override - public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, - int p_147416_5_) { - Logger.INFO("func_147416_a: " + p_147416_2_); - return super.func_147416_a(p_147416_1_, p_147416_2_, p_147416_3_, p_147416_4_, p_147416_5_); - /* - * return "ExtendedVillage".equals(p_147416_2_) && this.villageGenerator != null - * ? this.villageGenerator.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, - * p_147416_5_) : null; - */ - } - - @Override - public int getLoadedChunkCount() { - return super.getLoadedChunkCount(); - } - - @Override - public void recreateStructures(int par1, int par2) { - super.recreateStructures(par1, par2); - // this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, - // (Block[])null); - // this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, - // (Block[])null); - // this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, - // (Block[])null); - - } -}
\ No newline at end of file + private Random rand; + private NoiseGeneratorOctaves noiseGen1; + private NoiseGeneratorOctaves noiseGen2; + private NoiseGeneratorOctaves noiseGen3; + private NoiseGeneratorPerlin noiseGen4; + /** + * Reference to the World object. + */ + private World worldObj; + + private WorldType worldType; + private final double[] field_147434_q; + private final float[] parabolicField; + private double[] stoneNoise = new double[256]; + private MapGenBase caveGenerator = new MapGenCaves(); + /** + * Holds Stronghold Generator + */ + // private MapGenStronghold strongholdGenerator = new + // MapGenStronghold(); + + /** + * Holds Mineshaft Generator + */ + private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); + + private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + /** + * Holds ravine generator + */ + private MapGenBase ravineGenerator = new MapGenLargeRavine(); + /** + * The biomes that are used to generate the chunk + */ + private BiomeGenBase[] biomesForGeneration; + + double[] doubleArray1; + double[] doubleArray2; + double[] doubleArray3; + double[] doubleArray4; + + int[][] field_73219_j = new int[32][32]; + Map map; + + // Some Init Field? + { + try { + List<BiomeGenBase> y = new ArrayList<BiomeGenBase>(); + if (!villageSpawnBiomes.isEmpty()) { + y.addAll(villageSpawnBiomes); + } + + for (BiomeGenBase h : gtPlusPlus.australia.gen.map.MapGenExtendedVillage.villageSpawnBiomes) { + if (!y.contains(h)) { + if (h instanceof BiomeGenBase) { + try { + y.add(h); + } catch (Throwable t) { + } + } + } + } + if (y.size() > villageSpawnBiomes.size()) { + villageSpawnBiomes = y; + } + } catch (Throwable t) { + } + + caveGenerator = TerrainGen.getModdedMapGen( + caveGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); + mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen( + mineshaftGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); + scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen( + scatteredFeatureGenerator, + net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); + ravineGenerator = TerrainGen.getModdedMapGen( + ravineGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); + } + + public ChunkProviderAustralia(World par1World, long par2) { + super(par1World, par2, true); + this.worldObj = par1World; + this.worldType = par1World.getWorldInfo().getTerrainType(); + this.rand = new Random(par2); + this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16); + this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16); + this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8); + this.noiseGen4 = new NoiseGeneratorPerlin(this.rand, 4); + this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); + this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); + this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); + this.field_147434_q = new double[2500]; + this.parabolicField = new float[25]; + for (int j = -2; j <= 2; j++) { + for (int k = -2; k <= 2; k++) { + float f = 10.0F / MathHelper.sqrt_float(j * j + k * k + 0.2F); + this.parabolicField[(j + 2 + (k + 2) * 5)] = f; + } + } + NoiseGenerator[] noiseGens = { + this.noiseGen1, + this.noiseGen2, + this.noiseGen3, + this.noiseGen4, + this.noiseGen5, + this.noiseGen6, + this.mobSpawnerNoise + }; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); + this.noiseGen1 = ((NoiseGeneratorOctaves) noiseGens[0]); + this.noiseGen2 = ((NoiseGeneratorOctaves) noiseGens[1]); + this.noiseGen3 = ((NoiseGeneratorOctaves) noiseGens[2]); + this.noiseGen4 = ((NoiseGeneratorPerlin) noiseGens[3]); + this.noiseGen5 = ((NoiseGeneratorOctaves) noiseGens[4]); + this.noiseGen6 = ((NoiseGeneratorOctaves) noiseGens[5]); + this.mobSpawnerNoise = ((NoiseGeneratorOctaves) noiseGens[6]); + } + + public void func_147424_a(int p_147424_1_, int p_147424_2_, Block[] p_147424_3_) { + byte b0 = 63; + this.biomesForGeneration = this.worldObj + .getWorldChunkManager() + .getBiomesForGeneration(this.biomesForGeneration, p_147424_1_ * 4 - 2, p_147424_2_ * 4 - 2, 10, 10); + + func_147423_a(p_147424_1_ * 4, 0, p_147424_2_ * 4); + for (int k = 0; k < 4; k++) { + int l = k * 5; + int i1 = (k + 1) * 5; + for (int j1 = 0; j1 < 4; j1++) { + int k1 = (l + j1) * 33; + int l1 = (l + j1 + 1) * 33; + int i2 = (i1 + j1) * 33; + int j2 = (i1 + j1 + 1) * 33; + for (int k2 = 0; k2 < 32; k2++) { + double d0 = 0.125D; + double d1 = this.field_147434_q[(k1 + k2)]; + double d2 = this.field_147434_q[(l1 + k2)]; + double d3 = this.field_147434_q[(i2 + k2)]; + double d4 = this.field_147434_q[(j2 + k2)]; + double d5 = (this.field_147434_q[(k1 + k2 + 1)] - d1) * d0; + double d6 = (this.field_147434_q[(l1 + k2 + 1)] - d2) * d0; + double d7 = (this.field_147434_q[(i2 + k2 + 1)] - d3) * d0; + double d8 = (this.field_147434_q[(j2 + k2 + 1)] - d4) * d0; + for (int l2 = 0; l2 < 8; l2++) { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + for (int i3 = 0; i3 < 4; i3++) { + int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; + short short1 = 256; + j3 -= short1; + double d14 = 0.25D; + double d16 = (d11 - d10) * d14; + double d15 = d10 - d16; + for (int k3 = 0; k3 < 4; k3++) { + if ((d15 += d16) > 0.0D) { + p_147424_3_[(j3 += short1)] = Blocks.stone; + } else if (k2 * 8 + l2 < b0) { + p_147424_3_[(j3 += short1)] = Blocks.water; + } else { + p_147424_3_[(j3 += short1)] = null; + } + } + d10 += d12; + d11 += d13; + } + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void replaceBlocksForBiome( + int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, BiomeGenBase[] p_147422_5_) { + ChunkProviderEvent.ReplaceBiomeBlocks event = + new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, p_147422_2_, p_147422_3_, p_147422_5_); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) { + return; + } + double d0 = 0.03125D; + this.stoneNoise = this.noiseGen4.func_151599_a( + this.stoneNoise, p_147422_1_ * 16, p_147422_2_ * 16, 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); + for (int k = 0; k < 16; k++) { + for (int l = 0; l < 16; l++) { + BiomeGenBase biomegenbase = p_147422_5_[(l + k * 16)]; + biomegenbase.genTerrainBlocks( + this.worldObj, + this.rand, + p_147422_3_, + p_147422_4_, + p_147422_1_ * 16 + k, + p_147422_2_ * 16 + l, + this.stoneNoise[(l + k * 16)]); + } + } + } + + /** + * loads or generates the chunk at the chunk location specified + */ + @Override + public Chunk loadChunk(int par1, int par2) { + return this.provideChunk(par1, par2); + } + + /** + * Will return back a chunk, if it doesn't exist and its not a MP client it will + * generates all the blocks for the specified chunk from the map seed and chunk + * seed + */ + @Override + public Chunk provideChunk(int x, int z) { + try { + Block[] ablock = new Block[65536]; + // generateTerrain(x, z, ablock); + caveGenerator.func_151539_a(this, worldObj, x, z, ablock); + ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); + } catch (Exception e) { + e.printStackTrace(); + } + return super.provideChunk(x, z); + /* + * rand.setSeed(x * 341873128712L + z * 132897987541L); Block[] ablock = new + * Block[65536]; byte[] abyte = new byte[65536]; generateTerrain(x, z, ablock); + * biomesForGeneration = + * worldObj.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, x + * * 16, z * 16, 16, 16); replaceBlocksForBiome(x, z, ablock, abyte, + * biomesForGeneration); + * + * caveGenerator.func_151539_a(this, worldObj, x, z, ablock); + * caveGenerator.func_151539_a(this, worldObj, x, z, ablock); + * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); + * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); + * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); + * ravineGenerator.func_151539_a(this, worldObj, x, z, ablock); + * //villageGenerator.func_151539_a(this, worldObj, x, z, ablock); + * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); + * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); + * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); + * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); + * scatteredFeatureGenerator.func_151539_a(this, worldObj, x, z, ablock); + * mineshaftGenerator.func_151539_a(this, worldObj, x, z, ablock); + * + * Chunk chunk = new Chunk(worldObj, ablock, abyte, x, z); byte[] abyte1 = + * chunk.getBiomeArray(); + * + * for (int k = 0; k < abyte1.length; ++k) abyte1[k] = + * (byte)biomesForGeneration[k].biomeID; + * + * chunk.generateSkylightMap(); return chunk; + */ + } + + public void generateTerrain(int x, int z, Block[] par3BlockArray) { + byte b0 = 63; + biomesForGeneration = worldObj.getWorldChunkManager() + .getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); + generateNoise(x * 4, 0, z * 4); + + for (int k = 0; k < 4; ++k) { + int l = k * 5; + int i1 = (k + 1) * 5; + + for (int j1 = 0; j1 < 4; ++j1) { + int k1 = (l + j1) * 33; + int l1 = (l + j1 + 1) * 33; + int i2 = (i1 + j1) * 33; + int j2 = (i1 + j1 + 1) * 33; + + for (int k2 = 0; k2 < 32; ++k2) { + double d0 = 0.125D; + double d1 = field_147434_q[k1 + k2]; + double d2 = field_147434_q[l1 + k2]; + double d3 = field_147434_q[i2 + k2]; + double d4 = field_147434_q[j2 + k2]; + double d5 = (field_147434_q[k1 + k2 + 1] - d1) * d0; + double d6 = (field_147434_q[l1 + k2 + 1] - d2) * d0; + double d7 = (field_147434_q[i2 + k2 + 1] - d3) * d0; + double d8 = (field_147434_q[j2 + k2 + 1] - d4) * d0; + + for (int l2 = 0; l2 < 8; ++l2) { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + + for (int i3 = 0; i3 < 4; ++i3) { + int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; + short short1 = 256; + j3 -= short1; + double d14 = 0.25D; + double d16 = (d11 - d10) * d14; + double d15 = d10 - d16; + + for (int k3 = 0; k3 < 4; ++k3) + if ((d15 += d16) > 0.0D) par3BlockArray[j3 += short1] = Blocks.stone; + else if (k2 * 8 + l2 < b0) par3BlockArray[j3 += short1] = Blocks.water; + else par3BlockArray[j3 += short1] = null; + + d10 += d12; + d11 += d13; + } + + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + private void generateNoise(int x, int y, int z) { + doubleArray4 = noiseGen6.generateNoiseOctaves(doubleArray4, x, z, 5, 5, 200.0D, 200.0D, 0.5D); + doubleArray1 = noiseGen3.generateNoiseOctaves( + doubleArray1, x, y, z, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); + doubleArray2 = noiseGen1.generateNoiseOctaves(doubleArray2, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); + doubleArray3 = noiseGen2.generateNoiseOctaves(doubleArray3, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); + int l = 0; + int i1 = 0; + for (int j1 = 0; j1 < 5; ++j1) + for (int k1 = 0; k1 < 5; ++k1) { + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + byte b0 = 2; + BiomeGenBase biomegenbase = biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; + + for (int l1 = -b0; l1 <= b0; ++l1) + for (int i2 = -b0; i2 <= b0; ++i2) { + BiomeGenBase biomegenbase1 = biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; + float f3 = biomegenbase1.rootHeight; + float f4 = biomegenbase1.heightVariation; + + if (worldType == WorldType.AMPLIFIED && f3 > 0.0F) { + f3 = 1.0F + f3 * 2.0F; + f4 = 1.0F + f4 * 4.0F; + } + + float f5 = parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); + + if (biomegenbase1.rootHeight > biomegenbase.rootHeight) f5 /= 2.0F; + + f += f4 * f5; + f1 += f3 * f5; + f2 += f5; + } + + f /= f2; + f1 /= f2; + f = f * 0.9F + 0.1F; + f1 = (f1 * 4.0F - 1.0F) / 8.0F; + double d13 = doubleArray4[i1] / 8000.0D; + + if (d13 < 0.0D) d13 = -d13 * 0.3D; + + d13 = d13 * 3.0D - 2.0D; + + if (d13 < 0.0D) { + d13 /= 2.0D; + + if (d13 < -1.0D) d13 = -1.0D; + + d13 /= 1.4D; + d13 /= 2.0D; + } else { + if (d13 > 1.0D) d13 = 1.0D; + + d13 /= 8.0D; + } + + ++i1; + double d12 = f1; + double d14 = f; + d12 += d13 * 0.2D; + d12 = d12 * 8.5D / 8.0D; + double d5 = 8.5D + d12 * 4.0D; + + for (int j2 = 0; j2 < 33; ++j2) { + double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14; + + if (d6 < 0.0D) d6 *= 4.0D; + + double d7 = doubleArray2[l] / 512.0D; + double d8 = doubleArray3[l] / 512.0D; + double d9 = (doubleArray1[l] / 10.0D + 1.0D) / 2.0D; + double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; + + if (j2 > 29) { + double d11 = (j2 - 29) / 3.0F; + d10 = d10 * (1.0D - d11) + -10.0D * d11; + } + + field_147434_q[l] = d10; + ++l; + } + } + } + + private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_) { + double d0 = 684.412D; + double d1 = 684.412D; + double d2 = 512.0D; + double d3 = 512.0D; + this.doubleArray4 = this.noiseGen6.generateNoiseOctaves( + this.doubleArray4, p_147423_1_, p_147423_3_, 5, 5, 200.0D, 200.0D, 0.5D); + this.doubleArray1 = this.noiseGen3.generateNoiseOctaves( + this.doubleArray1, + p_147423_1_, + p_147423_2_, + p_147423_3_, + 5, + 33, + 5, + 8.555150000000001D, + 4.277575000000001D, + 8.555150000000001D); + + this.doubleArray2 = this.noiseGen1.generateNoiseOctaves( + this.doubleArray2, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + + this.doubleArray3 = this.noiseGen2.generateNoiseOctaves( + this.doubleArray3, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + + boolean flag1 = false; + boolean flag = false; + int l = 0; + int i1 = 0; + double d4 = 8.5D; + for (int j1 = 0; j1 < 5; j1++) { + for (int k1 = 0; k1 < 5; k1++) { + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + byte b0 = 2; + BiomeGenBase biomegenbase = this.biomesForGeneration[(j1 + 2 + (k1 + 2) * 10)]; + for (int l1 = -b0; l1 <= b0; l1++) { + for (int i2 = -b0; i2 <= b0; i2++) { + BiomeGenBase biomegenbase1 = this.biomesForGeneration[(j1 + l1 + 2 + (k1 + i2 + 2) * 10)]; + float f3 = biomegenbase1.rootHeight; + float f4 = biomegenbase1.heightVariation; + if ((this.worldType == WorldType.AMPLIFIED) && (f3 > 0.0F)) { + f3 = 1.0F + f3 * 2.0F; + f4 = 1.0F + f4 * 4.0F; + } + float f5 = this.parabolicField[(l1 + 2 + (i2 + 2) * 5)] / (f3 + 2.0F); + if (biomegenbase1.rootHeight > biomegenbase.rootHeight) { + f5 /= 2.0F; + } + f += f4 * f5; + f1 += f3 * f5; + f2 += f5; + } + } + f /= f2; + f1 /= f2; + f = f * 0.9F + 0.1F; + f1 = (f1 * 4.0F - 1.0F) / 8.0F; + double d13 = this.doubleArray4[i1] / 8000.0D; + if (d13 < 0.0D) { + d13 = -d13 * 0.3D; + } + d13 = d13 * 3.0D - 2.0D; + if (d13 < 0.0D) { + d13 /= 2.0D; + if (d13 < -1.0D) { + d13 = -1.0D; + } + d13 /= 1.4D; + d13 /= 2.0D; + } else { + if (d13 > 1.0D) { + d13 = 1.0D; + } + d13 /= 8.0D; + } + i1++; + double d12 = f1; + double d14 = f; + d12 += d13 * 0.2D; + d12 = d12 * 8.5D / 8.0D; + double d5 = 8.5D + d12 * 4.0D; + for (int j2 = 0; j2 < 33; j2++) { + double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14; + if (d6 < 0.0D) { + d6 *= 4.0D; + } + double d7 = this.doubleArray2[l] / 512.0D; + double d8 = this.doubleArray3[l] / 512.0D; + double d9 = (this.doubleArray1[l] / 10.0D + 1.0D) / 2.0D; + double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; + if (j2 > 29) { + double d11 = (j2 - 29) / 3.0F; + d10 = d10 * (1.0D - d11) + -10.0D * d11; + } + this.field_147434_q[l] = d10; + l++; + } + } + } + } + + /** + * Checks to see if a chunk exists at x, y + */ + @Override + public boolean chunkExists(int par1, int par2) { + return super.chunkExists(par1, par2); + } + + /** + * Populates chunk with ores etc etc + */ + @Override + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { + + if (this.worldObj.getChunkFromChunkCoords(par2, par3) != null) { + super.populate(par1IChunkProvider, par2, par3); + try { + // Maybe Custom stuff? + boolean doGen = false; + boolean flag = false; + int k1; + int l1; + int i2; + int x = par2 * 16; + int z = par3 * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(x + 16, z + 16); + MinecraftForge.EVENT_BUS.post( + new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + doGen = TerrainGen.populate( + par1IChunkProvider, + worldObj, + rand, + par2, + par3, + flag, + net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); + for (k1 = 0; doGen && k1 < 8; ++k1) { + l1 = x + this.rand.nextInt(16) + 8; + i2 = this.rand.nextInt(256); + int j2 = z + this.rand.nextInt(16) + 8; + (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); + } + + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { + SpawnerAnimals.performWorldGenSpawning( + this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); + SpawnerAnimals.performWorldGenSpawning( + this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); + } + MinecraftForge.EVENT_BUS.post( + new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /*boolean generateStructures = true; + + BlockFalling.fallInstantly = true; + int x = par2 * 16; + int z = par3 * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(x + 16, z + 16); + this.rand.setSeed(this.worldObj.getSeed()); + long i1 = this.rand.nextLong() / 2L * 2L + 1L; + long j1 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed(par2 * i1 + par3 * j1 ^ this.worldObj.getSeed()); + boolean flag = false; + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + + if (generateStructures) { + this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + // flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, + // this.rand, par2, par3); + this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + } + + int k1; + int l1; + int i2; + + if (generateStructures) { + if (generateStructures) { + // No specific liquid dimlets specified: we generate default lakes (water and + // lava were appropriate). + if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag + && this.rand.nextInt(4) == 0 + && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, + net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) { + k1 = x + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(256); + i2 = z + this.rand.nextInt(16) + 8; + (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2); + } + + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, + net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA) && !flag + && this.rand.nextInt(8) == 0) { + k1 = x + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); + i2 = z + this.rand.nextInt(16) + 8; + + if (l1 < 63 || this.rand.nextInt(10) == 0) { + (new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2); + } + } + } + * else { // Generate lakes for the specified biomes. for (Block liquid : + * dimensionInformation.getFluidsForLakes()) { if (!flag && this.rand.nextInt(4) + * == 0 && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, + * flag, + * net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType. + * LAKE)) { k1 = x + this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(256); i2 + * = z + this.rand.nextInt(16) + 8; (new + * WorldGenLakes(liquid)).generate(this.worldObj, this.rand, k1, l1, i2); } } } + + } + + boolean doGen = false; + if (generateStructures) { + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, + net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); + for (k1 = 0; doGen && k1 < 8; ++k1) { + l1 = x + this.rand.nextInt(16) + 8; + i2 = this.rand.nextInt(256); + int j2 = z + this.rand.nextInt(16) + 8; + (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); + } + } + + biomegenbase.decorate(this.worldObj, this.rand, x, z); + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { + SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand); + } + x += 8; + z += 8; + + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, + net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE); + for (k1 = 0; doGen && k1 < 16; ++k1) { + for (l1 = 0; l1 < 16; ++l1) { + i2 = this.worldObj.getPrecipitationHeight(x + k1, z + l1); + + if (this.worldObj.isBlockFreezable(k1 + x, i2 - 1, l1 + z)) { + this.worldObj.setBlock(k1 + x, i2 - 1, l1 + z, Blocks.ice, 0, 2); + } + + if (this.worldObj.func_147478_e(k1 + x, i2, l1 + z, true)) { + this.worldObj.setBlock(k1 + x, i2, l1 + z, Blocks.snow_layer, 0, 2); + } + } + } + + MinecraftForge.EVENT_BUS + .post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + + BlockFalling.fallInstantly = false;*/ + // super.populate(par1IChunkProvider, par2, par3); + /* + * net.minecraft.block.BlockFalling.fallInstantly = false; int k = par2 * 16; + * int l = par3 * 16; BiomeGenBase biomegenbase = + * this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + * this.rand.setSeed(this.worldObj.getSeed()); long i1 = this.rand.nextLong() / + * 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; + * this.rand.setSeed(par2 * i1 + par3 * j1 ^ this.worldObj.getSeed()); boolean + * flag = false; + * + * MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, + * this.worldObj, this.rand, par2, par3, flag)); + * + * + * this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, + * par2, par3); flag = + * this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, + * par2, par3); + * this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, + * this.rand, par2, par3); if (flag) { Logger.INFO("Did Generate? "+flag); } + * else { + * //Logger.INFO("Can village spawn here? "+villageGenerator.villageSpawnBiomes. + * contains(biomegenbase)); } + * + * + * if ((biomegenbase != BiomeGenBase.desert) && (biomegenbase != + * BiomeGenBase.desertHills) && (!flag)) { if ((this.rand.nextInt(4) == 0) && + * (TerrainGen.populate(par1IChunkProvider, this.worldObj, this.rand, par2, + * par3, flag, PopulateChunkEvent.Populate.EventType.LAKE))) { int k1 = k + + * this.rand.nextInt(16) + 8; int l1 = this.rand.nextInt(256); int i2 = l + + * this.rand.nextInt(16) + 8; new + * WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, k1, l1, i2); } + * } if ((TerrainGen.populate(par1IChunkProvider, this.worldObj, this.rand, + * par2, par3, flag, PopulateChunkEvent.Populate.EventType.LAVA)) && (!flag) && + * (this.rand.nextInt(8) == 0)) { int k1 = k + this.rand.nextInt(16) + 8; int l1 + * = this.rand.nextInt(this.rand.nextInt(248) + 8); int i2 = l + + * this.rand.nextInt(16) + 8; if ((l1 < 63) || (this.rand.nextInt(10) == 0)) { + * new WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, k1, l1, + * i2); } } int var4 = par2 * 16; int var5 = par3 * 16; + * + * biomegenbase.decorate(this.worldObj, this.rand, k, l); + * SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + * + 8, 16, 16, this.rand); if (TerrainGen.populate(this, worldObj, rand, par2, + * par3, flag, ANIMALS)) { SpawnerAnimals.performWorldGenSpawning(this.worldObj, + * biomegenbase, k + 8, l + 8, 16, 16, this.rand); } k += 8; l += 8; + * + * MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, + * this.worldObj, this.rand, par2, par3, flag)); + * + * net.minecraft.block.BlockFalling.fallInstantly = false; + */ + } + + /** + * Two modes of operation: if passed true, save all Chunks in one go. If passed + * false, save up to two chunks. Return true if all chunks have been saved. + */ + @Override + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) { + return super.saveChunks(par1, par2IProgressUpdate); + } + + /** + * Save extra data not associated with any Chunk. Not saved during autosave, + * only during world unload. Currently unimplemented. + */ + @Override + public void saveExtraData() { + super.saveExtraData(); + } + + /** + * Unloads chunks that are marked to be unloaded. This is not guaranteed to + * unload every such chunk. + */ + @Override + public boolean unloadQueuedChunks() { + return super.unloadQueuedChunks(); + } + + /** + * Returns if the IChunkProvider supports saving. + */ + @Override + public boolean canSave() { + return super.canSave(); + } + + /** + * Converts the instance data to a readable string. + */ + @Override + public String makeString() { + return "RandomLevelSource"; + } + + /** + * Returns a list of creatures of the specified type that can spawn at the given + * location. + */ + @SuppressWarnings("rawtypes") + @Override + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return (par1EnumCreatureType == EnumCreatureType.monster) + && (this.scatteredFeatureGenerator.func_143030_a(par2, par3, par4)) + ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() + : biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + @Override + public ChunkPosition func_147416_a( + World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) { + Logger.INFO("func_147416_a: " + p_147416_2_); + return super.func_147416_a(p_147416_1_, p_147416_2_, p_147416_3_, p_147416_4_, p_147416_5_); + /* + * return "ExtendedVillage".equals(p_147416_2_) && this.villageGenerator != null + * ? this.villageGenerator.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, + * p_147416_5_) : null; + */ + } + + @Override + public int getLoadedChunkCount() { + return super.getLoadedChunkCount(); + } + + @Override + public void recreateStructures(int par1, int par2) { + super.recreateStructures(par1, par2); + // this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, + // (Block[])null); + // this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, + // (Block[])null); + // this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, + // (Block[])null); + + } +} diff --git a/src/main/java/gtPlusPlus/australia/dimension/Dimension_Australia.java b/src/main/java/gtPlusPlus/australia/dimension/Dimension_Australia.java index ff9e81085d..f08fa2585a 100644 --- a/src/main/java/gtPlusPlus/australia/dimension/Dimension_Australia.java +++ b/src/main/java/gtPlusPlus/australia/dimension/Dimension_Australia.java @@ -1,23 +1,22 @@ package gtPlusPlus.australia.dimension; -import net.minecraft.block.Block; import gtPlusPlus.australia.block.BlockAustraliaPortal; import gtPlusPlus.australia.item.ItemAustraliaPortalTrigger; import gtPlusPlus.australia.world.AustraliaWorldProvider; import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; import net.minecraftforge.common.DimensionManager; public class Dimension_Australia { - public Object instance; - public static int DIMID = CORE.AUSTRALIA_ID; - public static BlockAustraliaPortal portalBlock; - public static ItemAustraliaPortalTrigger portalItem; - public static Block blockPortalFrame; - - public void load() { - DimensionManager.registerProviderType(DIMID, AustraliaWorldProvider.class, false); - DimensionManager.registerDimension(DIMID, DIMID); - } + public Object instance; + public static int DIMID = CORE.AUSTRALIA_ID; + public static BlockAustraliaPortal portalBlock; + public static ItemAustraliaPortalTrigger portalItem; + public static Block blockPortalFrame; + public void load() { + DimensionManager.registerProviderType(DIMID, AustraliaWorldProvider.class, false); + DimensionManager.registerDimension(DIMID, DIMID); + } } diff --git a/src/main/java/gtPlusPlus/australia/entity/model/ModelAustralianSpider.java b/src/main/java/gtPlusPlus/australia/entity/model/ModelAustralianSpider.java index 05b43b7558..c9ab30bc4f 100644 --- a/src/main/java/gtPlusPlus/australia/entity/model/ModelAustralianSpider.java +++ b/src/main/java/gtPlusPlus/australia/entity/model/ModelAustralianSpider.java @@ -10,139 +10,150 @@ import net.minecraft.util.MathHelper; @SideOnly(Side.CLIENT) public class ModelAustralianSpider extends ModelBase { - /** The spider's head box */ - public ModelRenderer spiderHead; - /** The spider's neck box */ - public ModelRenderer spiderNeck; - /** The spider's body box */ - public ModelRenderer spiderBody; - /** Spider's first leg */ - public ModelRenderer spiderLeg1; - /** Spider's second leg */ - public ModelRenderer spiderLeg2; - /** Spider's third leg */ - public ModelRenderer spiderLeg3; - /** Spider's fourth leg */ - public ModelRenderer spiderLeg4; - /** Spider's fifth leg */ - public ModelRenderer spiderLeg5; - /** Spider's sixth leg */ - public ModelRenderer spiderLeg6; - /** Spider's seventh leg */ - public ModelRenderer spiderLeg7; - /** Spider's eight leg */ - public ModelRenderer spiderLeg8; + /** The spider's head box */ + public ModelRenderer spiderHead; + /** The spider's neck box */ + public ModelRenderer spiderNeck; + /** The spider's body box */ + public ModelRenderer spiderBody; + /** Spider's first leg */ + public ModelRenderer spiderLeg1; + /** Spider's second leg */ + public ModelRenderer spiderLeg2; + /** Spider's third leg */ + public ModelRenderer spiderLeg3; + /** Spider's fourth leg */ + public ModelRenderer spiderLeg4; + /** Spider's fifth leg */ + public ModelRenderer spiderLeg5; + /** Spider's sixth leg */ + public ModelRenderer spiderLeg6; + /** Spider's seventh leg */ + public ModelRenderer spiderLeg7; + /** Spider's eight leg */ + public ModelRenderer spiderLeg8; - public ModelAustralianSpider() { - float f = 0.0F; - byte b0 = 15; - this.spiderHead = new ModelRenderer(this, 32, 4); - this.spiderHead.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, f); - this.spiderHead.setRotationPoint(0.0F, (float) b0, -3.0F); - this.spiderNeck = new ModelRenderer(this, 0, 0); - this.spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, f); - this.spiderNeck.setRotationPoint(0.0F, (float) b0, 0.0F); - this.spiderBody = new ModelRenderer(this, 0, 12); - this.spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, f); - this.spiderBody.setRotationPoint(0.0F, (float) b0, 9.0F); - this.spiderLeg1 = new ModelRenderer(this, 18, 0); - this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg1.setRotationPoint(-4.0F, (float) b0, 2.0F); - this.spiderLeg2 = new ModelRenderer(this, 18, 0); - this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg2.setRotationPoint(4.0F, (float) b0, 2.0F); - this.spiderLeg3 = new ModelRenderer(this, 18, 0); - this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg3.setRotationPoint(-4.0F, (float) b0, 1.0F); - this.spiderLeg4 = new ModelRenderer(this, 18, 0); - this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg4.setRotationPoint(4.0F, (float) b0, 1.0F); - this.spiderLeg5 = new ModelRenderer(this, 18, 0); - this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg5.setRotationPoint(-4.0F, (float) b0, 0.0F); - this.spiderLeg6 = new ModelRenderer(this, 18, 0); - this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg6.setRotationPoint(4.0F, (float) b0, 0.0F); - this.spiderLeg7 = new ModelRenderer(this, 18, 0); - this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg7.setRotationPoint(-4.0F, (float) b0, -1.0F); - this.spiderLeg8 = new ModelRenderer(this, 18, 0); - this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); - this.spiderLeg8.setRotationPoint(4.0F, (float) b0, -1.0F); - } + public ModelAustralianSpider() { + float f = 0.0F; + byte b0 = 15; + this.spiderHead = new ModelRenderer(this, 32, 4); + this.spiderHead.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, f); + this.spiderHead.setRotationPoint(0.0F, (float) b0, -3.0F); + this.spiderNeck = new ModelRenderer(this, 0, 0); + this.spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, f); + this.spiderNeck.setRotationPoint(0.0F, (float) b0, 0.0F); + this.spiderBody = new ModelRenderer(this, 0, 12); + this.spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, f); + this.spiderBody.setRotationPoint(0.0F, (float) b0, 9.0F); + this.spiderLeg1 = new ModelRenderer(this, 18, 0); + this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg1.setRotationPoint(-4.0F, (float) b0, 2.0F); + this.spiderLeg2 = new ModelRenderer(this, 18, 0); + this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg2.setRotationPoint(4.0F, (float) b0, 2.0F); + this.spiderLeg3 = new ModelRenderer(this, 18, 0); + this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg3.setRotationPoint(-4.0F, (float) b0, 1.0F); + this.spiderLeg4 = new ModelRenderer(this, 18, 0); + this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg4.setRotationPoint(4.0F, (float) b0, 1.0F); + this.spiderLeg5 = new ModelRenderer(this, 18, 0); + this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg5.setRotationPoint(-4.0F, (float) b0, 0.0F); + this.spiderLeg6 = new ModelRenderer(this, 18, 0); + this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg6.setRotationPoint(4.0F, (float) b0, 0.0F); + this.spiderLeg7 = new ModelRenderer(this, 18, 0); + this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg7.setRotationPoint(-4.0F, (float) b0, -1.0F); + this.spiderLeg8 = new ModelRenderer(this, 18, 0); + this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg8.setRotationPoint(4.0F, (float) b0, -1.0F); + } - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, - float p_78088_6_, float p_78088_7_) { - this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - this.spiderHead.render(p_78088_7_); - this.spiderNeck.render(p_78088_7_); - this.spiderBody.render(p_78088_7_); - this.spiderLeg1.render(p_78088_7_); - this.spiderLeg2.render(p_78088_7_); - this.spiderLeg3.render(p_78088_7_); - this.spiderLeg4.render(p_78088_7_); - this.spiderLeg5.render(p_78088_7_); - this.spiderLeg6.render(p_78088_7_); - this.spiderLeg7.render(p_78088_7_); - this.spiderLeg8.render(p_78088_7_); - } + /** + * Sets the models various rotation angles then renders the model. + */ + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + this.spiderHead.render(p_78088_7_); + this.spiderNeck.render(p_78088_7_); + this.spiderBody.render(p_78088_7_); + this.spiderLeg1.render(p_78088_7_); + this.spiderLeg2.render(p_78088_7_); + this.spiderLeg3.render(p_78088_7_); + this.spiderLeg4.render(p_78088_7_); + this.spiderLeg5.render(p_78088_7_); + this.spiderLeg6.render(p_78088_7_); + this.spiderLeg7.render(p_78088_7_); + this.spiderLeg8.render(p_78088_7_); + } - /** - * Sets the model's various rotation angles. For bipeds, par1 and par2 are used - * for animating the movement of arms and legs, where par1 represents the - * time(so that arms and legs swing back and forth) and par2 represents how - * "far" arms and legs can swing at most. - */ - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, - float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { - this.spiderHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); - this.spiderHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); - float f6 = ((float) Math.PI / 4F); - this.spiderLeg1.rotateAngleZ = -f6; - this.spiderLeg2.rotateAngleZ = f6; - this.spiderLeg3.rotateAngleZ = -f6 * 0.74F; - this.spiderLeg4.rotateAngleZ = f6 * 0.74F; - this.spiderLeg5.rotateAngleZ = -f6 * 0.74F; - this.spiderLeg6.rotateAngleZ = f6 * 0.74F; - this.spiderLeg7.rotateAngleZ = -f6; - this.spiderLeg8.rotateAngleZ = f6; - float f7 = -0.0F; - float f8 = 0.3926991F; - this.spiderLeg1.rotateAngleY = f8 * 2.0F + f7; - this.spiderLeg2.rotateAngleY = -f8 * 2.0F - f7; - this.spiderLeg3.rotateAngleY = f8 * 1.0F + f7; - this.spiderLeg4.rotateAngleY = -f8 * 1.0F - f7; - this.spiderLeg5.rotateAngleY = -f8 * 1.0F + f7; - this.spiderLeg6.rotateAngleY = f8 * 1.0F - f7; - this.spiderLeg7.rotateAngleY = -f8 * 2.0F + f7; - this.spiderLeg8.rotateAngleY = f8 * 2.0F - f7; - float f9 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + 0.0F) * 0.4F) * p_78087_2_; - float f10 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * p_78087_2_; - float f11 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + ((float) Math.PI / 2F)) * 0.4F) * p_78087_2_; - float f12 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * p_78087_2_; - float f13 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + 0.0F) * 0.4F) * p_78087_2_; - float f14 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + (float) Math.PI) * 0.4F) * p_78087_2_; - float f15 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + ((float) Math.PI / 2F)) * 0.4F) * p_78087_2_; - float f16 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * p_78087_2_; - this.spiderLeg1.rotateAngleY += f9; - this.spiderLeg2.rotateAngleY += -f9; - this.spiderLeg3.rotateAngleY += f10; - this.spiderLeg4.rotateAngleY += -f10; - this.spiderLeg5.rotateAngleY += f11; - this.spiderLeg6.rotateAngleY += -f11; - this.spiderLeg7.rotateAngleY += f12; - this.spiderLeg8.rotateAngleY += -f12; - this.spiderLeg1.rotateAngleZ += f13; - this.spiderLeg2.rotateAngleZ += -f13; - this.spiderLeg3.rotateAngleZ += f14; - this.spiderLeg4.rotateAngleZ += -f14; - this.spiderLeg5.rotateAngleZ += f15; - this.spiderLeg6.rotateAngleZ += -f15; - this.spiderLeg7.rotateAngleZ += f16; - this.spiderLeg8.rotateAngleZ += -f16; - } - -}
\ No newline at end of file + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used + * for animating the movement of arms and legs, where par1 represents the + * time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + this.spiderHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.spiderHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); + float f6 = ((float) Math.PI / 4F); + this.spiderLeg1.rotateAngleZ = -f6; + this.spiderLeg2.rotateAngleZ = f6; + this.spiderLeg3.rotateAngleZ = -f6 * 0.74F; + this.spiderLeg4.rotateAngleZ = f6 * 0.74F; + this.spiderLeg5.rotateAngleZ = -f6 * 0.74F; + this.spiderLeg6.rotateAngleZ = f6 * 0.74F; + this.spiderLeg7.rotateAngleZ = -f6; + this.spiderLeg8.rotateAngleZ = f6; + float f7 = -0.0F; + float f8 = 0.3926991F; + this.spiderLeg1.rotateAngleY = f8 * 2.0F + f7; + this.spiderLeg2.rotateAngleY = -f8 * 2.0F - f7; + this.spiderLeg3.rotateAngleY = f8 * 1.0F + f7; + this.spiderLeg4.rotateAngleY = -f8 * 1.0F - f7; + this.spiderLeg5.rotateAngleY = -f8 * 1.0F + f7; + this.spiderLeg6.rotateAngleY = f8 * 1.0F - f7; + this.spiderLeg7.rotateAngleY = -f8 * 2.0F + f7; + this.spiderLeg8.rotateAngleY = f8 * 2.0F - f7; + float f9 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + 0.0F) * 0.4F) * p_78087_2_; + float f10 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * p_78087_2_; + float f11 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + ((float) Math.PI / 2F)) * 0.4F) * p_78087_2_; + float f12 = -(MathHelper.cos(p_78087_1_ * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * p_78087_2_; + float f13 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + 0.0F) * 0.4F) * p_78087_2_; + float f14 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + (float) Math.PI) * 0.4F) * p_78087_2_; + float f15 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + ((float) Math.PI / 2F)) * 0.4F) * p_78087_2_; + float f16 = Math.abs(MathHelper.sin(p_78087_1_ * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * p_78087_2_; + this.spiderLeg1.rotateAngleY += f9; + this.spiderLeg2.rotateAngleY += -f9; + this.spiderLeg3.rotateAngleY += f10; + this.spiderLeg4.rotateAngleY += -f10; + this.spiderLeg5.rotateAngleY += f11; + this.spiderLeg6.rotateAngleY += -f11; + this.spiderLeg7.rotateAngleY += f12; + this.spiderLeg8.rotateAngleY += -f12; + this.spiderLeg1.rotateAngleZ += f13; + this.spiderLeg2.rotateAngleZ += -f13; + this.spiderLeg3.rotateAngleZ += f14; + this.spiderLeg4.rotateAngleZ += -f14; + this.spiderLeg5.rotateAngleZ += f15; + this.spiderLeg6.rotateAngleZ += -f15; + this.spiderLeg7.rotateAngleZ += f16; + this.spiderLeg8.rotateAngleZ += -f16; + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/model/ModelBoar.java b/src/main/java/gtPlusPlus/australia/entity/model/ModelBoar.java index 7d858e39f0..3d1a5b5ef7 100644 --- a/src/main/java/gtPlusPlus/australia/entity/model/ModelBoar.java +++ b/src/main/java/gtPlusPlus/australia/entity/model/ModelBoar.java @@ -6,15 +6,14 @@ import net.minecraft.client.model.ModelQuadruped; @SideOnly(Side.CLIENT) public class ModelBoar extends ModelQuadruped { - - public ModelBoar() { - this(0.0F); - } - public ModelBoar(float p_i1151_1_) { - super(6, p_i1151_1_); - this.head.setTextureOffset(16, 16).addBox(-2.0F, 0.0F, -9.0F, 4, 3, 1, p_i1151_1_); - this.field_78145_g = 4.0F; - } - -}
\ No newline at end of file + public ModelBoar() { + this(0.0F); + } + + public ModelBoar(float p_i1151_1_) { + super(6, p_i1151_1_); + this.head.setTextureOffset(16, 16).addBox(-2.0F, 0.0F, -9.0F, 4, 3, 1, p_i1151_1_); + this.field_78145_g = 4.0F; + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/model/ModelDingo.java b/src/main/java/gtPlusPlus/australia/entity/model/ModelDingo.java index 2999cdf2dd..51bce24794 100644 --- a/src/main/java/gtPlusPlus/australia/entity/model/ModelDingo.java +++ b/src/main/java/gtPlusPlus/australia/entity/model/ModelDingo.java @@ -12,157 +12,168 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class ModelDingo extends ModelBase { - - /** main box for the dingo head */ - public ModelRenderer dingoHeadMain; - /** The dingo's body */ - public ModelRenderer dingoBody; - /** dingo'se first leg */ - public ModelRenderer dingoLeg1; - /** dingo's second leg */ - public ModelRenderer dingoLeg2; - /** dingo's third leg */ - public ModelRenderer dingoLeg3; - /** dingo's fourth leg */ - public ModelRenderer dingoLeg4; - /** The dingo's tail */ - ModelRenderer dingoTail; - /** The dingo's mane */ - ModelRenderer dingoMane; - public ModelDingo() { - float f = 0.0F; - float f1 = 13.5F; - this.dingoHeadMain = new ModelRenderer(this, 0, 0); - this.dingoHeadMain.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, f); - this.dingoHeadMain.setRotationPoint(-1.0F, f1, -7.0F); - this.dingoBody = new ModelRenderer(this, 18, 14); - this.dingoBody.addBox(-4.0F, -2.0F, -3.0F, 6, 9, 6, f); - this.dingoBody.setRotationPoint(0.0F, 14.0F, 2.0F); - this.dingoMane = new ModelRenderer(this, 21, 0); - this.dingoMane.addBox(-4.0F, -3.0F, -3.0F, 8, 6, 7, f); - this.dingoMane.setRotationPoint(-1.0F, 14.0F, 2.0F); - this.dingoLeg1 = new ModelRenderer(this, 0, 18); - this.dingoLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); - this.dingoLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); - this.dingoLeg2 = new ModelRenderer(this, 0, 18); - this.dingoLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); - this.dingoLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); - this.dingoLeg3 = new ModelRenderer(this, 0, 18); - this.dingoLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); - this.dingoLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); - this.dingoLeg4 = new ModelRenderer(this, 0, 18); - this.dingoLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); - this.dingoLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); - this.dingoTail = new ModelRenderer(this, 9, 18); - this.dingoTail.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); - this.dingoTail.setRotationPoint(-1.0F, 12.0F, 8.0F); - this.dingoHeadMain.setTextureOffset(16, 14).addBox(-3.0F, -5.0F, 0.0F, 2, 2, 1, f); - this.dingoHeadMain.setTextureOffset(16, 14).addBox(1.0F, -5.0F, 0.0F, 2, 2, 1, f); - this.dingoHeadMain.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 3, 4, f); - } + /** main box for the dingo head */ + public ModelRenderer dingoHeadMain; + /** The dingo's body */ + public ModelRenderer dingoBody; + /** dingo'se first leg */ + public ModelRenderer dingoLeg1; + /** dingo's second leg */ + public ModelRenderer dingoLeg2; + /** dingo's third leg */ + public ModelRenderer dingoLeg3; + /** dingo's fourth leg */ + public ModelRenderer dingoLeg4; + /** The dingo's tail */ + ModelRenderer dingoTail; + /** The dingo's mane */ + ModelRenderer dingoMane; - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, - float p_78088_6_, float p_78088_7_) { - super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_); - this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + public ModelDingo() { + float f = 0.0F; + float f1 = 13.5F; + this.dingoHeadMain = new ModelRenderer(this, 0, 0); + this.dingoHeadMain.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, f); + this.dingoHeadMain.setRotationPoint(-1.0F, f1, -7.0F); + this.dingoBody = new ModelRenderer(this, 18, 14); + this.dingoBody.addBox(-4.0F, -2.0F, -3.0F, 6, 9, 6, f); + this.dingoBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.dingoMane = new ModelRenderer(this, 21, 0); + this.dingoMane.addBox(-4.0F, -3.0F, -3.0F, 8, 6, 7, f); + this.dingoMane.setRotationPoint(-1.0F, 14.0F, 2.0F); + this.dingoLeg1 = new ModelRenderer(this, 0, 18); + this.dingoLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.dingoLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.dingoLeg2 = new ModelRenderer(this, 0, 18); + this.dingoLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.dingoLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.dingoLeg3 = new ModelRenderer(this, 0, 18); + this.dingoLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.dingoLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.dingoLeg4 = new ModelRenderer(this, 0, 18); + this.dingoLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.dingoLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.dingoTail = new ModelRenderer(this, 9, 18); + this.dingoTail.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.dingoTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.dingoHeadMain.setTextureOffset(16, 14).addBox(-3.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.dingoHeadMain.setTextureOffset(16, 14).addBox(1.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.dingoHeadMain.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 3, 4, f); + } - if (this.isChild) { - float f6 = 2.0F; - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 5.0F * p_78088_7_, 2.0F * p_78088_7_); - this.dingoHeadMain.renderWithRotation(p_78088_7_); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); - GL11.glTranslatef(0.0F, 24.0F * p_78088_7_, 0.0F); - this.dingoBody.render(p_78088_7_); - this.dingoLeg1.render(p_78088_7_); - this.dingoLeg2.render(p_78088_7_); - this.dingoLeg3.render(p_78088_7_); - this.dingoLeg4.render(p_78088_7_); - this.dingoTail.renderWithRotation(p_78088_7_); - this.dingoMane.render(p_78088_7_); - GL11.glPopMatrix(); - } else { - this.dingoHeadMain.renderWithRotation(p_78088_7_); - this.dingoBody.render(p_78088_7_); - this.dingoLeg1.render(p_78088_7_); - this.dingoLeg2.render(p_78088_7_); - this.dingoLeg3.render(p_78088_7_); - this.dingoLeg4.render(p_78088_7_); - this.dingoTail.renderWithRotation(p_78088_7_); - this.dingoMane.render(p_78088_7_); - } - } + /** + * Sets the models various rotation angles then renders the model. + */ + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { + super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_); + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - /** - * Used for easily adding entity-dependent animations. The second and third - * float params here are the same second and third as in the setRotationAngles - * method. - */ - public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) { - EntityWolf entitydingo = (EntityWolf) p_78086_1_; + if (this.isChild) { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 5.0F * p_78088_7_, 2.0F * p_78088_7_); + this.dingoHeadMain.renderWithRotation(p_78088_7_); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * p_78088_7_, 0.0F); + this.dingoBody.render(p_78088_7_); + this.dingoLeg1.render(p_78088_7_); + this.dingoLeg2.render(p_78088_7_); + this.dingoLeg3.render(p_78088_7_); + this.dingoLeg4.render(p_78088_7_); + this.dingoTail.renderWithRotation(p_78088_7_); + this.dingoMane.render(p_78088_7_); + GL11.glPopMatrix(); + } else { + this.dingoHeadMain.renderWithRotation(p_78088_7_); + this.dingoBody.render(p_78088_7_); + this.dingoLeg1.render(p_78088_7_); + this.dingoLeg2.render(p_78088_7_); + this.dingoLeg3.render(p_78088_7_); + this.dingoLeg4.render(p_78088_7_); + this.dingoTail.renderWithRotation(p_78088_7_); + this.dingoMane.render(p_78088_7_); + } + } - if (entitydingo.isAngry()) { - this.dingoTail.rotateAngleY = 0.0F; - } else { - this.dingoTail.rotateAngleY = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; - } + /** + * Used for easily adding entity-dependent animations. The second and third + * float params here are the same second and third as in the setRotationAngles + * method. + */ + public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) { + EntityWolf entitydingo = (EntityWolf) p_78086_1_; - if (entitydingo.isSitting()) { - this.dingoMane.setRotationPoint(-1.0F, 16.0F, -3.0F); - this.dingoMane.rotateAngleX = ((float) Math.PI * 2F / 5F); - this.dingoMane.rotateAngleY = 0.0F; - this.dingoBody.setRotationPoint(0.0F, 18.0F, 0.0F); - this.dingoBody.rotateAngleX = ((float) Math.PI / 4F); - this.dingoTail.setRotationPoint(-1.0F, 21.0F, 6.0F); - this.dingoLeg1.setRotationPoint(-2.5F, 22.0F, 2.0F); - this.dingoLeg1.rotateAngleX = ((float) Math.PI * 3F / 2F); - this.dingoLeg2.setRotationPoint(0.5F, 22.0F, 2.0F); - this.dingoLeg2.rotateAngleX = ((float) Math.PI * 3F / 2F); - this.dingoLeg3.rotateAngleX = 5.811947F; - this.dingoLeg3.setRotationPoint(-2.49F, 17.0F, -4.0F); - this.dingoLeg4.rotateAngleX = 5.811947F; - this.dingoLeg4.setRotationPoint(0.51F, 17.0F, -4.0F); - } else { - this.dingoBody.setRotationPoint(0.0F, 14.0F, 2.0F); - this.dingoBody.rotateAngleX = ((float) Math.PI / 2F); - this.dingoMane.setRotationPoint(-1.0F, 14.0F, -3.0F); - this.dingoMane.rotateAngleX = this.dingoBody.rotateAngleX; - this.dingoTail.setRotationPoint(-1.0F, 12.0F, 8.0F); - this.dingoLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); - this.dingoLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); - this.dingoLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); - this.dingoLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); - this.dingoLeg1.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; - this.dingoLeg2.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float) Math.PI) * 1.4F * p_78086_3_; - this.dingoLeg3.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float) Math.PI) * 1.4F * p_78086_3_; - this.dingoLeg4.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; - } + if (entitydingo.isAngry()) { + this.dingoTail.rotateAngleY = 0.0F; + } else { + this.dingoTail.rotateAngleY = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + } - this.dingoHeadMain.rotateAngleZ = entitydingo.getInterestedAngle(p_78086_4_) - + entitydingo.getShakeAngle(p_78086_4_, 0.0F); - this.dingoMane.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.08F); - this.dingoBody.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.16F); - this.dingoTail.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.2F); - } + if (entitydingo.isSitting()) { + this.dingoMane.setRotationPoint(-1.0F, 16.0F, -3.0F); + this.dingoMane.rotateAngleX = ((float) Math.PI * 2F / 5F); + this.dingoMane.rotateAngleY = 0.0F; + this.dingoBody.setRotationPoint(0.0F, 18.0F, 0.0F); + this.dingoBody.rotateAngleX = ((float) Math.PI / 4F); + this.dingoTail.setRotationPoint(-1.0F, 21.0F, 6.0F); + this.dingoLeg1.setRotationPoint(-2.5F, 22.0F, 2.0F); + this.dingoLeg1.rotateAngleX = ((float) Math.PI * 3F / 2F); + this.dingoLeg2.setRotationPoint(0.5F, 22.0F, 2.0F); + this.dingoLeg2.rotateAngleX = ((float) Math.PI * 3F / 2F); + this.dingoLeg3.rotateAngleX = 5.811947F; + this.dingoLeg3.setRotationPoint(-2.49F, 17.0F, -4.0F); + this.dingoLeg4.rotateAngleX = 5.811947F; + this.dingoLeg4.setRotationPoint(0.51F, 17.0F, -4.0F); + } else { + this.dingoBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.dingoBody.rotateAngleX = ((float) Math.PI / 2F); + this.dingoMane.setRotationPoint(-1.0F, 14.0F, -3.0F); + this.dingoMane.rotateAngleX = this.dingoBody.rotateAngleX; + this.dingoTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.dingoLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.dingoLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.dingoLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.dingoLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.dingoLeg1.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + this.dingoLeg2.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float) Math.PI) * 1.4F * p_78086_3_; + this.dingoLeg3.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float) Math.PI) * 1.4F * p_78086_3_; + this.dingoLeg4.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + } - /** - * Sets the model's various rotation angles. For bipeds, par1 and par2 are used - * for animating the movement of arms and legs, where par1 represents the - * time(so that arms and legs swing back and forth) and par2 represents how - * "far" arms and legs can swing at most. - */ - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, - float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { - super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); - this.dingoHeadMain.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); - this.dingoHeadMain.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); - this.dingoTail.rotateAngleX = p_78087_3_; - } - -}
\ No newline at end of file + this.dingoHeadMain.rotateAngleZ = + entitydingo.getInterestedAngle(p_78086_4_) + entitydingo.getShakeAngle(p_78086_4_, 0.0F); + this.dingoMane.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.08F); + this.dingoBody.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.16F); + this.dingoTail.rotateAngleZ = entitydingo.getShakeAngle(p_78086_4_, -0.2F); + } + + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used + * for animating the movement of arms and legs, where par1 represents the + * time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); + this.dingoHeadMain.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); + this.dingoHeadMain.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.dingoTail.rotateAngleX = p_78087_3_; + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/model/ModelOctopus.java b/src/main/java/gtPlusPlus/australia/entity/model/ModelOctopus.java index f820d0ad85..aaec9f8dc4 100644 --- a/src/main/java/gtPlusPlus/australia/entity/model/ModelOctopus.java +++ b/src/main/java/gtPlusPlus/australia/entity/model/ModelOctopus.java @@ -8,60 +8,71 @@ import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) public class ModelOctopus extends ModelBase { - - /** The squid's body */ - ModelRenderer octopusBody; - /** The squid's tentacles */ - ModelRenderer[] octoTentacles = new ModelRenderer[8]; - public ModelOctopus() { - byte b0 = -16; - this.octopusBody = new ModelRenderer(this, 0, 0); - this.octopusBody.addBox(-6.0F, -8.0F, -6.0F, 12, 16, 12); - this.octopusBody.rotationPointY += (float) (24 + b0); + /** The squid's body */ + ModelRenderer octopusBody; + /** The squid's tentacles */ + ModelRenderer[] octoTentacles = new ModelRenderer[8]; - for (int i = 0; i < this.octoTentacles.length; ++i) { - this.octoTentacles[i] = new ModelRenderer(this, 48, 0); - double d0 = (double) i * Math.PI * 2.0D / (double) this.octoTentacles.length; - float f = (float) Math.cos(d0) * 5.0F; - float f1 = (float) Math.sin(d0) * 5.0F; - this.octoTentacles[i].addBox(-1.0F, 0.0F, -1.0F, 2, 18, 2); - this.octoTentacles[i].rotationPointX = f; - this.octoTentacles[i].rotationPointZ = f1; - this.octoTentacles[i].rotationPointY = (float) (31 + b0); - d0 = (double) i * Math.PI * -2.0D / (double) this.octoTentacles.length + (Math.PI / 2D); - this.octoTentacles[i].rotateAngleY = (float) d0; - } - } + public ModelOctopus() { + byte b0 = -16; + this.octopusBody = new ModelRenderer(this, 0, 0); + this.octopusBody.addBox(-6.0F, -8.0F, -6.0F, 12, 16, 12); + this.octopusBody.rotationPointY += (float) (24 + b0); - /** - * Sets the model's various rotation angles. For bipeds, par1 and par2 are used - * for animating the movement of arms and legs, where par1 represents the - * time(so that arms and legs swing back and forth) and par2 represents how - * "far" arms and legs can swing at most. - */ - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, - float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { - ModelRenderer[] amodelrenderer = this.octoTentacles; - int i = amodelrenderer.length; + for (int i = 0; i < this.octoTentacles.length; ++i) { + this.octoTentacles[i] = new ModelRenderer(this, 48, 0); + double d0 = (double) i * Math.PI * 2.0D / (double) this.octoTentacles.length; + float f = (float) Math.cos(d0) * 5.0F; + float f1 = (float) Math.sin(d0) * 5.0F; + this.octoTentacles[i].addBox(-1.0F, 0.0F, -1.0F, 2, 18, 2); + this.octoTentacles[i].rotationPointX = f; + this.octoTentacles[i].rotationPointZ = f1; + this.octoTentacles[i].rotationPointY = (float) (31 + b0); + d0 = (double) i * Math.PI * -2.0D / (double) this.octoTentacles.length + (Math.PI / 2D); + this.octoTentacles[i].rotateAngleY = (float) d0; + } + } - for (int j = 0; j < i; ++j) { - ModelRenderer modelrenderer = amodelrenderer[j]; - modelrenderer.rotateAngleX = p_78087_3_; - } - } + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used + * for animating the movement of arms and legs, where par1 represents the + * time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + ModelRenderer[] amodelrenderer = this.octoTentacles; + int i = amodelrenderer.length; - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, - float p_78088_6_, float p_78088_7_) { - this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - this.octopusBody.render(p_78088_7_); + for (int j = 0; j < i; ++j) { + ModelRenderer modelrenderer = amodelrenderer[j]; + modelrenderer.rotateAngleX = p_78087_3_; + } + } - for (int i = 0; i < this.octoTentacles.length; ++i) { - this.octoTentacles[i].render(p_78088_7_); - } - } - -}
\ No newline at end of file + /** + * Sets the models various rotation angles then renders the model. + */ + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + this.octopusBody.render(p_78088_7_); + + for (int i = 0; i < this.octoTentacles.length; ++i) { + this.octoTentacles[i].render(p_78088_7_); + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/render/RenderAustralianSpider.java b/src/main/java/gtPlusPlus/australia/entity/render/RenderAustralianSpider.java index af432e04b9..01b4b8ac4b 100644 --- a/src/main/java/gtPlusPlus/australia/entity/render/RenderAustralianSpider.java +++ b/src/main/java/gtPlusPlus/australia/entity/render/RenderAustralianSpider.java @@ -15,70 +15,70 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderAustralianSpider extends RenderLiving { - private static final ResourceLocation spiderEyesTextures = new ResourceLocation("textures/entity/spider_eyes.png"); - private static final ResourceLocation spiderTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/australia/bush_spider.png"); + private static final ResourceLocation spiderEyesTextures = new ResourceLocation("textures/entity/spider_eyes.png"); + private static final ResourceLocation spiderTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/bush_spider.png"); - public RenderAustralianSpider() { - super(new ModelAustralianSpider(), 1.0F); - this.setRenderPassModel(new ModelAustralianSpider()); - } + public RenderAustralianSpider() { + super(new ModelAustralianSpider(), 1.0F); + this.setRenderPassModel(new ModelAustralianSpider()); + } - protected float getDeathMaxRotation(EntityAustralianSpiderBase p_77037_1_) { - return 180.0F; - } + protected float getDeathMaxRotation(EntityAustralianSpiderBase p_77037_1_) { + return 180.0F; + } - /** - * Queries whether should render the specified pass or not. - */ - protected int shouldRenderPass(EntityAustralianSpiderBase p_77032_1_, int p_77032_2_, float p_77032_3_) { - if (p_77032_2_ != 0) { - return -1; - } else { - this.bindTexture(spiderEyesTextures); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass(EntityAustralianSpiderBase p_77032_1_, int p_77032_2_, float p_77032_3_) { + if (p_77032_2_ != 0) { + return -1; + } else { + this.bindTexture(spiderEyesTextures); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - if (p_77032_1_.isInvisible()) { - GL11.glDepthMask(false); - } else { - GL11.glDepthMask(true); - } + if (p_77032_1_.isInvisible()) { + GL11.glDepthMask(false); + } else { + GL11.glDepthMask(true); + } - char c0 = 61680; - int j = c0 % 65536; - int k = c0 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - return 1; - } - } + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + return 1; + } + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityAustralianSpiderBase p_110775_1_) { - return spiderTextures; - } + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityAustralianSpiderBase p_110775_1_) { + return spiderTextures; + } - protected float getDeathMaxRotation(EntityLivingBase p_77037_1_) { - return this.getDeathMaxRotation((EntityAustralianSpiderBase) p_77037_1_); - } + protected float getDeathMaxRotation(EntityLivingBase p_77037_1_) { + return this.getDeathMaxRotation((EntityAustralianSpiderBase) p_77037_1_); + } - /** - * Queries whether should render the specified pass or not. - */ - protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { - return this.shouldRenderPass((EntityAustralianSpiderBase) p_77032_1_, p_77032_2_, p_77032_3_); - } + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { + return this.shouldRenderPass((EntityAustralianSpiderBase) p_77032_1_, p_77032_2_, p_77032_3_); + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityAustralianSpiderBase) p_110775_1_); - } - -}
\ No newline at end of file + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityAustralianSpiderBase) p_110775_1_); + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/render/RenderBoar.java b/src/main/java/gtPlusPlus/australia/entity/render/RenderBoar.java index cc4bfa8906..c3a730492c 100644 --- a/src/main/java/gtPlusPlus/australia/entity/render/RenderBoar.java +++ b/src/main/java/gtPlusPlus/australia/entity/render/RenderBoar.java @@ -11,13 +11,13 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) -public class RenderBoar extends RenderLiving -{ - private static final ResourceLocation saddledBoarTextures = new ResourceLocation("textures/entity/boar/boar_saddle.png"); - private static final ResourceLocation boarTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/australia/boar.png"); +public class RenderBoar extends RenderLiving { + private static final ResourceLocation saddledBoarTextures = + new ResourceLocation("textures/entity/boar/boar_saddle.png"); + private static final ResourceLocation boarTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/boar.png"); - public RenderBoar(ModelBase p_i1265_1_, ModelBase p_i1265_2_, float p_i1265_3_) - { + public RenderBoar(ModelBase p_i1265_1_, ModelBase p_i1265_2_, float p_i1265_3_) { super(p_i1265_1_, p_i1265_3_); this.setRenderPassModel(p_i1265_2_); } @@ -25,15 +25,11 @@ public class RenderBoar extends RenderLiving /** * Queries whether should render the specified pass or not. */ - protected int shouldRenderPass(EntityBoar p_77032_1_, int p_77032_2_, float p_77032_3_) - { - if (p_77032_2_ == 0 && p_77032_1_.getSaddled()) - { + protected int shouldRenderPass(EntityBoar p_77032_1_, int p_77032_2_, float p_77032_3_) { + if (p_77032_2_ == 0 && p_77032_1_.getSaddled()) { this.bindTexture(saddledBoarTextures); return 1; - } - else - { + } else { return -1; } } @@ -41,24 +37,21 @@ public class RenderBoar extends RenderLiving /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntityBoar p_110775_1_) - { + protected ResourceLocation getEntityTexture(EntityBoar p_110775_1_) { return boarTextures; } /** * Queries whether should render the specified pass or not. */ - protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) - { - return this.shouldRenderPass((EntityBoar)p_77032_1_, p_77032_2_, p_77032_3_); + protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { + return this.shouldRenderPass((EntityBoar) p_77032_1_, p_77032_2_, p_77032_3_); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(Entity p_110775_1_) - { - return this.getEntityTexture((EntityBoar)p_110775_1_); + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityBoar) p_110775_1_); } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/australia/entity/render/RenderDingo.java b/src/main/java/gtPlusPlus/australia/entity/render/RenderDingo.java index 8bbf0392cd..37511355e6 100644 --- a/src/main/java/gtPlusPlus/australia/entity/render/RenderDingo.java +++ b/src/main/java/gtPlusPlus/australia/entity/render/RenderDingo.java @@ -15,76 +15,78 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderDingo extends RenderLiving { - private static final ResourceLocation dingoTextures = new ResourceLocation( - CORE.MODID + ":" + "textures/entity/australia/dingo/dingo.png"); - private static final ResourceLocation tamedDingoTextures = new ResourceLocation( - CORE.MODID + ":" + "textures/entity/australia/dingo/wdingo_tame.png"); - private static final ResourceLocation anrgyDingoTextures = new ResourceLocation( - CORE.MODID + ":" + "textures/entity/australia/dingo/dingo_angry.png"); - private static final ResourceLocation dingoCollarTextures = new ResourceLocation( - CORE.MODID + ":" + "textures/entity/australia/wdingoolf/dingo_collar.png"); + private static final ResourceLocation dingoTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/dingo/dingo.png"); + private static final ResourceLocation tamedDingoTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/dingo/wdingo_tame.png"); + private static final ResourceLocation anrgyDingoTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/dingo/dingo_angry.png"); + private static final ResourceLocation dingoCollarTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/wdingoolf/dingo_collar.png"); - public RenderDingo(ModelBase p_i1269_1_, ModelBase p_i1269_2_, float p_i1269_3_) { - super(p_i1269_1_, p_i1269_3_); - this.setRenderPassModel(p_i1269_2_); - } + public RenderDingo(ModelBase p_i1269_1_, ModelBase p_i1269_2_, float p_i1269_3_) { + super(p_i1269_1_, p_i1269_3_); + this.setRenderPassModel(p_i1269_2_); + } - /** - * Defines what float the third param in setRotationAngles of ModelBase is - */ - protected float handleRotationFloat(EntityDingo p_77044_1_, float p_77044_2_) { - return p_77044_1_.getTailRotation(); - } + /** + * Defines what float the third param in setRotationAngles of ModelBase is + */ + protected float handleRotationFloat(EntityDingo p_77044_1_, float p_77044_2_) { + return p_77044_1_.getTailRotation(); + } - /** - * Queries whether should render the specified pass or not. - */ - protected int shouldRenderPass(EntityDingo p_77032_1_, int p_77032_2_, float p_77032_3_) { - if (p_77032_2_ == 0 && p_77032_1_.getWolfShaking()) { - float f1 = p_77032_1_.getBrightness(p_77032_3_) * p_77032_1_.getShadingWhileShaking(p_77032_3_); - this.bindTexture(dingoTextures); - GL11.glColor3f(f1, f1, f1); - return 1; - } else if (p_77032_2_ == 1 && p_77032_1_.isTamed()) { - this.bindTexture(dingoCollarTextures); - int j = p_77032_1_.getCollarColor(); - GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1], - EntitySheep.fleeceColorTable[j][2]); - return 1; - } else { - return -1; - } - } + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass(EntityDingo p_77032_1_, int p_77032_2_, float p_77032_3_) { + if (p_77032_2_ == 0 && p_77032_1_.getWolfShaking()) { + float f1 = p_77032_1_.getBrightness(p_77032_3_) * p_77032_1_.getShadingWhileShaking(p_77032_3_); + this.bindTexture(dingoTextures); + GL11.glColor3f(f1, f1, f1); + return 1; + } else if (p_77032_2_ == 1 && p_77032_1_.isTamed()) { + this.bindTexture(dingoCollarTextures); + int j = p_77032_1_.getCollarColor(); + GL11.glColor3f( + EntitySheep.fleeceColorTable[j][0], + EntitySheep.fleeceColorTable[j][1], + EntitySheep.fleeceColorTable[j][2]); + return 1; + } else { + return -1; + } + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityDingo p_110775_1_) { - return p_110775_1_.isTamed() ? tamedDingoTextures - : (p_110775_1_.isAngry() ? anrgyDingoTextures : dingoTextures); - } + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityDingo p_110775_1_) { + return p_110775_1_.isTamed() + ? tamedDingoTextures + : (p_110775_1_.isAngry() ? anrgyDingoTextures : dingoTextures); + } - /** - * Queries whether should render the specified pass or not. - */ - protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { - return this.shouldRenderPass((EntityDingo) p_77032_1_, p_77032_2_, p_77032_3_); - } + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { + return this.shouldRenderPass((EntityDingo) p_77032_1_, p_77032_2_, p_77032_3_); + } - /** - * Defines what float the third param in setRotationAngles of ModelBase is - */ - protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_) { - return this.handleRotationFloat((EntityDingo) p_77044_1_, p_77044_2_); - } + /** + * Defines what float the third param in setRotationAngles of ModelBase is + */ + protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_) { + return this.handleRotationFloat((EntityDingo) p_77044_1_, p_77044_2_); + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityDingo) p_110775_1_); - } - -}
\ No newline at end of file + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityDingo) p_110775_1_); + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/render/RenderOctopus.java b/src/main/java/gtPlusPlus/australia/entity/render/RenderOctopus.java index 592ef9391a..89888140f2 100644 --- a/src/main/java/gtPlusPlus/australia/entity/render/RenderOctopus.java +++ b/src/main/java/gtPlusPlus/australia/entity/render/RenderOctopus.java @@ -14,107 +14,127 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderOctopus extends RenderLiving { - - private static final ResourceLocation octopusTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/australia/octopus.png"); - public RenderOctopus(ModelBase p_i1268_1_, float p_i1268_2_) { - super(p_i1268_1_, p_i1268_2_); - } + private static final ResourceLocation octopusTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/australia/octopus.png"); - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker function - * which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void - * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). - * But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(EntityOctopus p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, - float p_76986_8_, float p_76986_9_) { - super.doRender((EntityLiving) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } + public RenderOctopus(ModelBase p_i1268_1_, float p_i1268_2_) { + super(p_i1268_1_, p_i1268_2_); + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityOctopus p_110775_1_) { - return octopusTextures; - } + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker function + * which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void + * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). + * But JAD is pre 1.5 so doesn't do that. + */ + public void doRender( + EntityOctopus p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + super.doRender((EntityLiving) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } - protected void rotateCorpse(EntityOctopus p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { - float f3 = p_77043_1_.prevSquidPitch + (p_77043_1_.octopusPitch - p_77043_1_.prevSquidPitch) * p_77043_4_; - float f4 = p_77043_1_.prevSquidYaw + (p_77043_1_.octopusYaw - p_77043_1_.prevSquidYaw) * p_77043_4_; - GL11.glTranslatef(0.0F, 0.5F, 0.0F); - GL11.glRotatef(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(f3, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f4, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.2F, 0.0F); - } + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityOctopus p_110775_1_) { + return octopusTextures; + } - /** - * Defines what float the third param in setRotationAngles of ModelBase is - */ - protected float handleRotationFloat(EntityOctopus p_77044_1_, float p_77044_2_) { - return p_77044_1_.lastTentacleAngle + (p_77044_1_.tentacleAngle - p_77044_1_.lastTentacleAngle) * p_77044_2_; - } + protected void rotateCorpse(EntityOctopus p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + float f3 = p_77043_1_.prevSquidPitch + (p_77043_1_.octopusPitch - p_77043_1_.prevSquidPitch) * p_77043_4_; + float f4 = p_77043_1_.prevSquidYaw + (p_77043_1_.octopusYaw - p_77043_1_.prevSquidYaw) * p_77043_4_; + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + GL11.glRotatef(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f3, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f4, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.2F, 0.0F); + } - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker function - * which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void - * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). - * But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, - float p_76986_8_, float p_76986_9_) { - this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } + /** + * Defines what float the third param in setRotationAngles of ModelBase is + */ + protected float handleRotationFloat(EntityOctopus p_77044_1_, float p_77044_2_) { + return p_77044_1_.lastTentacleAngle + (p_77044_1_.tentacleAngle - p_77044_1_.lastTentacleAngle) * p_77044_2_; + } - /** - * Defines what float the third param in setRotationAngles of ModelBase is - */ - protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_) { - return this.handleRotationFloat((EntityOctopus) p_77044_1_, p_77044_2_); - } + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker function + * which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void + * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). + * But JAD is pre 1.5 so doesn't do that. + */ + public void doRender( + EntityLiving p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } - protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { - this.rotateCorpse((EntityOctopus) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); - } + /** + * Defines what float the third param in setRotationAngles of ModelBase is + */ + protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_) { + return this.handleRotationFloat((EntityOctopus) p_77044_1_, p_77044_2_); + } - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker function - * which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void - * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). - * But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, - float p_76986_8_, float p_76986_9_) { - this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } + protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + this.rotateCorpse((EntityOctopus) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless - * you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityOctopus) p_110775_1_); - } + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker function + * which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void + * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). + * But JAD is pre 1.5 so doesn't do that. + */ + public void doRender( + EntityLivingBase p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker function - * which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void - * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). - * But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, - float p_76986_9_) { - this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } - -}
\ No newline at end of file + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless + * you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityOctopus) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker function + * which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void + * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). + * But JAD is pre 1.5 so doesn't do that. + */ + public void doRender( + Entity p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + this.doRender((EntityOctopus) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/type/EntityAustralianSpiderBase.java b/src/main/java/gtPlusPlus/australia/entity/type/EntityAustralianSpiderBase.java index 5aa78203a3..9f4963e2fc 100644 --- a/src/main/java/gtPlusPlus/australia/entity/type/EntityAustralianSpiderBase.java +++ b/src/main/java/gtPlusPlus/australia/entity/type/EntityAustralianSpiderBase.java @@ -11,31 +11,31 @@ import net.minecraft.world.World; public class EntityAustralianSpiderBase extends EntitySpider { - public EntityAustralianSpiderBase(World p_i1732_1_) { - super(p_i1732_1_); - this.setSize(0.7F, 0.5F); - } + public EntityAustralianSpiderBase(World p_i1732_1_) { + super(p_i1732_1_); + this.setSize(0.7F, 0.5F); + } - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(12.0D); - } + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(12.0D); + } - public boolean attackEntityAsMob(Entity p_70652_1_) { - if (super.attackEntityAsMob(p_70652_1_)) { - if (p_70652_1_ instanceof EntityLivingBase) { - byte b0 = 45; - if (b0 > 0) { - ((EntityLivingBase) p_70652_1_).addPotionEffect(new PotionEffect(Potion.poison.id, b0 * 20, 0)); - } - } - return true; - } else { - return false; - } - } + public boolean attackEntityAsMob(Entity p_70652_1_) { + if (super.attackEntityAsMob(p_70652_1_)) { + if (p_70652_1_ instanceof EntityLivingBase) { + byte b0 = 45; + if (b0 > 0) { + ((EntityLivingBase) p_70652_1_).addPotionEffect(new PotionEffect(Potion.poison.id, b0 * 20, 0)); + } + } + return true; + } else { + return false; + } + } - public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { - return p_110161_1_; - } -}
\ No newline at end of file + public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { + return p_110161_1_; + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/type/EntityBoar.java b/src/main/java/gtPlusPlus/australia/entity/type/EntityBoar.java index 871b1a5356..fddde70116 100644 --- a/src/main/java/gtPlusPlus/australia/entity/type/EntityBoar.java +++ b/src/main/java/gtPlusPlus/australia/entity/type/EntityBoar.java @@ -7,7 +7,6 @@ import net.minecraft.entity.ai.EntityAIControlledByPlayer; import net.minecraft.entity.ai.EntityAIFollowParent; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; -import net.minecraft.entity.ai.EntityAIPanic; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITempt; import net.minecraft.entity.ai.EntityAIWander; @@ -24,197 +23,198 @@ import net.minecraft.stats.AchievementList; import net.minecraft.world.World; public class EntityBoar extends EntityAnimal { - /** AI task for player control. */ - private final EntityAIControlledByPlayer aiControlledByPlayer; - - public EntityBoar(World p_i1689_1_) { - super(p_i1689_1_); - this.setSize(0.9F, 0.9F); - this.getNavigator().setAvoidsWater(true); - this.tasks.addTask(0, new EntityAISwimming(this)); - //this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); - this.tasks.addTask(2, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.3F)); - this.tasks.addTask(3, new EntityAIMate(this, 1.0D)); - this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false)); - this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot, false)); - this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D)); - this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - this.tasks.addTask(8, new EntityAILookIdle(this)); - } - - /** - * Returns true if the newer Entity AI code should be run - */ - public boolean isAIEnabled() { - return true; - } - - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); - } - - protected void updateAITasks() { - super.updateAITasks(); - } - - /** - * returns true if all the conditions for steering the entity are met. For pigs, - * this is true if it is being ridden by a player and the player is holding a - * carrot-on-a-stick - */ - public boolean canBeSteered() { - ItemStack itemstack = ((EntityPlayer) this.riddenByEntity).getHeldItem(); - return itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick; - } - - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setBoolean("Saddle", this.getSaddled()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - this.setSaddled(p_70037_1_.getBoolean("Saddle")); - } - - /** - * Returns the sound this mob makes while it's alive. - */ - protected String getLivingSound() { - return "mob.pig.say"; - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - protected String getHurtSound() { - return "mob.pig.say"; - } - - /** - * Returns the sound this mob makes on death. - */ - protected String getDeathSound() { - return "mob.pig.death"; - } - - protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { - this.playSound("mob.pig.step", 0.15F, 1.0F); - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets - * into the saddle on a pig. - */ - public boolean interact(EntityPlayer p_70085_1_) { - if (super.interact(p_70085_1_)) { - return true; - } else if (this.getSaddled() && !this.worldObj.isRemote - && (this.riddenByEntity == null || this.riddenByEntity == p_70085_1_)) { - p_70085_1_.mountEntity(this); - return true; - } else { - return false; - } - } - - protected Item getDropItem() { - return this.isBurning() ? Items.cooked_porkchop : Items.porkchop; - } - - /** - * Drop 0-2 items of this living's type. @param par1 - Whether this entity has - * recently been hit by a player. @param par2 - Level of Looting used to kill - * this mob. - */ - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - int j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_); - - for (int k = 0; k < j; ++k) { - if (this.isBurning()) { - this.dropItem(Items.cooked_porkchop, 1); - } else { - this.dropItem(Items.porkchop, 1); - } - } - - if (this.getSaddled()) { - this.dropItem(Items.saddle, 1); - } - } - - /** - * Returns true if the pig is saddled. - */ - public boolean getSaddled() { - return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; - } - - /** - * Set or remove the saddle of the pig. - */ - public void setSaddled(boolean p_70900_1_) { - if (p_70900_1_) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) 1)); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) 0)); - } - } - - /** - * Called when a lightning bolt hits the entity. - */ - public void onStruckByLightning(EntityLightningBolt p_70077_1_) { - if (!this.worldObj.isRemote) { - EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj); - entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword)); - entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.worldObj.spawnEntityInWorld(entitypigzombie); - this.setDead(); - } - } - - /** - * Called when the mob is falling. Calculates and applies fall damage. - */ - protected void fall(float p_70069_1_) { - super.fall(p_70069_1_); - - if (p_70069_1_ > 5.0F && this.riddenByEntity instanceof EntityPlayer) { - ((EntityPlayer) this.riddenByEntity).triggerAchievement(AchievementList.flyPig); - } - } - - public EntityBoar createChild(EntityAgeable p_90011_1_) { - return new EntityBoar(this.worldObj); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it - * (wheat, carrots or seeds depending on the animal type) - */ - public boolean isBreedingItem(ItemStack p_70877_1_) { - return p_70877_1_ != null && p_70877_1_.getItem() == Items.carrot; - } - - /** - * Return the AI task for player control. - */ - public EntityAIControlledByPlayer getAIControlledByPlayer() { - return this.aiControlledByPlayer; - } -}
\ No newline at end of file + /** AI task for player control. */ + private final EntityAIControlledByPlayer aiControlledByPlayer; + + public EntityBoar(World p_i1689_1_) { + super(p_i1689_1_); + this.setSize(0.9F, 0.9F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + // this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); + this.tasks.addTask(2, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.3F)); + this.tasks.addTask(3, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false)); + this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot, false)); + this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D)); + this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + } + + /** + * Returns true if the newer Entity AI code should be run + */ + public boolean isAIEnabled() { + return true; + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + protected void updateAITasks() { + super.updateAITasks(); + } + + /** + * returns true if all the conditions for steering the entity are met. For pigs, + * this is true if it is being ridden by a player and the player is holding a + * carrot-on-a-stick + */ + public boolean canBeSteered() { + ItemStack itemstack = ((EntityPlayer) this.riddenByEntity).getHeldItem(); + return itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick; + } + + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setBoolean("Saddle", this.getSaddled()); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + this.setSaddled(p_70037_1_.getBoolean("Saddle")); + } + + /** + * Returns the sound this mob makes while it's alive. + */ + protected String getLivingSound() { + return "mob.pig.say"; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + protected String getHurtSound() { + return "mob.pig.say"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound() { + return "mob.pig.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { + this.playSound("mob.pig.step", 0.15F, 1.0F); + } + + /** + * Called when a player interacts with a mob. e.g. gets milk from a cow, gets + * into the saddle on a pig. + */ + public boolean interact(EntityPlayer p_70085_1_) { + if (super.interact(p_70085_1_)) { + return true; + } else if (this.getSaddled() + && !this.worldObj.isRemote + && (this.riddenByEntity == null || this.riddenByEntity == p_70085_1_)) { + p_70085_1_.mountEntity(this); + return true; + } else { + return false; + } + } + + protected Item getDropItem() { + return this.isBurning() ? Items.cooked_porkchop : Items.porkchop; + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity has + * recently been hit by a player. @param par2 - Level of Looting used to kill + * this mob. + */ + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_); + + for (int k = 0; k < j; ++k) { + if (this.isBurning()) { + this.dropItem(Items.cooked_porkchop, 1); + } else { + this.dropItem(Items.porkchop, 1); + } + } + + if (this.getSaddled()) { + this.dropItem(Items.saddle, 1); + } + } + + /** + * Returns true if the pig is saddled. + */ + public boolean getSaddled() { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + /** + * Set or remove the saddle of the pig. + */ + public void setSaddled(boolean p_70900_1_) { + if (p_70900_1_) { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) 1)); + } else { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) 0)); + } + } + + /** + * Called when a lightning bolt hits the entity. + */ + public void onStruckByLightning(EntityLightningBolt p_70077_1_) { + if (!this.worldObj.isRemote) { + EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj); + entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword)); + entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.worldObj.spawnEntityInWorld(entitypigzombie); + this.setDead(); + } + } + + /** + * Called when the mob is falling. Calculates and applies fall damage. + */ + protected void fall(float p_70069_1_) { + super.fall(p_70069_1_); + + if (p_70069_1_ > 5.0F && this.riddenByEntity instanceof EntityPlayer) { + ((EntityPlayer) this.riddenByEntity).triggerAchievement(AchievementList.flyPig); + } + } + + public EntityBoar createChild(EntityAgeable p_90011_1_) { + return new EntityBoar(this.worldObj); + } + + /** + * Checks if the parameter is an item which this animal can be fed to breed it + * (wheat, carrots or seeds depending on the animal type) + */ + public boolean isBreedingItem(ItemStack p_70877_1_) { + return p_70877_1_ != null && p_70877_1_.getItem() == Items.carrot; + } + + /** + * Return the AI task for player control. + */ + public EntityAIControlledByPlayer getAIControlledByPlayer() { + return this.aiControlledByPlayer; + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/type/EntityDingo.java b/src/main/java/gtPlusPlus/australia/entity/type/EntityDingo.java index 11b9737c4f..ad95631652 100644 --- a/src/main/java/gtPlusPlus/australia/entity/type/EntityDingo.java +++ b/src/main/java/gtPlusPlus/australia/entity/type/EntityDingo.java @@ -26,7 +26,6 @@ import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntitySheep; -import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; @@ -42,495 +41,519 @@ import net.minecraft.world.World; public class EntityDingo extends EntityWolf { - private float mPrivateField1; - private float mPrivateField2; - private boolean mPrivateField3; - - /** true is the dingo is wet else false */ - private boolean isShaking; - /** This time increases while dingo is shaking and emitting water particles. */ - private float timeWolfIsShaking; - private float prevTimeWolfIsShaking; - - public EntityDingo(World p_i1696_1_) { - super(p_i1696_1_); - this.setSize(0.6F, 0.8F); - this.getNavigator().setAvoidsWater(true); - this.tasks.addTask(1, new EntityAISwimming(this)); - this.tasks.addTask(2, this.aiSit); - this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); - this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); - this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); - this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); - this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(8, new EntityAIBeg(this, 8.0F)); - this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - this.tasks.addTask(9, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); - this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); - this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); - this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); - this.setTamed(false); - } - - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); - } - } - - /** - * Returns true if the newer Entity AI code should be run - */ - public boolean isAIEnabled() { - return true; - } - - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase p_70624_1_) { - super.setAttackTarget(p_70624_1_); - - if (p_70624_1_ == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - - /** - * main AI tick function, replaces updateEntityActionState - */ - protected void updateAITick() { - this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); - } - - protected void entityInit() { - super.entityInit(); - } - - protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { - this.playSound("mob.wolf.step", 0.15F, 1.0F); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - } - - /** - * Returns the sound this mob makes while it's alive. - */ - protected String getLivingSound() { - return this.isAngry() ? "mob.wolf.growl" - : (this.rand.nextInt(3) == 0 - ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" - : "mob.wolf.panting") - : "mob.wolf.bark"); - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - protected String getHurtSound() { - return "mob.wolf.hurt"; - } - - /** - * Returns the sound this mob makes on death. - */ - protected String getDeathSound() { - return "mob.wolf.death"; - } - - /** - * Returns the volume for the sounds this mob makes. - */ - protected float getSoundVolume() { - return 0.4F; - } - - protected Item getDropItem() { - return Item.getItemById(-1); - } - - /** - * Called frequently so the entity can update its state every tick as required. - * For example, zombies and skeletons use this to react to sunlight and start to - * burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - - if (!this.worldObj.isRemote && this.isShaking && !this.mPrivateField3 && !this.hasPath() && this.onGround) { - this.mPrivateField3 = true; - this.timeWolfIsShaking = 0.0F; - this.prevTimeWolfIsShaking = 0.0F; - this.worldObj.setEntityState(this, (byte) 8); - } - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - this.mPrivateField2 = this.mPrivateField1; - - if (this.func_70922_bv()) { - this.mPrivateField1 += (1.0F - this.mPrivateField1) * 0.4F; - } else { - this.mPrivateField1 += (0.0F - this.mPrivateField1) * 0.4F; - } - - if (this.func_70922_bv()) { - this.numTicksToChaseTarget = 10; - } - - if (this.isWet()) { - this.isShaking = true; - this.mPrivateField3 = false; - this.timeWolfIsShaking = 0.0F; - this.prevTimeWolfIsShaking = 0.0F; - } else if ((this.isShaking || this.mPrivateField3) && this.mPrivateField3) { - if (this.timeWolfIsShaking == 0.0F) { - this.playSound("mob.wolf.shake", this.getSoundVolume(), - (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); - } - - this.prevTimeWolfIsShaking = this.timeWolfIsShaking; - this.timeWolfIsShaking += 0.05F; - - if (this.prevTimeWolfIsShaking >= 2.0F) { - this.isShaking = false; - this.mPrivateField3 = false; - this.prevTimeWolfIsShaking = 0.0F; - this.timeWolfIsShaking = 0.0F; - } - - if (this.timeWolfIsShaking > 0.4F) { - float f = (float) this.boundingBox.minY; - int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); - - for (int j = 0; j < i; ++j) { - float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; - float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; - this.worldObj.spawnParticle("splash", this.posX + (double) f1, (double) (f + 0.8F), - this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ); - } - } - } - } - - @SideOnly(Side.CLIENT) - public boolean getWolfShaking() { - return this.isShaking; - } - - /** - * Used when calculating the amount of shading to apply while the dingo is - * shaking. - */ - @SideOnly(Side.CLIENT) - public float getShadingWhileShaking(float p_70915_1_) { - return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) - / 2.0F * 0.25F; - } - - @SideOnly(Side.CLIENT) - public float getShakeAngle(float p_70923_1_, float p_70923_2_) { - float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ - + p_70923_2_) / 1.8F; - - if (f2 < 0.0F) { - f2 = 0.0F; - } else if (f2 > 1.0F) { - f2 = 1.0F; - } - - return MathHelper.sin(f2 * (float) Math.PI) * MathHelper.sin(f2 * (float) Math.PI * 11.0F) * 0.15F - * (float) Math.PI; - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - @SideOnly(Side.CLIENT) - public float getInterestedAngle(float p_70917_1_) { - return (this.mPrivateField2 + (this.mPrivateField1 - this.mPrivateField2) * p_70917_1_) * 0.15F - * (float) Math.PI; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the - * faceEntity method. This is only currently use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = p_70097_1_.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(p_70097_1_, p_70097_2_); - } - } - - public boolean attackEntityAsMob(Entity p_70652_1_) { - int i = this.isTamed() ? 4 : 2; - return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); - } - - public void setTamed(boolean p_70903_1_) { - super.setTamed(p_70903_1_); - - if (p_70903_1_) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets - * into the saddle on a pig. - */ - public boolean interact(EntityPlayer p_70085_1_) { - ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { - if (!p_70085_1_.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, - (ItemStack) null); - } - - return true; - } - } else if (itemstack.getItem() == Items.dye) { - int i = BlockColored.func_150032_b(itemstack.getItemDamage()); - - if (i != this.getCollarColor()) { - this.setCollarColor(i); - - if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { - p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, - (ItemStack) null); - } - - return true; - } - } - } - - if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity((PathEntity) null); - this.setTarget((Entity) null); - this.setAttackTarget((EntityLivingBase) null); - } - } else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry()) { - if (!p_70085_1_.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(3) == 0) { - this.setTamed(true); - this.setPathToEntity((PathEntity) null); - this.setAttackTarget((EntityLivingBase) null); - this.aiSit.setSitting(true); - this.setHealth(20.0F); - this.func_152115_b(p_70085_1_.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(p_70085_1_); - } - - @SideOnly(Side.CLIENT) - public void handleHealthUpdate(byte p_70103_1_) { - if (p_70103_1_ == 8) { - this.mPrivateField3 = true; - this.timeWolfIsShaking = 0.0F; - this.prevTimeWolfIsShaking = 0.0F; - } else { - super.handleHealthUpdate(p_70103_1_); - } - } - - @SideOnly(Side.CLIENT) - public float getTailRotation() { - return this.isAngry() ? 1.5393804F - : (this.isTamed() - ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI - : ((float) Math.PI / 5F)); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it - * (wheat, carrots or seeds depending on the animal type) - */ - public boolean isBreedingItem(ItemStack p_70877_1_) { - return p_70877_1_ == null ? false - : (!(p_70877_1_.getItem() instanceof ItemFood) ? false - : ((ItemFood) p_70877_1_.getItem()).isWolfsFavoriteMeat()); - } - - /** - * Will return how many at most can spawn in a chunk at once. - */ - public int getMaxSpawnedInChunk() { - return 8; - } - - /** - * Determines whether this dingo is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this dingo is angry or not. - */ - public void setAngry(boolean p_70916_1_) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (p_70916_1_) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Return this dingo's collar color. - */ - public int getCollarColor() { - return this.dataWatcher.getWatchableObjectByte(20) & 15; - } - - /** - * Set this dingo's collar color. - */ - public void setCollarColor(int p_82185_1_) { - this.dataWatcher.updateObject(20, Byte.valueOf((byte) (p_82185_1_ & 15))); - } - - public EntityDingo createChild(EntityAgeable p_90011_1_) { - EntityDingo entitydingo = new EntityDingo(this.worldObj); - String s = this.func_152113_b(); - - if (s != null && s.trim().length() > 0) { - entitydingo.func_152115_b(s); - entitydingo.setTamed(true); - } - - return entitydingo; - } - - public void func_70918_i(boolean p_70918_1_) { - if (p_70918_1_) { - this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1)); - } else { - this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0)); - } - } - - /** - * Returns true if the mob is currently able to mate with the specified mob. - */ - public boolean canMateWith(EntityAnimal p_70878_1_) { - if (p_70878_1_ == this) { - return false; - } else if (!this.isTamed()) { - return false; - } else if (!(p_70878_1_ instanceof EntityDingo)) { - return false; - } else { - EntityDingo entitydingo = (EntityDingo) p_70878_1_; - return !entitydingo.isTamed() ? false - : (entitydingo.isSitting() ? false : this.isInLove() && entitydingo.isInLove()); - } - } - - public boolean func_70922_bv() { - return this.dataWatcher.getWatchableObjectByte(19) == 1; - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return !this.isTamed() && this.ticksExisted > 2400; - } - - public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) { - if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) { - if (p_142018_1_ instanceof EntityDingo) { - EntityDingo entitydingo = (EntityDingo) p_142018_1_; - - if (entitydingo.isTamed() && entitydingo.getOwner() == p_142018_2_) { - return false; - } - } - - return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer - && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) ? false - : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame(); - } else { - return false; - } - } -}
\ No newline at end of file + private float mPrivateField1; + private float mPrivateField2; + private boolean mPrivateField3; + + /** true is the dingo is wet else false */ + private boolean isShaking; + /** This time increases while dingo is shaking and emitting water particles. */ + private float timeWolfIsShaking; + + private float prevTimeWolfIsShaking; + + public EntityDingo(World p_i1696_1_) { + super(p_i1696_1_); + this.setSize(0.6F, 0.8F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, this.aiSit); + this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); + this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); + this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(8, new EntityAIBeg(this, 8.0F)); + this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(9, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); + this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); + this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); + this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); + this.setTamed(false); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); + + if (this.isTamed()) { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + } else { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + } + } + + /** + * Returns true if the newer Entity AI code should be run + */ + public boolean isAIEnabled() { + return true; + } + + /** + * Sets the active target the Task system uses for tracking + */ + public void setAttackTarget(EntityLivingBase p_70624_1_) { + super.setAttackTarget(p_70624_1_); + + if (p_70624_1_ == null) { + this.setAngry(false); + } else if (!this.isTamed()) { + this.setAngry(true); + } + } + + /** + * main AI tick function, replaces updateEntityActionState + */ + protected void updateAITick() { + this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); + } + + protected void entityInit() { + super.entityInit(); + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { + this.playSound("mob.wolf.step", 0.15F, 1.0F); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + } + + /** + * Returns the sound this mob makes while it's alive. + */ + protected String getLivingSound() { + return this.isAngry() + ? "mob.wolf.growl" + : (this.rand.nextInt(3) == 0 + ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F + ? "mob.wolf.whine" + : "mob.wolf.panting") + : "mob.wolf.bark"); + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + protected String getHurtSound() { + return "mob.wolf.hurt"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound() { + return "mob.wolf.death"; + } + + /** + * Returns the volume for the sounds this mob makes. + */ + protected float getSoundVolume() { + return 0.4F; + } + + protected Item getDropItem() { + return Item.getItemById(-1); + } + + /** + * Called frequently so the entity can update its state every tick as required. + * For example, zombies and skeletons use this to react to sunlight and start to + * burn. + */ + public void onLivingUpdate() { + super.onLivingUpdate(); + + if (!this.worldObj.isRemote && this.isShaking && !this.mPrivateField3 && !this.hasPath() && this.onGround) { + this.mPrivateField3 = true; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + this.worldObj.setEntityState(this, (byte) 8); + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + super.onUpdate(); + this.mPrivateField2 = this.mPrivateField1; + + if (this.func_70922_bv()) { + this.mPrivateField1 += (1.0F - this.mPrivateField1) * 0.4F; + } else { + this.mPrivateField1 += (0.0F - this.mPrivateField1) * 0.4F; + } + + if (this.func_70922_bv()) { + this.numTicksToChaseTarget = 10; + } + + if (this.isWet()) { + this.isShaking = true; + this.mPrivateField3 = false; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + } else if ((this.isShaking || this.mPrivateField3) && this.mPrivateField3) { + if (this.timeWolfIsShaking == 0.0F) { + this.playSound( + "mob.wolf.shake", + this.getSoundVolume(), + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + } + + this.prevTimeWolfIsShaking = this.timeWolfIsShaking; + this.timeWolfIsShaking += 0.05F; + + if (this.prevTimeWolfIsShaking >= 2.0F) { + this.isShaking = false; + this.mPrivateField3 = false; + this.prevTimeWolfIsShaking = 0.0F; + this.timeWolfIsShaking = 0.0F; + } + + if (this.timeWolfIsShaking > 0.4F) { + float f = (float) this.boundingBox.minY; + int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); + + for (int j = 0; j < i; ++j) { + float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; + float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; + this.worldObj.spawnParticle( + "splash", + this.posX + (double) f1, + (double) (f + 0.8F), + this.posZ + (double) f2, + this.motionX, + this.motionY, + this.motionZ); + } + } + } + } + + @SideOnly(Side.CLIENT) + public boolean getWolfShaking() { + return this.isShaking; + } + + /** + * Used when calculating the amount of shading to apply while the dingo is + * shaking. + */ + @SideOnly(Side.CLIENT) + public float getShadingWhileShaking(float p_70915_1_) { + return 0.75F + + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) + / 2.0F + * 0.25F; + } + + @SideOnly(Side.CLIENT) + public float getShakeAngle(float p_70923_1_, float p_70923_2_) { + float f2 = (this.prevTimeWolfIsShaking + + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + + p_70923_2_) + / 1.8F; + + if (f2 < 0.0F) { + f2 = 0.0F; + } else if (f2 > 1.0F) { + f2 = 1.0F; + } + + return MathHelper.sin(f2 * (float) Math.PI) + * MathHelper.sin(f2 * (float) Math.PI * 11.0F) + * 0.15F + * (float) Math.PI; + } + + public float getEyeHeight() { + return this.height * 0.8F; + } + + @SideOnly(Side.CLIENT) + public float getInterestedAngle(float p_70917_1_) { + return (this.mPrivateField2 + (this.mPrivateField1 - this.mPrivateField2) * p_70917_1_) + * 0.15F + * (float) Math.PI; + } + + /** + * The speed it takes to move the entityliving's rotationPitch through the + * faceEntity method. This is only currently use in wolves. + */ + public int getVerticalFaceSpeed() { + return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + if (this.isEntityInvulnerable()) { + return false; + } else { + Entity entity = p_70097_1_.getEntity(); + this.aiSit.setSitting(false); + + if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { + p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F; + } + + return super.attackEntityFrom(p_70097_1_, p_70097_2_); + } + } + + public boolean attackEntityAsMob(Entity p_70652_1_) { + int i = this.isTamed() ? 4 : 2; + return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + } + + public void setTamed(boolean p_70903_1_) { + super.setTamed(p_70903_1_); + + if (p_70903_1_) { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + } else { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + } + } + + /** + * Called when a player interacts with a mob. e.g. gets milk from a cow, gets + * into the saddle on a pig. + */ + public boolean interact(EntityPlayer p_70085_1_) { + ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); + + if (this.isTamed()) { + if (itemstack != null) { + if (itemstack.getItem() instanceof ItemFood) { + ItemFood itemfood = (ItemFood) itemstack.getItem(); + + if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { + if (!p_70085_1_.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + + this.heal((float) itemfood.func_150905_g(itemstack)); + + if (itemstack.stackSize <= 0) { + p_70085_1_.inventory.setInventorySlotContents( + p_70085_1_.inventory.currentItem, (ItemStack) null); + } + + return true; + } + } else if (itemstack.getItem() == Items.dye) { + int i = BlockColored.func_150032_b(itemstack.getItemDamage()); + + if (i != this.getCollarColor()) { + this.setCollarColor(i); + + if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { + p_70085_1_.inventory.setInventorySlotContents( + p_70085_1_.inventory.currentItem, (ItemStack) null); + } + + return true; + } + } + } + + if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { + this.aiSit.setSitting(!this.isSitting()); + this.isJumping = false; + this.setPathToEntity((PathEntity) null); + this.setTarget((Entity) null); + this.setAttackTarget((EntityLivingBase) null); + } + } else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry()) { + if (!p_70085_1_.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + + if (itemstack.stackSize <= 0) { + p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); + } + + if (!this.worldObj.isRemote) { + if (this.rand.nextInt(3) == 0) { + this.setTamed(true); + this.setPathToEntity((PathEntity) null); + this.setAttackTarget((EntityLivingBase) null); + this.aiSit.setSitting(true); + this.setHealth(20.0F); + this.func_152115_b(p_70085_1_.getUniqueID().toString()); + this.playTameEffect(true); + this.worldObj.setEntityState(this, (byte) 7); + } else { + this.playTameEffect(false); + this.worldObj.setEntityState(this, (byte) 6); + } + } + + return true; + } + + return super.interact(p_70085_1_); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte p_70103_1_) { + if (p_70103_1_ == 8) { + this.mPrivateField3 = true; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + } else { + super.handleHealthUpdate(p_70103_1_); + } + } + + @SideOnly(Side.CLIENT) + public float getTailRotation() { + return this.isAngry() + ? 1.5393804F + : (this.isTamed() + ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI + : ((float) Math.PI / 5F)); + } + + /** + * Checks if the parameter is an item which this animal can be fed to breed it + * (wheat, carrots or seeds depending on the animal type) + */ + public boolean isBreedingItem(ItemStack p_70877_1_) { + return p_70877_1_ == null + ? false + : (!(p_70877_1_.getItem() instanceof ItemFood) + ? false + : ((ItemFood) p_70877_1_.getItem()).isWolfsFavoriteMeat()); + } + + /** + * Will return how many at most can spawn in a chunk at once. + */ + public int getMaxSpawnedInChunk() { + return 8; + } + + /** + * Determines whether this dingo is angry or not. + */ + public boolean isAngry() { + return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; + } + + /** + * Sets whether this dingo is angry or not. + */ + public void setAngry(boolean p_70916_1_) { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (p_70916_1_) { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); + } else { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); + } + } + + /** + * Return this dingo's collar color. + */ + public int getCollarColor() { + return this.dataWatcher.getWatchableObjectByte(20) & 15; + } + + /** + * Set this dingo's collar color. + */ + public void setCollarColor(int p_82185_1_) { + this.dataWatcher.updateObject(20, Byte.valueOf((byte) (p_82185_1_ & 15))); + } + + public EntityDingo createChild(EntityAgeable p_90011_1_) { + EntityDingo entitydingo = new EntityDingo(this.worldObj); + String s = this.func_152113_b(); + + if (s != null && s.trim().length() > 0) { + entitydingo.func_152115_b(s); + entitydingo.setTamed(true); + } + + return entitydingo; + } + + public void func_70918_i(boolean p_70918_1_) { + if (p_70918_1_) { + this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1)); + } else { + this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0)); + } + } + + /** + * Returns true if the mob is currently able to mate with the specified mob. + */ + public boolean canMateWith(EntityAnimal p_70878_1_) { + if (p_70878_1_ == this) { + return false; + } else if (!this.isTamed()) { + return false; + } else if (!(p_70878_1_ instanceof EntityDingo)) { + return false; + } else { + EntityDingo entitydingo = (EntityDingo) p_70878_1_; + return !entitydingo.isTamed() + ? false + : (entitydingo.isSitting() ? false : this.isInLove() && entitydingo.isInLove()); + } + } + + public boolean func_70922_bv() { + return this.dataWatcher.getWatchableObjectByte(19) == 1; + } + + /** + * Determines if an entity can be despawned, used on idle far away entities + */ + protected boolean canDespawn() { + return !this.isTamed() && this.ticksExisted > 2400; + } + + public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) { + if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) { + if (p_142018_1_ instanceof EntityDingo) { + EntityDingo entitydingo = (EntityDingo) p_142018_1_; + + if (entitydingo.isTamed() && entitydingo.getOwner() == p_142018_2_) { + return false; + } + } + + return p_142018_1_ instanceof EntityPlayer + && p_142018_2_ instanceof EntityPlayer + && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) + ? false + : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame(); + } else { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/entity/type/EntityOctopus.java b/src/main/java/gtPlusPlus/australia/entity/type/EntityOctopus.java index f88d931b52..9d9f883865 100644 --- a/src/main/java/gtPlusPlus/australia/entity/type/EntityOctopus.java +++ b/src/main/java/gtPlusPlus/australia/entity/type/EntityOctopus.java @@ -9,8 +9,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class EntityOctopus extends EntityWaterMob -{ +public class EntityOctopus extends EntityWaterMob { public float octopusPitch; public float prevSquidPitch; public float octopusYaw; @@ -23,23 +22,23 @@ public class EntityOctopus extends EntityWaterMob public float tentacleAngle; /** the last calculated angle of the tentacles in radians */ public float lastTentacleAngle; + private float randomMotionSpeed; /** change in octopusRotation in radians. */ private float rotationVelocity; + private float field_70871_bB; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; - public EntityOctopus(World p_i1693_1_) - { + public EntityOctopus(World p_i1693_1_) { super(p_i1693_1_); this.setSize(0.95F, 0.95F); this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F; } - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); } @@ -47,37 +46,32 @@ public class EntityOctopus extends EntityWaterMob /** * Returns the sound this mob makes while it's alive. */ - protected String getLivingSound() - { + protected String getLivingSound() { return null; } /** * Returns the sound this mob makes when it is hurt. */ - protected String getHurtSound() - { + protected String getHurtSound() { return null; } /** * Returns the sound this mob makes on death. */ - protected String getDeathSound() - { + protected String getDeathSound() { return null; } /** * Returns the volume for the sounds this mob makes. */ - protected float getSoundVolume() - { + protected float getSoundVolume() { return 0.4F; } - protected Item getDropItem() - { + protected Item getDropItem() { return Item.getItemById(0); } @@ -85,8 +79,7 @@ public class EntityOctopus extends EntityWaterMob * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ - protected boolean canTriggerWalking() - { + protected boolean canTriggerWalking() { return false; } @@ -94,12 +87,10 @@ public class EntityOctopus extends EntityWaterMob * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param * par2 - Level of Looting used to kill this mob. */ - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) - { + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { int j = this.rand.nextInt(3 + p_70628_2_) + 1; - for (int k = 0; k < j; ++k) - { + for (int k = 0; k < j; ++k) { this.entityDropItem(new ItemStack(Items.dye, 1, 0), 0.0F); } } @@ -108,17 +99,16 @@ public class EntityOctopus extends EntityWaterMob * Checks if this entity is inside water (if inWater field is true as a result of handleWaterMovement() returning * true) */ - public boolean isInWater() - { - return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); + public boolean isInWater() { + return this.worldObj.handleMaterialAcceleration( + this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ - public void onLivingUpdate() - { + public void onLivingUpdate() { super.onLivingUpdate(); this.prevSquidPitch = this.octopusPitch; this.prevSquidYaw = this.octopusYaw; @@ -126,90 +116,78 @@ public class EntityOctopus extends EntityWaterMob this.lastTentacleAngle = this.tentacleAngle; this.octopusRotation += this.rotationVelocity; - if (this.octopusRotation > ((float)Math.PI * 2F)) - { - this.octopusRotation -= ((float)Math.PI * 2F); + if (this.octopusRotation > ((float) Math.PI * 2F)) { + this.octopusRotation -= ((float) Math.PI * 2F); - if (this.rand.nextInt(10) == 0) - { + if (this.rand.nextInt(10) == 0) { this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F; } } - if (this.isInWater()) - { + if (this.isInWater()) { float f; - if (this.octopusRotation < (float)Math.PI) - { - f = this.octopusRotation / (float)Math.PI; - this.tentacleAngle = MathHelper.sin(f * f * (float)Math.PI) * (float)Math.PI * 0.25F; + if (this.octopusRotation < (float) Math.PI) { + f = this.octopusRotation / (float) Math.PI; + this.tentacleAngle = MathHelper.sin(f * f * (float) Math.PI) * (float) Math.PI * 0.25F; - if ((double)f > 0.75D) - { + if ((double) f > 0.75D) { this.randomMotionSpeed = 1.0F; this.field_70871_bB = 1.0F; - } - else - { + } else { this.field_70871_bB *= 0.8F; } - } - else - { + } else { this.tentacleAngle = 0.0F; this.randomMotionSpeed *= 0.9F; this.field_70871_bB *= 0.99F; } - if (!this.worldObj.isRemote) - { - this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); - this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); - this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); + if (!this.worldObj.isRemote) { + this.motionX = (double) (this.randomMotionVecX * this.randomMotionSpeed); + this.motionY = (double) (this.randomMotionVecY * this.randomMotionSpeed); + this.motionZ = (double) (this.randomMotionVecZ * this.randomMotionSpeed); } f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F; + this.renderYawOffset += (-((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float) Math.PI + - this.renderYawOffset) + * 0.1F; this.rotationYaw = this.renderYawOffset; - this.octopusYaw += (float)Math.PI * this.field_70871_bB * 1.5F; - this.octopusPitch += (-((float)Math.atan2((double)f, this.motionY)) * 180.0F / (float)Math.PI - this.octopusPitch) * 0.1F; - } - else - { - this.tentacleAngle = MathHelper.abs(MathHelper.sin(this.octopusRotation)) * (float)Math.PI * 0.25F; - - if (!this.worldObj.isRemote) - { + this.octopusYaw += (float) Math.PI * this.field_70871_bB * 1.5F; + this.octopusPitch += + (-((float) Math.atan2((double) f, this.motionY)) * 180.0F / (float) Math.PI - this.octopusPitch) + * 0.1F; + } else { + this.tentacleAngle = MathHelper.abs(MathHelper.sin(this.octopusRotation)) * (float) Math.PI * 0.25F; + + if (!this.worldObj.isRemote) { this.motionX = 0.0D; this.motionY -= 0.08D; this.motionY *= 0.9800000190734863D; this.motionZ = 0.0D; } - this.octopusPitch = (float)((double)this.octopusPitch + (double)(-90.0F - this.octopusPitch) * 0.02D); + this.octopusPitch = (float) ((double) this.octopusPitch + (double) (-90.0F - this.octopusPitch) * 0.02D); } } /** * Moves the entity based on the specified heading. Args: strafe, forward */ - public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) - { + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } - protected void updateEntityActionState() - { + protected void updateEntityActionState() { ++this.entityAge; - if (this.entityAge > 100) - { + if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; - } - else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) - { - float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + } else if (this.rand.nextInt(50) == 0 + || !this.inWater + || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { + float f = this.rand.nextFloat() * (float) Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; @@ -221,8 +199,7 @@ public class EntityOctopus extends EntityWaterMob /** * Checks if the entity's current position is a valid location to spawn this entity. */ - public boolean getCanSpawnHere() - { + public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java index 18f9e6684f..cd88940e11 100644 --- a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java +++ b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java @@ -1,294 +1,235 @@ package gtPlusPlus.australia.gen.gt; -import java.util.Hashtable; - import gregtech.api.enums.Materials; - import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.everglades.object.BoxedQuad; +import java.util.Hashtable; public class WorldGen_Australia_Ores { - - /** - * Set Ore Types on by one. - */ - private static final Material PYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrite); - private static final Material PYROPE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrope); - private static final Material ALMANDINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Almandine); - private static final Material RUBY = MaterialUtils.generateMaterialFromGtENUM(Materials.Ruby); - private static final Material CHALCOPYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite); - private static final Material TOPAZ = MaterialUtils.generateMaterialFromGtENUM(Materials.Topaz); - private static final Material SAPPHIRE_GREEN = MaterialUtils.generateMaterialFromGtENUM(Materials.GreenSapphire); - private static final Material SAPPHIRE_BLUE = MaterialUtils.generateMaterialFromGtENUM(Materials.Sapphire); - - - private static final Material EMERALD = MaterialUtils.generateMaterialFromGtENUM(Materials.Emerald); - private static final Material DIAMOND = MaterialUtils.generateMaterialFromGtENUM(Materials.Diamond); - private static final Material BANDED_IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.BandedIron); - private static final Material LIM_YELLOW = MaterialUtils.generateMaterialFromGtENUM(Materials.YellowLimonite); - private static final Material LIM_BROWN = MaterialUtils.generateMaterialFromGtENUM(Materials.BrownLimonite); - private static final Material TETRAHEDRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Tetrahedrite); - private static final Material COAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Coal); - private static final Material SHIT_COAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Lignite); - private static final Material GRAPHITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Graphite); - - - - public static WorldGen_GT_Australia_Ore_Layer BaseVein = new WorldGen_GT_Australia_Ore_Layer( - "veinA", - 0, 128, - 5, - 8, - 32, - ELEMENT.getInstance().IRON, - BANDED_IRON, - LIM_YELLOW, - TETRAHEDRITE); - - - - /** - * Custom ore Veins - */ - - public static WorldGen_GT_Australia_Ore_Layer Vein1 = new WorldGen_GT_Australia_Ore_Layer( - "vein1", - 0, 10, - 1, - 8, - 16, - EMERALD, - SHIT_COAL, - TOPAZ, - DIAMOND); - - public static WorldGen_GT_Australia_Ore_Layer Vein2 = new WorldGen_GT_Australia_Ore_Layer( - "vein2", - 0, 128, - 20, - 16, - 64, - COAL, - COAL, - SHIT_COAL, - SHIT_COAL); + /** + * Set Ore Types on by one. + */ + private static final Material PYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrite); + + private static final Material PYROPE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrope); + private static final Material ALMANDINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Almandine); + private static final Material RUBY = MaterialUtils.generateMaterialFromGtENUM(Materials.Ruby); + private static final Material CHALCOPYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite); + private static final Material TOPAZ = MaterialUtils.generateMaterialFromGtENUM(Materials.Topaz); + private static final Material SAPPHIRE_GREEN = MaterialUtils.generateMaterialFromGtENUM(Materials.GreenSapphire); + private static final Material SAPPHIRE_BLUE = MaterialUtils.generateMaterialFromGtENUM(Materials.Sapphire); + + private static final Material EMERALD = MaterialUtils.generateMaterialFromGtENUM(Materials.Emerald); + private static final Material DIAMOND = MaterialUtils.generateMaterialFromGtENUM(Materials.Diamond); + private static final Material BANDED_IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.BandedIron); + private static final Material LIM_YELLOW = MaterialUtils.generateMaterialFromGtENUM(Materials.YellowLimonite); + private static final Material LIM_BROWN = MaterialUtils.generateMaterialFromGtENUM(Materials.BrownLimonite); + private static final Material TETRAHEDRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Tetrahedrite); + private static final Material COAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Coal); + private static final Material SHIT_COAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Lignite); + private static final Material GRAPHITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Graphite); + + public static WorldGen_GT_Australia_Ore_Layer BaseVein = new WorldGen_GT_Australia_Ore_Layer( + "veinA", 0, 128, 5, 8, 32, ELEMENT.getInstance().IRON, BANDED_IRON, LIM_YELLOW, TETRAHEDRITE); + + /** + * Custom ore Veins + */ + public static WorldGen_GT_Australia_Ore_Layer Vein1 = + new WorldGen_GT_Australia_Ore_Layer("vein1", 0, 10, 1, 8, 16, EMERALD, SHIT_COAL, TOPAZ, DIAMOND); + + public static WorldGen_GT_Australia_Ore_Layer Vein2 = + new WorldGen_GT_Australia_Ore_Layer("vein2", 0, 128, 20, 16, 64, COAL, COAL, SHIT_COAL, SHIT_COAL); + + public static WorldGen_GT_Australia_Ore_Layer Vein3 = new WorldGen_GT_Australia_Ore_Layer( + "vein3", + 0, + 128, + 5, + 8, + 32, + ELEMENT.getInstance().IRON, + ELEMENT.getInstance().TIN, + ELEMENT.getInstance().GOLD, + ELEMENT.getInstance().LEAD); + + public static WorldGen_GT_Australia_Ore_Layer Vein4 = new WorldGen_GT_Australia_Ore_Layer( + "vein4", + 0, + 128, + 5, + 8, + 32, + ELEMENT.getInstance().GOLD, + ELEMENT.getInstance().COPPER, + ELEMENT.getInstance().COBALT, + ALMANDINE); + + public static WorldGen_GT_Australia_Ore_Layer Vein5 = + new WorldGen_GT_Australia_Ore_Layer("vein5", 0, 128, 15, 8, 16, PYRITE, PYROPE, LIM_YELLOW, CHALCOPYRITE); + + public static WorldGen_GT_Australia_Ore_Layer Vein6 = new WorldGen_GT_Australia_Ore_Layer( + "vein6", + 0, + 128, + 5, + 8, + 32, + LIM_BROWN, + SAPPHIRE_GREEN, + ELEMENT.getInstance().IRON, + ELEMENT.getInstance().COPPER); + + public static WorldGen_GT_Australia_Ore_Layer Vein7 = new WorldGen_GT_Australia_Ore_Layer( + "vein7", 0, 128, 5, 8, 32, GRAPHITE, RUBY, LIM_YELLOW, ELEMENT.getInstance().NICKEL); + + public static WorldGen_GT_Australia_Ore_Layer Vein8 = new WorldGen_GT_Australia_Ore_Layer( + "vein8", 0, 128, 5, 8, 32, ELEMENT.getInstance().IRON, SAPPHIRE_BLUE, LIM_YELLOW, GRAPHITE); + + /*public static WorldGen_GT_Australia_Ore_Layer Vein9 = new WorldGen_GT_Australia_Ore_Layer( + "vein9", + 10, 30, + 20, + 4, + 64, + ORES.LANTHANITE_CE, + FLUORIDES.FLUORITE, + PLATINUM, + ORES.FLORENCITE); + public static WorldGen_GT_Australia_Ore_Layer Vein10 = new WorldGen_GT_Australia_Ore_Layer( + "vein10", + 20, 50, + 20, + 8, + 32, + ORES.GEIKIELITE, + ORES.YTTROCERITE, + ORES.LANTHANITE_LA, + BAUXITE); + public static WorldGen_GT_Australia_Ore_Layer Vein11 = new WorldGen_GT_Australia_Ore_Layer( + "vein11", + 30, 70, + 20, + 5, + 64, + FLUORIDES.FLUORITE, + SAPPHIRE_BLUE, + ORES.ZIRCON, + ORES.CRYOLITE); + public static WorldGen_GT_Australia_Ore_Layer Vein12 = new WorldGen_GT_Australia_Ore_Layer( + "vein12", + 40, 80, + 20, + 8, + 32, + ORES.CERITE, + SAPPHIRE_GREEN, + CHALCOPYRITE, + ORES.HIBONITE); + + */ + /** + * Best Rarest Veins 2017 + */ + /* + + public static WorldGen_GT_Australia_Ore_Layer Vein13 = new WorldGen_GT_Australia_Ore_Layer( + "vein13", + 5, 15, + 5, + 5, + 16, + ORES.CRYOLITE, + NAQPLUS, + NAQUADRIA, + ORES.FLORENCITE); + + public static WorldGen_GT_Australia_Ore_Layer Vein14 = new WorldGen_GT_Australia_Ore_Layer( + "vein14", + 10, 20, + 8, + 3, + 16, + URNAIUM235, + PLUTONIUM, + OSMIUM, + AMETHYST); + + public static WorldGen_GT_Australia_Ore_Layer Vein15 = new WorldGen_GT_Australia_Ore_Layer( + "vein15", + 5, 25, + 5, + 6, + 24, + ORES.FLUORCAPHITE, + BISMUTH, + ORES.GADOLINITE_CE, + ORES.GADOLINITE_Y); + + public static WorldGen_GT_Australia_Ore_Layer Vein16 = new WorldGen_GT_Australia_Ore_Layer( + "vein16", + 0, 25, + 4, + 6, + 32, + ORES.YTTROCERITE, + ORES.LEPERSONNITE, + INFUSEDGOLD, + FLUORIDES.FLUORITE); - public static WorldGen_GT_Australia_Ore_Layer Vein3 = new WorldGen_GT_Australia_Ore_Layer( - "vein3", - 0, 128, - 5, - 8, - 32, - ELEMENT.getInstance().IRON, - ELEMENT.getInstance().TIN, - ELEMENT.getInstance().GOLD, - ELEMENT.getInstance().LEAD); + public static WorldGen_GT_Australia_Ore_Layer Vein17 = new WorldGen_GT_Australia_Ore_Layer( + "vein17", + 10, 35, + 4, + 5, + 32, + ORES.FLORENCITE, + URNAIUM235, + ORES.SAMARSKITE_YB, + ORES.POLYCRASE); + public static WorldGen_GT_Australia_Ore_Layer Vein18 = new WorldGen_GT_Australia_Ore_Layer( + "vein18", + 15, 40, + 4, + 4, + 64, + ORES.GADOLINITE_CE, + ORES.GADOLINITE_Y, + ORES.AGARDITE_LA, + ORES.AGARDITE_CD);*/ - public static WorldGen_GT_Australia_Ore_Layer Vein4 = new WorldGen_GT_Australia_Ore_Layer( - "vein4", - 0, 128, - 5, - 8, - 32, - ELEMENT.getInstance().GOLD, - ELEMENT.getInstance().COPPER, - ELEMENT.getInstance().COBALT, - ALMANDINE); - - - - public static WorldGen_GT_Australia_Ore_Layer Vein5 = new WorldGen_GT_Australia_Ore_Layer( - "vein5", - 0, 128, - 15, - 8, - 16, - PYRITE, - PYROPE, - LIM_YELLOW, - CHALCOPYRITE); - - public static WorldGen_GT_Australia_Ore_Layer Vein6 = new WorldGen_GT_Australia_Ore_Layer( - "vein6", - 0, 128, - 5, - 8, - 32, - LIM_BROWN, - SAPPHIRE_GREEN, - ELEMENT.getInstance().IRON, - ELEMENT.getInstance().COPPER); - - public static WorldGen_GT_Australia_Ore_Layer Vein7 = new WorldGen_GT_Australia_Ore_Layer( - "vein7", - 0, 128, - 5, - 8, - 32, - GRAPHITE, - RUBY, - LIM_YELLOW, - ELEMENT.getInstance().NICKEL); - - public static WorldGen_GT_Australia_Ore_Layer Vein8 = new WorldGen_GT_Australia_Ore_Layer( - "vein8", - 0, 128, - 5, - 8, - 32, - ELEMENT.getInstance().IRON, - SAPPHIRE_BLUE, - LIM_YELLOW, - GRAPHITE); - - - + public static Hashtable<Long, WorldGen_GT_Australia_Ore_Layer> validOreveins = + new Hashtable<Long, WorldGen_GT_Australia_Ore_Layer>(1024); - /*public static WorldGen_GT_Australia_Ore_Layer Vein9 = new WorldGen_GT_Australia_Ore_Layer( - "vein9", - 10, 30, - 20, - 4, - 64, - ORES.LANTHANITE_CE, - FLUORIDES.FLUORITE, - PLATINUM, - ORES.FLORENCITE); - public static WorldGen_GT_Australia_Ore_Layer Vein10 = new WorldGen_GT_Australia_Ore_Layer( - "vein10", - 20, 50, - 20, - 8, - 32, - ORES.GEIKIELITE, - ORES.YTTROCERITE, - ORES.LANTHANITE_LA, - BAUXITE); - public static WorldGen_GT_Australia_Ore_Layer Vein11 = new WorldGen_GT_Australia_Ore_Layer( - "vein11", - 30, 70, - 20, - 5, - 64, - FLUORIDES.FLUORITE, - SAPPHIRE_BLUE, - ORES.ZIRCON, - ORES.CRYOLITE); - public static WorldGen_GT_Australia_Ore_Layer Vein12 = new WorldGen_GT_Australia_Ore_Layer( - "vein12", - 40, 80, - 20, - 8, - 32, - ORES.CERITE, - SAPPHIRE_GREEN, - CHALCOPYRITE, - ORES.HIBONITE); - - *//** - * Best Rarest Veins 2017 - *//* - - public static WorldGen_GT_Australia_Ore_Layer Vein13 = new WorldGen_GT_Australia_Ore_Layer( - "vein13", - 5, 15, - 5, - 5, - 16, - ORES.CRYOLITE, - NAQPLUS, - NAQUADRIA, - ORES.FLORENCITE); + public static volatile BoxedQuad<Integer, Integer, Integer, Integer> OreVein1 = + new BoxedQuad<Integer, Integer, Integer, Integer>(null, null, null, null); - public static WorldGen_GT_Australia_Ore_Layer Vein14 = new WorldGen_GT_Australia_Ore_Layer( - "vein14", - 10, 20, - 8, - 3, - 16, - URNAIUM235, - PLUTONIUM, - OSMIUM, - AMETHYST); + static long ID = 0; - public static WorldGen_GT_Australia_Ore_Layer Vein15 = new WorldGen_GT_Australia_Ore_Layer( - "vein15", - 5, 25, - 5, - 6, - 24, - ORES.FLUORCAPHITE, - BISMUTH, - ORES.GADOLINITE_CE, - ORES.GADOLINITE_Y); + public static void generateValidOreVeins() { + validOreveins.put(ID++, BaseVein); - public static WorldGen_GT_Australia_Ore_Layer Vein16 = new WorldGen_GT_Australia_Ore_Layer( - "vein16", - 0, 25, - 4, - 6, - 32, - ORES.YTTROCERITE, - ORES.LEPERSONNITE, - INFUSEDGOLD, - FLUORIDES.FLUORITE); - - public static WorldGen_GT_Australia_Ore_Layer Vein17 = new WorldGen_GT_Australia_Ore_Layer( - "vein17", - 10, 35, - 4, - 5, - 32, - ORES.FLORENCITE, - URNAIUM235, - ORES.SAMARSKITE_YB, - ORES.POLYCRASE); - public static WorldGen_GT_Australia_Ore_Layer Vein18 = new WorldGen_GT_Australia_Ore_Layer( - "vein18", - 15, 40, - 4, - 4, - 64, - ORES.GADOLINITE_CE, - ORES.GADOLINITE_Y, - ORES.AGARDITE_LA, - ORES.AGARDITE_CD);*/ - - - - - public static Hashtable<Long, WorldGen_GT_Australia_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Australia_Ore_Layer>( - 1024); - + validOreveins.put(ID++, Vein1); + validOreveins.put(ID++, Vein2); + validOreveins.put(ID++, Vein3); + validOreveins.put(ID++, Vein4); + validOreveins.put(ID++, Vein5); + validOreveins.put(ID++, Vein6); + validOreveins.put(ID++, Vein7); + validOreveins.put(ID++, Vein8); - public static volatile BoxedQuad<Integer, Integer, Integer, Integer> OreVein1 = new BoxedQuad<Integer, Integer, Integer, Integer>(null, null, null, null); - - static long ID = 0; - public static void generateValidOreVeins(){ - validOreveins.put(ID++, BaseVein); - - validOreveins.put(ID++, Vein1); - validOreveins.put(ID++, Vein2); - validOreveins.put(ID++, Vein3); - validOreveins.put(ID++, Vein4); - validOreveins.put(ID++, Vein5); - validOreveins.put(ID++, Vein6); - validOreveins.put(ID++, Vein7); - validOreveins.put(ID++, Vein8); - - /*validOreveins.put(ID++, Vein9); - validOreveins.put(ID++, Vein10); - validOreveins.put(ID++, Vein11); - validOreveins.put(ID++, Vein12); - validOreveins.put(ID++, Vein13); - validOreveins.put(ID++, Vein14); - validOreveins.put(ID++, Vein15); - validOreveins.put(ID++, Vein16); - validOreveins.put(ID++, Vein17); - validOreveins.put(ID++, Vein18);*/ - } - + /*validOreveins.put(ID++, Vein9); + validOreveins.put(ID++, Vein10); + validOreveins.put(ID++, Vein11); + validOreveins.put(ID++, Vein12); + validOreveins.put(ID++, Vein13); + validOreveins.put(ID++, Vein14); + validOreveins.put(ID++, Vein15); + validOreveins.put(ID++, Vein16); + validOreveins.put(ID++, Vein17); + validOreveins.put(ID++, Vein18);*/ + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java index 93d5524a66..988e455aa7 100644 --- a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java +++ b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java @@ -1,48 +1,60 @@ package gtPlusPlus.australia.gen.gt; +import gtPlusPlus.australia.GTplusplus_Australia; import java.util.List; import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; - import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -import gtPlusPlus.australia.GTplusplus_Australia; public abstract class WorldGen_GT_Australia { - public final String mWorldGenName; - public final boolean mEnabled; - private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); - - public WorldGen_GT_Australia(String aName, List aList, boolean aDefault) { - this.mWorldGenName = aName; - this.mEnabled = GTplusplus_Australia.sCustomWorldgenFile.get("worldgen", this.mWorldGenName, aDefault); - if (this.mEnabled) { - aList.add(this); - } - - } - - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, - int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - return false; - } - - public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, - int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - return false; - } - - public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { - String aDimName = aWorld.provider.getDimensionName(); - Boolean tAllowed = (Boolean) this.mDimensionMap.get(aDimName); - if (tAllowed == null) { - boolean tValue = GTplusplus_Australia.sCustomWorldgenFile.get("worldgen.dimensions." + this.mWorldGenName, aDimName, - aDimensionType == aAllowedDimensionType); - this.mDimensionMap.put(aDimName, Boolean.valueOf(tValue)); - return tValue; - } else { - return tAllowed.booleanValue(); - } - } -}
\ No newline at end of file + public final String mWorldGenName; + public final boolean mEnabled; + private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); + + public WorldGen_GT_Australia(String aName, List aList, boolean aDefault) { + this.mWorldGenName = aName; + this.mEnabled = GTplusplus_Australia.sCustomWorldgenFile.get("worldgen", this.mWorldGenName, aDefault); + if (this.mEnabled) { + aList.add(this); + } + } + + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + return false; + } + + public boolean executeCavegen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + return false; + } + + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + String aDimName = aWorld.provider.getDimensionName(); + Boolean tAllowed = (Boolean) this.mDimensionMap.get(aDimName); + if (tAllowed == null) { + boolean tValue = GTplusplus_Australia.sCustomWorldgenFile.get( + "worldgen.dimensions." + this.mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); + this.mDimensionMap.put(aDimName, Boolean.valueOf(tValue)); + return tValue; + } else { + return tAllowed.booleanValue(); + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java index 917c1eb746..86a16d7569 100644 --- a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java +++ b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java @@ -1,471 +1,540 @@ package gtPlusPlus.australia.gen.gt; -import java.util.*; - import cpw.mods.fml.common.IWorldGenerator; - -import net.minecraft.block.Block; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.feature.WorldGenMinable; - import gregtech.api.util.GT_Log; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.australia.dimension.Dimension_Australia; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import java.util.*; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; public class WorldGen_GT_Australia_Base implements IWorldGenerator { - /** - * Class Variables - */ - - /** - * Control percentage of filled 3x3 chunks. Lower number means less oreveins - * spawn - */ - public static int oreveinPercentage; - /** - * Control number of attempts to find a valid orevein. Generally this - * maximum limit isn't hit, selecting a vein is cheap - */ - public static int oreveinAttempts; - /** - * Control number of attempts to place a valid orevein. If a vein wasn't - * placed due to height restrictions, completely in the water, etc, another - * attempt is tried. - */ - public static int oreveinMaxPlacementAttempts; - /** - * Debug parameter for world generation. Tracks chunks added/removed from - * run queue. - */ - public static boolean debugWorldGen = false; - /** - * Try re-implement Richard Hendrick's Chunk by Chunk Ore Generation from - * his GT5u fork. - */ - - public static List<Runnable> mList = new ArrayList<Runnable>(); - public static HashSet<Long> ProcChunks = new HashSet<Long>(); - // This is probably not going to work. Trying to create a fake orevein to - // put into hashtable when there will be no ores in a vein. - public static WorldGen_GT_Australia_Ore_Layer noOresInVein = new WorldGen_GT_Australia_Ore_Layer("vein0", 0, 255, 0, 0, - 0, ELEMENT.getInstance().IRON, ELEMENT.getInstance().GOLD, ELEMENT.getInstance().LEAD, ELEMENT.getInstance().TIN); - - public static Hashtable<Long, WorldGen_GT_Australia_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Australia_Ore_Layer>( - 1024); - - public boolean mIsGenerating = false; - public static final Object listLock = new Object(); - // private static boolean gcAsteroids = true; - - public WorldGen_GT_Australia_Base() { - if (debugWorldGen) { - GT_Log.out.println("GTPP_Worldgenerator created"); - } - } - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, - IChunkProvider chunkProvider) { - if (world.provider.dimensionId == Dimension_Australia.DIMID) { - generateSafely(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); - } - } - - public synchronized void generateSafely(Random random, int chunkX, int chunkZ, World world, - IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - int xDim = Dimension_Australia.DIMID; - switch (world.provider.dimensionId) { - case -1: // Nether - // generateNether(world, random, chunkX * 16, chunkZ * 16); - break; - case 0: // Overworld - // generateSurface(world, random, chunkX * 16, chunkZ * 16); - break; - case 1: // End - // generateEnd(world, random, chunkX * 16, chunkZ * 16); - break; - default: // Any other dimension - if (world.provider.dimensionId != xDim) { - break; - } - else { - generateEverglades(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); - break; - } - } - } - - private synchronized void generateEverglades(Random aRandom, int aX, int aZ, World aWorld, - IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - Logger.WARNING("Trying to Generate Dimension."); - synchronized (listLock) { - Logger.WARNING("Locked List addition."); - if (WorldGen_GT_Australia_Base.mList.add(new WorldGenContainer(new XSTR(Math.abs(aRandom.nextInt()) + 1), aX, aZ, - Dimension_Australia.DIMID, - aWorld, aChunkGenerator, aChunkProvider, - aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName))){ - Logger.WARNING("Locked List addition. Success."); - } - else { - Logger.WARNING("Locked List addition. Fail."); - } - if (debugWorldGen) - GT_Log.out.println("ADD WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId - + " chunk x:" + aX + " z:" + aZ + " SIZE: " + WorldGen_GT_Australia_Base.mList.size()); - } - - if (!this.mIsGenerating) { - Logger.WARNING("Is not generating."); - this.mIsGenerating = true; - Logger.WARNING("Setting Generation to true."); - int mList_sS = WorldGen_GT_Australia_Base.mList.size(); - mList_sS = Math.min(mList_sS, 3); // Run a maximum of 3 chunks at a - // time through worldgen. Extra - // chunks get done later. - for (int i = 0; i < mList_sS; i++) { - WorldGenContainer toRun = (WorldGenContainer) WorldGen_GT_Australia_Base.mList.get(0); - if (debugWorldGen) - GT_Log.out.println("RUN WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId - + " chunk x:" + toRun.mX + " z:" + toRun.mZ + " SIZE: " + WorldGen_GT_Australia_Base.mList.size() - + " i: " + i); - synchronized (listLock) { - Logger.WARNING("Locked List Removal."); - WorldGen_GT_Australia_Base.mList.remove(0); - } - toRun.run(); - } - this.mIsGenerating = false; - Logger.WARNING("Is Generating now set to false.."); - } - } - - public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, - int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn) { - int heightRange = maxY - minY; - WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn); - for (int k1 = 0; k1 < chancesToSpawn; ++k1) { - int xrand = random.nextInt(16); - int yrand = random.nextInt(heightRange) + minY; - int zrand = random.nextInt(16); - worldgenminable.generate(world, random, chunk_x + xrand, yrand, chunk_z + zrand); - } - } - - public static class WorldGenContainer implements Runnable { - public final Random mRandom; - public final int mX; - public final int mZ; - public final int mDimensionType; - public final World mWorld; - public final IChunkProvider mChunkGenerator; - public final IChunkProvider mChunkProvider; - public final String mBiome; - - // Local class to track which orevein seeds must be checked when doing - // chunkified worldgen - class NearbySeeds { - public int mX; - public int mZ; - - NearbySeeds(int x, int z) { - this.mX = x; - this.mZ = z; - } - }; - - public static ArrayList<NearbySeeds> seedList = new ArrayList<NearbySeeds>(); - - // aX and aZ are now the by-chunk X and Z for the chunk of interest - public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld, - IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome) { - this.mRandom = aRandom; - this.mX = aX; - this.mZ = aZ; - this.mDimensionType = aDimensionType; - this.mWorld = aWorld; - this.mChunkGenerator = aChunkGenerator; - this.mChunkProvider = aChunkProvider; - this.mBiome = aBiome; - } - - public void worldGenFindVein(int oreseedX, int oreseedZ) { - // Explanation of oreveinseed implementation. - // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen - // passes, one with getSeed set to +1 the original world seed. This - // pushes that +1 off the low bits of oreseedZ, so that the hashes - // are far apart for the two passes. - // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the - // dimension in the top bits of the hash, to make sure to get unique - // hashes per dimension - // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in - // the bits 29-55. Cuts off the top few bits of the chunk so we have - // bits for dimension. - // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the - // bits 0-27. Cuts off the top few bits of the chunk so we have bits - // for dimension. - long oreveinSeed = (this.mWorld.getSeed() << 16) ^ ((this.mWorld.provider.dimensionId & 0xffL) << 56 - | ((oreseedX & 0x000000000fffffffL) << 28) | (oreseedZ & 0x000000000fffffffL)); // Use - // an - // RNG - // that - // is - // identical - // every - // time - // it - // is - // called - // for - // this - // oreseed. - XSTR oreveinRNG = new XSTR(oreveinSeed); - int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the - // dice, see - // if we get - // an - // orevein - // here at - // all - int noOrePlacedCount = 0; - String tDimensionName = ""; - if (debugWorldGen) { - tDimensionName = this.mWorld.provider.getDimensionName(); - } - - if (debugWorldGen){ - GT_Log.out.println(" Finding oreveins for oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" - + this.mZ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " worldSeed=" - + this.mWorld.getSeed()); - } - - Logger.WARNING("[World Generation Debug] !validOreveins.containsKey(oreveinSeed) | oreveinSeed: "+oreveinSeed); - // Search for a valid orevein for this dimension - if (!validOreveins.containsKey(oreveinSeed)) { - - - Logger.WARNING("[World Generation Debug] oreveinPercentageRoll < oreveinPercentage? "+((oreveinPercentageRoll < oreveinPercentage))); - Logger.WARNING("[World Generation Debug] WorldGen_GT_Ore_Layer.sWeight > 0? "+(WorldGen_GT_Australia_Ore_Layer.sWeight > 0)); - Logger.WARNING("[World Generation Debug] WorldGen_GT_Ore_Layer.sList.size() > 0? "+(WorldGen_GT_Australia_Ore_Layer.sList.size() > 0)); - if ((oreveinPercentageRoll < oreveinPercentage) && (WorldGen_GT_Australia_Ore_Layer.sWeight > 0) - && (WorldGen_GT_Australia_Ore_Layer.sList.size() > 0)) { - int placementAttempts = 0; - boolean oreveinFound = false; - int i; - for (i = 0; (i < oreveinAttempts) && (!oreveinFound) - && (placementAttempts < oreveinMaxPlacementAttempts); i++) { - Logger.WARNING("[World Generation Debug] i: "+i); - Logger.WARNING("[World Generation Debug] placementAttempts: "+placementAttempts); - Logger.WARNING("[World Generation Debug] oreveinAttempts: "+oreveinAttempts); - Logger.WARNING("[World Generation Debug] (placementAttempts < oreveinMaxPlacementAttempts): "+(placementAttempts < oreveinMaxPlacementAttempts)); - Logger.WARNING("[World Generation Debug] oreveinFound: "+oreveinFound); - int tRandomWeight = oreveinRNG.nextInt(WorldGen_GT_Australia_Ore_Layer.sWeight); - for (WorldGen_GT_Australia_Ore_Layer tWorldGen : WorldGen_GT_Australia_Ore_Layer.sList) { - Logger.WARNING("[World Generation Debug] Iterating sList - Size: "+WorldGen_GT_Australia_Ore_Layer.sList.size()); - tRandomWeight -= (tWorldGen).mWeight; - if (tRandomWeight <= 0) { - try { - // Adjust the seed so that this layer has a - // series of unique random numbers. - // Otherwise multiple attempts at this same - // oreseed will get the same offset and X/Z - // values. If an orevein failed, any orevein - // with the - // same minimum heights would fail as well. - // This prevents that, giving each orevein a - // unique height each pass through here. - int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, - new XSTR(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))), this.mBiome, - this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16, - oreseedZ * 16, this.mChunkGenerator, this.mChunkProvider); - switch (placementResult) { - case WorldGen_GT_Australia_Ore_Layer.ORE_PLACED: - if (debugWorldGen) - GT_Log.out.println(" Added oreveinSeed=" + oreveinSeed - + " tries at oremix=" + i + " placementAttempts=" - + placementAttempts + " dimensionName=" + tDimensionName); - validOreveins.put(oreveinSeed, tWorldGen); - oreveinFound = true; - Logger.WARNING("[World Generation Debug] ORE_PLACED"); - break; - case WorldGen_GT_Australia_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: - placementAttempts++; - Logger.WARNING("[World Generation Debug] NO_ORE_IN_BOTTOM_LAYER | Attempts: "+placementAttempts); - // SHould do retry in this case - // until out of chances - break; - case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP: - // Orevein didn't reach this chunk, - // can't add it yet to the hash - Logger.WARNING("[World Generation Debug] NO_OVERLAP"); - if (debugWorldGen) GT_Log.out.println( - " Added far oreveinSeed=" + oreveinSeed + " " + - ( tWorldGen).mWorldGenName + - " tries at oremix=" + i + - " placementAttempts=" + placementAttempts + - " dimensionName=" + tDimensionName - ); - validOreveins.put(oreveinSeed, tWorldGen); - oreveinFound = true; - break; - case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP_AIR_BLOCK: - if (debugWorldGen) GT_Log.out.println( - " No overlap and air block in test spot=" + oreveinSeed + " " + - ( tWorldGen).mWorldGenName + - " tries at oremix=" + i + - " placementAttempts=" + placementAttempts + - " dimensionName=" + tDimensionName - ); - // SHould do retry in this case until out of chances - Logger.WARNING("[World Generation Debug] NO_OVERLAP_AIR_BLOCK"); - placementAttempts++; - break; - } - break; // Try the next orevein - } - catch (Throwable e) { - if (debugWorldGen) - GT_Log.out.println("Exception occurred on oreVein" + tWorldGen + " oreveinSeed=" - + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + " oreseedX=" - + oreseedX + " oreseedZ=" + oreseedZ); - e.printStackTrace(GT_Log.err); - } - } - } - } - // Only add an empty orevein if are unable to place a vein - // at the oreseed chunk. - if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)) { - if (debugWorldGen) - GT_Log.out.println(" Empty oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ - + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " tries at oremix=" + i - + " placementAttempts=" + placementAttempts + " dimensionName=" + tDimensionName); - validOreveins.put(oreveinSeed, noOresInVein); - } - } - else if (oreveinPercentageRoll >= oreveinPercentage) { - if (debugWorldGen) - GT_Log.out.println(" Skipped oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ - + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " RNG=" + oreveinPercentageRoll - + " %=" + oreveinPercentage + " dimensionName=" + tDimensionName); - validOreveins.put(oreveinSeed, noOresInVein); - } - } - else { - // oreseed is located in the previously processed table - if (debugWorldGen) - GT_Log.out.print(" Valid oreveinSeed=" + oreveinSeed + " validOreveins.size()=" - + validOreveins.size() + " "); - WorldGen_GT_Australia_Ore_Layer tWorldGen = validOreveins.get(oreveinSeed); - oreveinRNG.setSeed(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))); // Reset - // RNG - // to - // only - // be - // based - // on - // oreseed - // X/Z - // and - // type - // of - // vein - int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome, - this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16, oreseedZ * 16, - this.mChunkGenerator, this.mChunkProvider); - switch (placementResult) { - case WorldGen_GT_Australia_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: - if (debugWorldGen) - GT_Log.out.println(" No ore in bottom layer"); - break; - case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP: - if (debugWorldGen) - GT_Log.out.println(" No overlap"); - break; - } - } - } - - @Override - public void run() { - long startTime = System.nanoTime(); - int oreveinMaxSize; - - // Determine bounding box on how far out to check for oreveins - // affecting this chunk - // For now, manually reducing oreveinMaxSize when not in the - // Underdark for performance - if (this.mWorld.provider.getDimensionName().equals("Underdark")) { - oreveinMaxSize = 24; // Leave Deep Dark/Underdark max oregen at - // 32, instead of 64 - } - else { - oreveinMaxSize = 48; - } - - int wXbox = this.mX - (oreveinMaxSize / 16); - int eXbox = this.mX + (oreveinMaxSize / 16 + 1); // Need to add 1 - // since it is - // compared - // using a < - int nZbox = this.mZ - (oreveinMaxSize / 16); - int sZbox = this.mZ + (oreveinMaxSize / 16 + 1); - - // Search for orevein seeds and add to the list; - for (int x = wXbox; x < eXbox; x++) { - for (int z = nZbox; z < sZbox; z++) { - // Determine if this X/Z is an orevein seed - if (((Math.abs(x) % 3) == 1) && ((Math.abs(z) % 3) == 1)) { - if (debugWorldGen) - GT_Log.out.println("Adding seed x=" + x + " z=" + z); - seedList.add(new NearbySeeds(x, z)); - } - } - } - - // Now process each oreseed vs this requested chunk - for (; seedList.size() != 0; seedList.remove(0)) { - if (debugWorldGen) - GT_Log.out.println("Processing seed x=" + seedList.get(0).mX + " z=" + seedList.get(0).mZ); - worldGenFindVein(seedList.get(0).mX, seedList.get(0).mZ); - } - - long oregenTime = System.nanoTime(); - - // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores) - try { - for (WorldGen_GT_Australia tWorldGen : HANDLER_GT.sWorldgenListAustralia) { - /* - * if (debugWorldGen) GT_Log.out.println( - * "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName ); - */ - tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX * 16, - this.mZ * 16, this.mChunkGenerator, this.mChunkProvider); - } - } - catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - - long leftOverTime = System.nanoTime(); - - Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); - if (tChunk != null) { - tChunk.isModified = true; - } - long endTime = System.nanoTime(); - long duration = (endTime - startTime); - if (debugWorldGen) { - GT_Log.out.println(" Oregen took " + (oregenTime - startTime) + " Leftover gen took " - + (leftOverTime - oregenTime) + " Worldgen took " + duration + " nanoseconds"); - } - } - } - + /** + * Class Variables + */ + + /** + * Control percentage of filled 3x3 chunks. Lower number means less oreveins + * spawn + */ + public static int oreveinPercentage; + /** + * Control number of attempts to find a valid orevein. Generally this + * maximum limit isn't hit, selecting a vein is cheap + */ + public static int oreveinAttempts; + /** + * Control number of attempts to place a valid orevein. If a vein wasn't + * placed due to height restrictions, completely in the water, etc, another + * attempt is tried. + */ + public static int oreveinMaxPlacementAttempts; + /** + * Debug parameter for world generation. Tracks chunks added/removed from + * run queue. + */ + public static boolean debugWorldGen = false; + /** + * Try re-implement Richard Hendrick's Chunk by Chunk Ore Generation from + * his GT5u fork. + */ + public static List<Runnable> mList = new ArrayList<Runnable>(); + + public static HashSet<Long> ProcChunks = new HashSet<Long>(); + // This is probably not going to work. Trying to create a fake orevein to + // put into hashtable when there will be no ores in a vein. + public static WorldGen_GT_Australia_Ore_Layer noOresInVein = new WorldGen_GT_Australia_Ore_Layer( + "vein0", + 0, + 255, + 0, + 0, + 0, + ELEMENT.getInstance().IRON, + ELEMENT.getInstance().GOLD, + ELEMENT.getInstance().LEAD, + ELEMENT.getInstance().TIN); + + public static Hashtable<Long, WorldGen_GT_Australia_Ore_Layer> validOreveins = + new Hashtable<Long, WorldGen_GT_Australia_Ore_Layer>(1024); + + public boolean mIsGenerating = false; + public static final Object listLock = new Object(); + // private static boolean gcAsteroids = true; + + public WorldGen_GT_Australia_Base() { + if (debugWorldGen) { + GT_Log.out.println("GTPP_Worldgenerator created"); + } + } + + @Override + public void generate( + Random random, + int chunkX, + int chunkZ, + World world, + IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + if (world.provider.dimensionId == Dimension_Australia.DIMID) { + generateSafely(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); + } + } + + public synchronized void generateSafely( + Random random, + int chunkX, + int chunkZ, + World world, + IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + int xDim = Dimension_Australia.DIMID; + switch (world.provider.dimensionId) { + case -1: // Nether + // generateNether(world, random, chunkX * 16, chunkZ * 16); + break; + case 0: // Overworld + // generateSurface(world, random, chunkX * 16, chunkZ * 16); + break; + case 1: // End + // generateEnd(world, random, chunkX * 16, chunkZ * 16); + break; + default: // Any other dimension + if (world.provider.dimensionId != xDim) { + break; + } else { + generateEverglades(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); + break; + } + } + } + + private synchronized void generateEverglades( + Random aRandom, + int aX, + int aZ, + World aWorld, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + Logger.WARNING("Trying to Generate Dimension."); + synchronized (listLock) { + Logger.WARNING("Locked List addition."); + if (WorldGen_GT_Australia_Base.mList.add(new WorldGenContainer( + new XSTR(Math.abs(aRandom.nextInt()) + 1), + aX, + aZ, + Dimension_Australia.DIMID, + aWorld, + aChunkGenerator, + aChunkProvider, + aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName))) { + Logger.WARNING("Locked List addition. Success."); + } else { + Logger.WARNING("Locked List addition. Fail."); + } + if (debugWorldGen) + GT_Log.out.println("ADD WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId + + " chunk x:" + aX + " z:" + aZ + " SIZE: " + WorldGen_GT_Australia_Base.mList.size()); + } + + if (!this.mIsGenerating) { + Logger.WARNING("Is not generating."); + this.mIsGenerating = true; + Logger.WARNING("Setting Generation to true."); + int mList_sS = WorldGen_GT_Australia_Base.mList.size(); + mList_sS = Math.min(mList_sS, 3); // Run a maximum of 3 chunks at a + // time through worldgen. Extra + // chunks get done later. + for (int i = 0; i < mList_sS; i++) { + WorldGenContainer toRun = (WorldGenContainer) WorldGen_GT_Australia_Base.mList.get(0); + if (debugWorldGen) + GT_Log.out.println("RUN WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId + + " chunk x:" + toRun.mX + " z:" + toRun.mZ + " SIZE: " + + WorldGen_GT_Australia_Base.mList.size() + + " i: " + i); + synchronized (listLock) { + Logger.WARNING("Locked List Removal."); + WorldGen_GT_Australia_Base.mList.remove(0); + } + toRun.run(); + } + this.mIsGenerating = false; + Logger.WARNING("Is Generating now set to false.."); + } + } + + public void generateOre( + Block block, + World world, + Random random, + int chunk_x, + int chunk_z, + int maxX, + int maxZ, + int maxVeinSize, + int chancesToSpawn, + int minY, + int maxY, + Block generateIn) { + int heightRange = maxY - minY; + WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn); + for (int k1 = 0; k1 < chancesToSpawn; ++k1) { + int xrand = random.nextInt(16); + int yrand = random.nextInt(heightRange) + minY; + int zrand = random.nextInt(16); + worldgenminable.generate(world, random, chunk_x + xrand, yrand, chunk_z + zrand); + } + } + + public static class WorldGenContainer implements Runnable { + public final Random mRandom; + public final int mX; + public final int mZ; + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public final String mBiome; + + // Local class to track which orevein seeds must be checked when doing + // chunkified worldgen + class NearbySeeds { + public int mX; + public int mZ; + + NearbySeeds(int x, int z) { + this.mX = x; + this.mZ = z; + } + } + ; + + public static ArrayList<NearbySeeds> seedList = new ArrayList<NearbySeeds>(); + + // aX and aZ are now the by-chunk X and Z for the chunk of interest + public WorldGenContainer( + Random aRandom, + int aX, + int aZ, + int aDimensionType, + World aWorld, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider, + String aBiome) { + this.mRandom = aRandom; + this.mX = aX; + this.mZ = aZ; + this.mDimensionType = aDimensionType; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + this.mBiome = aBiome; + } + + public void worldGenFindVein(int oreseedX, int oreseedZ) { + // Explanation of oreveinseed implementation. + // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen + // passes, one with getSeed set to +1 the original world seed. This + // pushes that +1 off the low bits of oreseedZ, so that the hashes + // are far apart for the two passes. + // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the + // dimension in the top bits of the hash, to make sure to get unique + // hashes per dimension + // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in + // the bits 29-55. Cuts off the top few bits of the chunk so we have + // bits for dimension. + // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the + // bits 0-27. Cuts off the top few bits of the chunk so we have bits + // for dimension. + long oreveinSeed = (this.mWorld.getSeed() << 16) + ^ ((this.mWorld.provider.dimensionId & 0xffL) << 56 + | ((oreseedX & 0x000000000fffffffL) << 28) + | (oreseedZ & 0x000000000fffffffL)); // Use + // an + // RNG + // that + // is + // identical + // every + // time + // it + // is + // called + // for + // this + // oreseed. + XSTR oreveinRNG = new XSTR(oreveinSeed); + int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the + // dice, see + // if we get + // an + // orevein + // here at + // all + int noOrePlacedCount = 0; + String tDimensionName = ""; + if (debugWorldGen) { + tDimensionName = this.mWorld.provider.getDimensionName(); + } + + if (debugWorldGen) { + GT_Log.out.println(" Finding oreveins for oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + + this.mZ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " worldSeed=" + + this.mWorld.getSeed()); + } + + Logger.WARNING( + "[World Generation Debug] !validOreveins.containsKey(oreveinSeed) | oreveinSeed: " + oreveinSeed); + // Search for a valid orevein for this dimension + if (!validOreveins.containsKey(oreveinSeed)) { + + Logger.WARNING("[World Generation Debug] oreveinPercentageRoll < oreveinPercentage? " + + ((oreveinPercentageRoll < oreveinPercentage))); + Logger.WARNING("[World Generation Debug] WorldGen_GT_Ore_Layer.sWeight > 0? " + + (WorldGen_GT_Australia_Ore_Layer.sWeight > 0)); + Logger.WARNING("[World Generation Debug] WorldGen_GT_Ore_Layer.sList.size() > 0? " + + (WorldGen_GT_Australia_Ore_Layer.sList.size() > 0)); + if ((oreveinPercentageRoll < oreveinPercentage) + && (WorldGen_GT_Australia_Ore_Layer.sWeight > 0) + && (WorldGen_GT_Australia_Ore_Layer.sList.size() > 0)) { + int placementAttempts = 0; + boolean oreveinFound = false; + int i; + for (i = 0; + (i < oreveinAttempts) + && (!oreveinFound) + && (placementAttempts < oreveinMaxPlacementAttempts); + i++) { + Logger.WARNING("[World Generation Debug] i: " + i); + Logger.WARNING("[World Generation Debug] placementAttempts: " + placementAttempts); + Logger.WARNING("[World Generation Debug] oreveinAttempts: " + oreveinAttempts); + Logger.WARNING("[World Generation Debug] (placementAttempts < oreveinMaxPlacementAttempts): " + + (placementAttempts < oreveinMaxPlacementAttempts)); + Logger.WARNING("[World Generation Debug] oreveinFound: " + oreveinFound); + int tRandomWeight = oreveinRNG.nextInt(WorldGen_GT_Australia_Ore_Layer.sWeight); + for (WorldGen_GT_Australia_Ore_Layer tWorldGen : WorldGen_GT_Australia_Ore_Layer.sList) { + Logger.WARNING("[World Generation Debug] Iterating sList - Size: " + + WorldGen_GT_Australia_Ore_Layer.sList.size()); + tRandomWeight -= (tWorldGen).mWeight; + if (tRandomWeight <= 0) { + try { + // Adjust the seed so that this layer has a + // series of unique random numbers. + // Otherwise multiple attempts at this same + // oreseed will get the same offset and X/Z + // values. If an orevein failed, any orevein + // with the + // same minimum heights would fail as well. + // This prevents that, giving each orevein a + // unique height each pass through here. + int placementResult = tWorldGen.executeWorldgenChunkified( + this.mWorld, + new XSTR(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))), + this.mBiome, + this.mDimensionType, + this.mX * 16, + this.mZ * 16, + oreseedX * 16, + oreseedZ * 16, + this.mChunkGenerator, + this.mChunkProvider); + switch (placementResult) { + case WorldGen_GT_Australia_Ore_Layer.ORE_PLACED: + if (debugWorldGen) + GT_Log.out.println(" Added oreveinSeed=" + oreveinSeed + + " tries at oremix=" + i + " placementAttempts=" + + placementAttempts + " dimensionName=" + tDimensionName); + validOreveins.put(oreveinSeed, tWorldGen); + oreveinFound = true; + Logger.WARNING("[World Generation Debug] ORE_PLACED"); + break; + case WorldGen_GT_Australia_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: + placementAttempts++; + Logger.WARNING( + "[World Generation Debug] NO_ORE_IN_BOTTOM_LAYER | Attempts: " + + placementAttempts); + // SHould do retry in this case + // until out of chances + break; + case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP: + // Orevein didn't reach this chunk, + // can't add it yet to the hash + Logger.WARNING("[World Generation Debug] NO_OVERLAP"); + if (debugWorldGen) + GT_Log.out.println(" Added far oreveinSeed=" + oreveinSeed + " " + + (tWorldGen).mWorldGenName + + " tries at oremix=" + + i + " placementAttempts=" + + placementAttempts + " dimensionName=" + + tDimensionName); + validOreveins.put(oreveinSeed, tWorldGen); + oreveinFound = true; + break; + case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP_AIR_BLOCK: + if (debugWorldGen) + GT_Log.out.println(" No overlap and air block in test spot=" + + oreveinSeed + " " + (tWorldGen).mWorldGenName + + " tries at oremix=" + + i + " placementAttempts=" + + placementAttempts + " dimensionName=" + + tDimensionName); + // SHould do retry in this case until out of chances + Logger.WARNING("[World Generation Debug] NO_OVERLAP_AIR_BLOCK"); + placementAttempts++; + break; + } + break; // Try the next orevein + } catch (Throwable e) { + if (debugWorldGen) + GT_Log.out.println("Exception occurred on oreVein" + tWorldGen + " oreveinSeed=" + + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + " oreseedX=" + + oreseedX + " oreseedZ=" + oreseedZ); + e.printStackTrace(GT_Log.err); + } + } + } + } + // Only add an empty orevein if are unable to place a vein + // at the oreseed chunk. + if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)) { + if (debugWorldGen) + GT_Log.out.println(" Empty oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " tries at oremix=" + i + + " placementAttempts=" + placementAttempts + " dimensionName=" + tDimensionName); + validOreveins.put(oreveinSeed, noOresInVein); + } + } else if (oreveinPercentageRoll >= oreveinPercentage) { + if (debugWorldGen) + GT_Log.out.println(" Skipped oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " RNG=" + oreveinPercentageRoll + + " %=" + oreveinPercentage + " dimensionName=" + tDimensionName); + validOreveins.put(oreveinSeed, noOresInVein); + } + } else { + // oreseed is located in the previously processed table + if (debugWorldGen) + GT_Log.out.print(" Valid oreveinSeed=" + oreveinSeed + " validOreveins.size()=" + + validOreveins.size() + " "); + WorldGen_GT_Australia_Ore_Layer tWorldGen = validOreveins.get(oreveinSeed); + oreveinRNG.setSeed(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))); // Reset + // RNG + // to + // only + // be + // based + // on + // oreseed + // X/Z + // and + // type + // of + // vein + int placementResult = tWorldGen.executeWorldgenChunkified( + this.mWorld, + oreveinRNG, + this.mBiome, + this.mDimensionType, + this.mX * 16, + this.mZ * 16, + oreseedX * 16, + oreseedZ * 16, + this.mChunkGenerator, + this.mChunkProvider); + switch (placementResult) { + case WorldGen_GT_Australia_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: + if (debugWorldGen) GT_Log.out.println(" No ore in bottom layer"); + break; + case WorldGen_GT_Australia_Ore_Layer.NO_OVERLAP: + if (debugWorldGen) GT_Log.out.println(" No overlap"); + break; + } + } + } + + @Override + public void run() { + long startTime = System.nanoTime(); + int oreveinMaxSize; + + // Determine bounding box on how far out to check for oreveins + // affecting this chunk + // For now, manually reducing oreveinMaxSize when not in the + // Underdark for performance + if (this.mWorld.provider.getDimensionName().equals("Underdark")) { + oreveinMaxSize = 24; // Leave Deep Dark/Underdark max oregen at + // 32, instead of 64 + } else { + oreveinMaxSize = 48; + } + + int wXbox = this.mX - (oreveinMaxSize / 16); + int eXbox = this.mX + (oreveinMaxSize / 16 + 1); // Need to add 1 + // since it is + // compared + // using a < + int nZbox = this.mZ - (oreveinMaxSize / 16); + int sZbox = this.mZ + (oreveinMaxSize / 16 + 1); + + // Search for orevein seeds and add to the list; + for (int x = wXbox; x < eXbox; x++) { + for (int z = nZbox; z < sZbox; z++) { + // Determine if this X/Z is an orevein seed + if (((Math.abs(x) % 3) == 1) && ((Math.abs(z) % 3) == 1)) { + if (debugWorldGen) GT_Log.out.println("Adding seed x=" + x + " z=" + z); + seedList.add(new NearbySeeds(x, z)); + } + } + } + + // Now process each oreseed vs this requested chunk + for (; seedList.size() != 0; seedList.remove(0)) { + if (debugWorldGen) + GT_Log.out.println("Processing seed x=" + seedList.get(0).mX + " z=" + seedList.get(0).mZ); + worldGenFindVein(seedList.get(0).mX, seedList.get(0).mZ); + } + + long oregenTime = System.nanoTime(); + + // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores) + try { + for (WorldGen_GT_Australia tWorldGen : HANDLER_GT.sWorldgenListAustralia) { + /* + * if (debugWorldGen) GT_Log.out.println( + * "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName ); + */ + tWorldGen.executeWorldgen( + this.mWorld, + this.mRandom, + this.mBiome, + this.mDimensionType, + this.mX * 16, + this.mZ * 16, + this.mChunkGenerator, + this.mChunkProvider); + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + + long leftOverTime = System.nanoTime(); + + Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + long endTime = System.nanoTime(); + long duration = (endTime - startTime); + if (debugWorldGen) { + GT_Log.out.println(" Oregen took " + (oregenTime - startTime) + " Leftover gen took " + + (leftOverTime - oregenTime) + " Worldgen took " + duration + " nanoseconds"); + } + } + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java index a5e5f8b245..f88cd0edbe 100644 --- a/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java +++ b/src/main/java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java @@ -2,23 +2,11 @@ package gtPlusPlus.australia.gen.gt; import static gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia_Base.debugWorldGen; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; import gregtech.common.blocks.GT_Block_Ores; import gregtech.common.blocks.GT_TileEntity_Ores; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.australia.GTplusplus_Australia; import gtPlusPlus.australia.dimension.Dimension_Australia; @@ -26,486 +14,602 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; -public class WorldGen_GT_Australia_Ore_Layer -extends WorldGen_GT_Australia { - public static ArrayList<WorldGen_GT_Australia_Ore_Layer> sList = new ArrayList<WorldGen_GT_Australia_Ore_Layer>(); - public static int sWeight = 0; - public final short mMinY; - public final short mMaxY; - public final short mWeight; - public final short mDensity; - public final short mSize; - public Block mPrimaryMeta; - public Block mSecondaryMeta; - public Block mBetweenMeta; - public Block mSporadicMeta; - public final Material mPrimary; - public final Material mSecondary; - public final Material mBetween; - public final Material mSporadic; - - public static boolean mUpdated = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; - public static final Block mStoneTypes; - - //public final String mBiome; - public final String mRestrictBiome; - public final boolean mOverworld; - public final boolean mNether; - public final boolean mEnd; - public static final int WRONG_BIOME=0; - public static final int WRONG_DIMENSION=1; - public static final int NO_ORE_IN_BOTTOM_LAYER=2; - public static final int NO_OVERLAP=3; - public static final int ORE_PLACED=4; - public static final int NO_OVERLAP_AIR_BLOCK=5; - - //public final boolean mMoon; - //public final boolean mMars; - //public final boolean mAsteroid; - public final String aTextWorldgen = "worldgen."; - - static { - if (mUpdated) { - Object tempBlock = null; - try { - Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); - tempBlock = temp.get(null); - } - catch (IllegalArgumentException | IllegalAccessException e) {} - mStoneTypes = (Block) tempBlock; - } - else { - mStoneTypes = null; - } - } - - - public WorldGen_GT_Australia_Ore_Layer(String aName, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) { - this(aName, true, aMinY, aMaxY, aWeight, aDensity, aSize, false, false, false, false, false, false, aPrimary, aSecondary, aBetween, aSporadic); - } - - - public WorldGen_GT_Australia_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, boolean aNether, boolean aEnd, boolean GC_UNUSED1, boolean GC_UNUSED2, boolean GC_UNUSED3, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) { - super(aName, sList, aDefault); - Logger.WARNING("Creating Ore Layer Object"); - this.mOverworld = GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); - this.mNether = GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); - this.mEnd = GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); - //this.mMoon = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); - //this.mMars = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); - //this.mAsteroid = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); - this.mMinY = 5; - short mMaxY = 14; - if (mMaxY < (this.mMinY + 7)) { - GT_Log.out.println( - "Oremix " + this.mWorldGenName + - " has invalid Min/Max heights!" - ); - mMaxY = (short) (this.mMinY + 7); - } - this.mMaxY = mMaxY; - this.mWeight = ((short) GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - this.mPrimary = aPrimary; - this.mSecondary = aSecondary; - this.mBetween = aBetween; - this.mSporadic = aSporadic; - this.mPrimaryMeta = aPrimary.getOreBlock(1); - this.mSecondaryMeta = aSecondary.getOreBlock(1); - this.mBetweenMeta = aBetween.getOreBlock(1); - this.mSporadicMeta = aSporadic.getOreBlock(1); - this.mRestrictBiome = GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); - - //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mPrimaryMeta + " for " + mWorldGenName + " does not exist"); - //if (mSecondaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSecondaryMeta + " for " + mWorldGenName + " does not exist"); - //if (mBetweenMeta != -1 && GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mBetweenMeta + " for " + mWorldGenName + " does not exist"); - //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSporadicMeta + " for " + mWorldGenName + " does not exist"); - - if (this.mEnabled) { - //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - sWeight += this.mWeight; - } - } - - public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - - //Debug Handler - /** - * This handles Variables that are null during Init - */ - - if (this.mPrimaryMeta == Blocks.stone || this.mSecondaryMeta == Blocks.stone - || this.mBetweenMeta == Blocks.stone || this.mSporadicMeta == Blocks.stone){ - this.mPrimaryMeta = this.mPrimary.getOreBlock(1); - this.mSecondaryMeta = this.mSecondary.getOreBlock(1); - this.mBetweenMeta = this.mBetween.getOreBlock(1); - this.mSporadicMeta = this.mSporadic.getOreBlock(1); - Logger.WARNING("[Vein Generator] An Ore in a Vein had defaulted back to a default value, so they have now been reset to correct values."); - } - - if( mWorldGenName.equals("vein0") ) { - if (debugWorldGen) GT_Log.out.println( - " NoOresInVein-vein0" - ); - // This is a special empty orevein - Logger.WARNING("[World Generation Debug] Special Empty Vein placed."); - return ORE_PLACED; - } - if (aDimensionType != Dimension_Australia.DIMID) { - /* // Debug code, but spams log - if (debugWorldGen) { - GT_Log.out.println( - "Wrong dimension" - ); +public class WorldGen_GT_Australia_Ore_Layer extends WorldGen_GT_Australia { + public static ArrayList<WorldGen_GT_Australia_Ore_Layer> sList = new ArrayList<WorldGen_GT_Australia_Ore_Layer>(); + public static int sWeight = 0; + public final short mMinY; + public final short mMaxY; + public final short mWeight; + public final short mDensity; + public final short mSize; + public Block mPrimaryMeta; + public Block mSecondaryMeta; + public Block mBetweenMeta; + public Block mSporadicMeta; + public final Material mPrimary; + public final Material mSecondary; + public final Material mBetween; + public final Material mSporadic; + + public static boolean mUpdated = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; + public static final Block mStoneTypes; + + // public final String mBiome; + public final String mRestrictBiome; + public final boolean mOverworld; + public final boolean mNether; + public final boolean mEnd; + public static final int WRONG_BIOME = 0; + public static final int WRONG_DIMENSION = 1; + public static final int NO_ORE_IN_BOTTOM_LAYER = 2; + public static final int NO_OVERLAP = 3; + public static final int ORE_PLACED = 4; + public static final int NO_OVERLAP_AIR_BLOCK = 5; + + // public final boolean mMoon; + // public final boolean mMars; + // public final boolean mAsteroid; + public final String aTextWorldgen = "worldgen."; + + static { + if (mUpdated) { + Object tempBlock = null; + try { + Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); + tempBlock = temp.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } - */ - Logger.WARNING("[World Generation Debug] Wrong dimension."); - return WRONG_DIMENSION; - } - if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { - return WRONG_BIOME; - } - int[] placeCount=new int[4]; - - int tMinY = mMinY + aRandom.nextInt(mMaxY - mMinY - 5); - // Determine West/East ends of orevein - int wXVein = aSeedX - aRandom.nextInt(mSize); // West side - int eXVein = aSeedX + 16 + aRandom.nextInt(mSize); - // Limit Orevein to only blocks present in current chunk - int wX = Math.max( wXVein, aChunkX + 2); // Bias placement by 2 blocks to prevent worldgen cascade. - int eX = Math.min( eXVein, aChunkX + 2 + 16); - if (wX >= eX) { //No overlap between orevein and this chunk exists in X - Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8); - if (tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.stone) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.netherrack) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.end_stone) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) || - (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, mStoneTypes)) ) { - // Didn't reach, but could have placed. Save orevein for future use. - return NO_OVERLAP; - } else { - // Didn't reach, but couldn't place in test spot anywys, try for another orevein - return NO_OVERLAP_AIR_BLOCK; - } - } - // Determine North/Sound ends of orevein - int nZVein = aSeedZ - aRandom.nextInt(mSize); - int sZVein = aSeedZ + 16 + aRandom.nextInt(mSize); - - int nZ = Math.max(nZVein, aChunkZ + 2); // Bias placement by 2 blocks to prevent worldgen cascade. - int sZ = Math.min(sZVein, aChunkZ + 2 + 16); - if (nZ >= sZ) { //No overlap between orevein and this chunk exists in Z - Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8); - if (tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.stone) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.netherrack) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.end_stone) || - tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) || - (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, mStoneTypes)) ) { - // Didn't reach, but could have placed. Save orevein for future use. - return NO_OVERLAP; - } else { - // Didn't reach, but couldn't place in test spot anywys, try for another orevein - return NO_OVERLAP_AIR_BLOCK; - } - - } - - if (debugWorldGen) { - String tDimensionName = aWorld.provider.getDimensionName(); - GT_Log.out.print( - "Trying Orevein:" + this.mWorldGenName + - " Dimension=" + tDimensionName + - " mX="+aChunkX/16+ - " mZ="+aChunkZ/16+ - " oreseedX="+ aSeedX/16 + - " oreseedZ="+ aSeedZ/16 + - " cY="+tMinY - ); - } - // Adjust the density down the more chunks we are away from the oreseed. The 5 chunks surrounding the seed should always be max density due to truncation of Math.sqrt(). - int localDensity = (Math.max(1, this.mDensity / ((int)Math.sqrt(2 + Math.pow(aChunkX/16 - aSeedX/16, 2) + Math.pow(aChunkZ/16 - aSeedZ/16, 2))))); - - // To allow for early exit due to no ore placed in the bottom layer (probably because we are in the sky), unroll 1 pass through the loop - // Now we do bottom-level-first oregen, and work our way upwards. - int level = tMinY - 1; //Dunno why, but the first layer is actually played one below tMinY. Go figure. - for (int tX = wX; tX < eX; tX++) { - int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); - for (int tZ = nZ; tZ < sZ; tZ++) { - int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) { - if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { - placeCount[1]++; - } - } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - /*if ((placeCount[1]+placeCount[3])==0) { + mStoneTypes = (Block) tempBlock; + } else { + mStoneTypes = null; + } + } + + public WorldGen_GT_Australia_Ore_Layer( + String aName, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + this( + aName, + true, + aMinY, + aMaxY, + aWeight, + aDensity, + aSize, + false, + false, + false, + false, + false, + false, + aPrimary, + aSecondary, + aBetween, + aSporadic); + } + + public WorldGen_GT_Australia_Ore_Layer( + String aName, + boolean aDefault, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + boolean aOverworld, + boolean aNether, + boolean aEnd, + boolean GC_UNUSED1, + boolean GC_UNUSED2, + boolean GC_UNUSED3, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + super(aName, sList, aDefault); + Logger.WARNING("Creating Ore Layer Object"); + this.mOverworld = GTplusplus_Australia.sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mNether = + GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); + this.mEnd = GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); + // this.mMoon = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); + // this.mMars = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); + // this.mAsteroid = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", + // aAsteroid); + this.mMinY = 5; + short mMaxY = 14; + if (mMaxY < (this.mMinY + 7)) { + GT_Log.out.println("Oremix " + this.mWorldGenName + " has invalid Min/Max heights!"); + mMaxY = (short) (this.mMinY + 7); + } + this.mMaxY = mMaxY; + this.mWeight = ((short) GTplusplus_Australia.sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) + GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max( + 1, GTplusplus_Australia.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimary = aPrimary; + this.mSecondary = aSecondary; + this.mBetween = aBetween; + this.mSporadic = aSporadic; + this.mPrimaryMeta = aPrimary.getOreBlock(1); + this.mSecondaryMeta = aSecondary.getOreBlock(1); + this.mBetweenMeta = aBetween.getOreBlock(1); + this.mSporadicMeta = aSporadic.getOreBlock(1); + this.mRestrictBiome = GTplusplus_Australia.sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + + // if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)] == null) throw new + // IllegalArgumentException("A Material for the supplied ID " + mPrimaryMeta + " for " + mWorldGenName + " does + // not exist"); + // if (mSecondaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)] == null) throw new + // IllegalArgumentException("A Material for the supplied ID " + mSecondaryMeta + " for " + mWorldGenName + " + // does not exist"); + // if (mBetweenMeta != -1 && GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)] == null) throw new + // IllegalArgumentException("A Material for the supplied ID " + mBetweenMeta + " for " + mWorldGenName + " does + // not exist"); + // if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)] == null) throw new + // IllegalArgumentException("A Material for the supplied ID " + mSporadicMeta + " for " + mWorldGenName + " does + // not exist"); + + if (this.mEnabled) { + // GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, + // aWeight, aOverworld, aNether, aEnd); + // GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, + // aWeight, aOverworld, aNether, aEnd); + // GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, + // aWeight, aOverworld, aNether, aEnd); + // GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, + // aWeight, aOverworld, aNether, aEnd); + sWeight += this.mWeight; + } + } + + public int executeWorldgenChunkified( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + int aSeedX, + int aSeedZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + + // Debug Handler + /** + * This handles Variables that are null during Init + */ + if (this.mPrimaryMeta == Blocks.stone + || this.mSecondaryMeta == Blocks.stone + || this.mBetweenMeta == Blocks.stone + || this.mSporadicMeta == Blocks.stone) { + this.mPrimaryMeta = this.mPrimary.getOreBlock(1); + this.mSecondaryMeta = this.mSecondary.getOreBlock(1); + this.mBetweenMeta = this.mBetween.getOreBlock(1); + this.mSporadicMeta = this.mSporadic.getOreBlock(1); + Logger.WARNING( + "[Vein Generator] An Ore in a Vein had defaulted back to a default value, so they have now been reset to correct values."); + } + + if (mWorldGenName.equals("vein0")) { + if (debugWorldGen) GT_Log.out.println(" NoOresInVein-vein0"); + // This is a special empty orevein + Logger.WARNING("[World Generation Debug] Special Empty Vein placed."); + return ORE_PLACED; + } + if (aDimensionType != Dimension_Australia.DIMID) { + /* // Debug code, but spams log + if (debugWorldGen) { + GT_Log.out.println( + "Wrong dimension" + ); + } + */ + Logger.WARNING("[World Generation Debug] Wrong dimension."); + return WRONG_DIMENSION; + } + if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { + return WRONG_BIOME; + } + int[] placeCount = new int[4]; + + int tMinY = mMinY + aRandom.nextInt(mMaxY - mMinY - 5); + // Determine West/East ends of orevein + int wXVein = aSeedX - aRandom.nextInt(mSize); // West side + int eXVein = aSeedX + 16 + aRandom.nextInt(mSize); + // Limit Orevein to only blocks present in current chunk + int wX = Math.max(wXVein, aChunkX + 2); // Bias placement by 2 blocks to prevent worldgen cascade. + int eX = Math.min(eXVein, aChunkX + 2 + 16); + if (wX >= eX) { // No overlap between orevein and this chunk exists in X + Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8); + if (tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.stone) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.netherrack) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.end_stone) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) + || (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, mStoneTypes))) { + // Didn't reach, but could have placed. Save orevein for future use. + return NO_OVERLAP; + } else { + // Didn't reach, but couldn't place in test spot anywys, try for another orevein + return NO_OVERLAP_AIR_BLOCK; + } + } + // Determine North/Sound ends of orevein + int nZVein = aSeedZ - aRandom.nextInt(mSize); + int sZVein = aSeedZ + 16 + aRandom.nextInt(mSize); + + int nZ = Math.max(nZVein, aChunkZ + 2); // Bias placement by 2 blocks to prevent worldgen cascade. + int sZ = Math.min(sZVein, aChunkZ + 2 + 16); + if (nZ >= sZ) { // No overlap between orevein and this chunk exists in Z + Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8); + if (tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.stone) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.netherrack) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, Blocks.end_stone) + || tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) + || (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX + 8, tMinY, aChunkZ + 8, mStoneTypes))) { + // Didn't reach, but could have placed. Save orevein for future use. + return NO_OVERLAP; + } else { + // Didn't reach, but couldn't place in test spot anywys, try for another orevein + return NO_OVERLAP_AIR_BLOCK; + } + } + + if (debugWorldGen) { + String tDimensionName = aWorld.provider.getDimensionName(); + GT_Log.out.print("Trying Orevein:" + this.mWorldGenName + " Dimension=" + + tDimensionName + " mX=" + + aChunkX / 16 + " mZ=" + + aChunkZ / 16 + " oreseedX=" + + aSeedX / 16 + " oreseedZ=" + + aSeedZ / 16 + " cY=" + + tMinY); + } + // Adjust the density down the more chunks we are away from the oreseed. The 5 chunks surrounding the seed + // should always be max density due to truncation of Math.sqrt(). + int localDensity = (Math.max( + 1, + this.mDensity + / ((int) Math.sqrt(2 + + Math.pow(aChunkX / 16 - aSeedX / 16, 2) + + Math.pow(aChunkZ / 16 - aSeedZ / 16, 2))))); + + // To allow for early exit due to no ore placed in the bottom layer (probably because we are in the sky), unroll + // 1 pass through the loop + // Now we do bottom-level-first oregen, and work our way upwards. + int level = tMinY - 1; // Dunno why, but the first layer is actually played one below tMinY. Go figure. + for (int tX = wX; tX < eX; tX++) { + int placeX = Math.max( + 1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX)) / localDensity); + for (int tZ = nZ; tZ < sZ; tZ++) { + int placeZ = Math.max( + 1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ)) / localDensity); + if (((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSecondaryMeta != null)) { + if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { + placeCount[1]++; + } + } else if ((aRandom.nextInt(7) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSporadicMeta + != null)) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to + // compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; + } + } + } + /*if ((placeCount[1]+placeCount[3])==0) { if (debugWorldGen) GT_Log.out.println( " No ore in bottom layer" ); return NO_ORE_IN_BOTTOM_LAYER; // Exit early, didn't place anything in the bottom layer }*/ - Logger.WARNING("[World Generation Debug] Trying to set Ores?"); - for (level = tMinY; level < (tMinY-1+3); level++) { - for (int tX = wX; tX < eX; tX++) { - int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); - for (int tZ = nZ; tZ < sZ; tZ++) { - int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) { - if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { - placeCount[1]++; - } - } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - } - // Low Middle layer is between + sporadic - // level should be = tMinY-1+3 from end of for loop - for (int tX = wX; tX < eX; tX++) { - int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); - for (int tZ = nZ; tZ < sZ; tZ++) { - int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { - placeCount[2]++; - } - } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - // High Middle layer is between + primary + sporadic - level++; // Increment level to next layer - for (int tX = wX; tX < eX; tX++) { - int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); - for (int tZ = nZ; tZ < sZ; tZ++) { - int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { - placeCount[2]++; - } - } - else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) { - if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { - placeCount[0]++; - } - } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - // Top two layers are primary + sporadic - level++; // Increment level to next layer - for( ; level < (tMinY + 6); level++){ // should do two layers - for (int tX = wX; tX < eX; tX++) { - int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); - for (int tZ = nZ; tZ < sZ; tZ++) { - int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) { - if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { - placeCount[0]++; - } - } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - } - if (debugWorldGen) { - String tDimensionName = aWorld.provider.getDimensionName(); - GT_Log.out.println( - "Generated Orevein:" + this.mWorldGenName + - " Dimension=" + tDimensionName + - " mX="+aChunkX/16+ - " mZ="+aChunkZ/16+ - " oreseedX="+ aSeedX/16 + - " oreseedZ="+ aSeedZ/16 + - " cY="+tMinY+ - " wXVein" + wXVein + - " eXVein" + eXVein + - " nZVein" + nZVein + - " sZVein" + sZVein + - " locDen=" + localDensity + - " Den=" + this.mDensity + - " Sec="+placeCount[1]+ - " Spo="+placeCount[3]+ - " Bet="+placeCount[2]+ - " Pri="+placeCount[0] - ); - } - // Something (at least the bottom layer must have 1 block) must have been placed, return true - return ORE_PLACED; - } - - private String fString = "unset", ore1String = "unset", ore2String = "unset", ore3String = "unset", ore4String = "unset"; - Map<Materials, String> gtOreMap = new HashMap<Materials, String>(); - - @SuppressWarnings("deprecation") - public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, Block aMetaData, boolean isSmallOre, - boolean air) { - if (!air) { - aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); - } - - //Set GT ORE - if (aMetaData instanceof GT_Block_Ores){ - if (ore1String.equals("unset")) { - ore1String = Utils.sanitizeString(this.mPrimary.getLocalizedName().toLowerCase()); - } - if (ore2String.equals("unset")) { - ore2String = Utils.sanitizeString(this.mSecondaryMeta.getLocalizedName().toLowerCase()); - } - if (ore3String.equals("unset")) { - ore3String = Utils.sanitizeString(this.mBetweenMeta.getLocalizedName().toLowerCase()); - } - if (ore4String.equals("unset")) { - ore4String = Utils.sanitizeString(this.mSporadicMeta.getLocalizedName().toLowerCase()); - } - - if (this.mPrimaryMeta == aMetaData){ - for (Materials f : Materials.values()){ - if (!gtOreMap.containsKey(f)) { - gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); - } - fString = gtOreMap.get(f); - if (fString.contains(ore1String)){ - int r = f.mMetaItemSubID; - if (setOreBlock(aWorld, aX, aY, aZ, r, false)){ - Logger.WARNING("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); - return true; - } - } - } - } - if (this.mSecondaryMeta == aMetaData){ - for (Materials f : Materials.values()){ - if (!gtOreMap.containsKey(f)) { - gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); - } - fString = gtOreMap.get(f); - if (fString.contains(ore2String)){ - int r = f.mMetaItemSubID; - if (setOreBlock(aWorld, aX, aY, aZ, r, false)){ - Logger.WARNING("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); - return true; - } - } - } - } - if (this.mBetweenMeta == aMetaData){ - for (Materials f : Materials.values()){ - if (!gtOreMap.containsKey(f)) { - gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); - } - fString = gtOreMap.get(f); - if (fString.contains(ore3String)){ - int r = f.mMetaItemSubID; - if (setOreBlock(aWorld, aX, aY, aZ, r, false)){ - Logger.WARNING("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); - return true; - } - } - } - } - if (this.mSporadicMeta == aMetaData){ - for (Materials f : Materials.values()){ - if (!gtOreMap.containsKey(f)) { - gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); - } - fString = gtOreMap.get(f); - if (fString.contains(ore4String)){ - int r = f.mMetaItemSubID; - if (setOreBlock(aWorld, aX, aY, aZ, r, false)){ - Logger.WARNING("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); - return true; - } - } - } - } - - } - - Block tBlock = aWorld.getBlock(aX, aY, aZ); - Block tOreBlock = aMetaData; - int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ); - String BlockName = tBlock.getUnlocalizedName(); - if ( - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone) || - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sand) || - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt) || - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites) || - (mUpdated && tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, mStoneTypes)) ||/* - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondLayer) || - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockMainFiller) || - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondaryFiller) ||*/ - tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sandstone)) { - - if (aWorld.setBlock(aX, aY, aZ, tOreBlock, 0, 3)){ - Logger.WARNING("[World Generation Debug] Set "+tOreBlock.getLocalizedName()+" at X: "+aX+" | Y: "+aY+" | Z: "+aZ); - return true; - } - } - return false; - } - + Logger.WARNING("[World Generation Debug] Trying to set Ores?"); + for (level = tMinY; level < (tMinY - 1 + 3); level++) { + for (int tX = wX; tX < eX; tX++) { + int placeX = Math.max( + 1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX)) / localDensity); + for (int tZ = nZ; tZ < sZ; tZ++) { + int placeZ = Math.max( + 1, + Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ)) / localDensity); + if (((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSecondaryMeta != null)) { + if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { + placeCount[1]++; + } + } else if ((aRandom.nextInt(7) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSporadicMeta + != null)) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to + // compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; + } + } + } + } + // Low Middle layer is between + sporadic + // level should be = tMinY-1+3 from end of for loop + for (int tX = wX; tX < eX; tX++) { + int placeX = Math.max( + 1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX)) / localDensity); + for (int tZ = nZ; tZ < sZ; tZ++) { + int placeZ = Math.max( + 1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ)) / localDensity); + if ((aRandom.nextInt(2) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mBetweenMeta + != null)) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + placeCount[2]++; + } + } else if ((aRandom.nextInt(7) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSporadicMeta + != null)) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to + // compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; + } + } + } + // High Middle layer is between + primary + sporadic + level++; // Increment level to next layer + for (int tX = wX; tX < eX; tX++) { + int placeX = Math.max( + 1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX)) / localDensity); + for (int tZ = nZ; tZ < sZ; tZ++) { + int placeZ = Math.max( + 1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ)) / localDensity); + if ((aRandom.nextInt(2) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mBetweenMeta + != null)) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + placeCount[2]++; + } + } else if (((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mPrimaryMeta != null)) { + if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { + placeCount[0]++; + } + } else if ((aRandom.nextInt(7) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSporadicMeta + != null)) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to + // compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; + } + } + } + // Top two layers are primary + sporadic + level++; // Increment level to next layer + for (; level < (tMinY + 6); level++) { // should do two layers + for (int tX = wX; tX < eX; tX++) { + int placeX = Math.max( + 1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX)) / localDensity); + for (int tZ = nZ; tZ < sZ; tZ++) { + int placeZ = Math.max( + 1, + Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ)) / localDensity); + if (((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mPrimaryMeta != null)) { + if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { + placeCount[0]++; + } + } else if ((aRandom.nextInt(7) == 0) + && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) + && (this.mSporadicMeta + != null)) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to + // compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; + } + } + } + } + if (debugWorldGen) { + String tDimensionName = aWorld.provider.getDimensionName(); + GT_Log.out.println("Generated Orevein:" + this.mWorldGenName + " Dimension=" + + tDimensionName + " mX=" + + aChunkX / 16 + " mZ=" + + aChunkZ / 16 + " oreseedX=" + + aSeedX / 16 + " oreseedZ=" + + aSeedZ / 16 + " cY=" + + tMinY + " wXVein" + + wXVein + " eXVein" + + eXVein + " nZVein" + + nZVein + " sZVein" + + sZVein + " locDen=" + + localDensity + " Den=" + + this.mDensity + " Sec=" + + placeCount[1] + " Spo=" + + placeCount[3] + " Bet=" + + placeCount[2] + " Pri=" + + placeCount[0]); + } + // Something (at least the bottom layer must have 1 block) must have been placed, return true + return ORE_PLACED; + } + + private String fString = "unset", + ore1String = "unset", + ore2String = "unset", + ore3String = "unset", + ore4String = "unset"; + Map<Materials, String> gtOreMap = new HashMap<Materials, String>(); + + @SuppressWarnings("deprecation") + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, Block aMetaData, boolean isSmallOre, boolean air) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + + // Set GT ORE + if (aMetaData instanceof GT_Block_Ores) { + if (ore1String.equals("unset")) { + ore1String = + Utils.sanitizeString(this.mPrimary.getLocalizedName().toLowerCase()); + } + if (ore2String.equals("unset")) { + ore2String = Utils.sanitizeString( + this.mSecondaryMeta.getLocalizedName().toLowerCase()); + } + if (ore3String.equals("unset")) { + ore3String = Utils.sanitizeString( + this.mBetweenMeta.getLocalizedName().toLowerCase()); + } + if (ore4String.equals("unset")) { + ore4String = Utils.sanitizeString( + this.mSporadicMeta.getLocalizedName().toLowerCase()); + } - private boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int mMetaItemSubID, boolean useless){ + if (this.mPrimaryMeta == aMetaData) { + for (Materials f : Materials.values()) { + if (!gtOreMap.containsKey(f)) { + gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); + } + fString = gtOreMap.get(f); + if (fString.contains(ore1String)) { + int r = f.mMetaItemSubID; + if (setOreBlock(aWorld, aX, aY, aZ, r, false)) { + Logger.WARNING("[World Generation Debug] Set " + f.mDefaultLocalName + " Ore at X: " + aX + + " | Y: " + aY + " | Z: " + aZ); + return true; + } + } + } + } + if (this.mSecondaryMeta == aMetaData) { + for (Materials f : Materials.values()) { + if (!gtOreMap.containsKey(f)) { + gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); + } + fString = gtOreMap.get(f); + if (fString.contains(ore2String)) { + int r = f.mMetaItemSubID; + if (setOreBlock(aWorld, aX, aY, aZ, r, false)) { + Logger.WARNING("[World Generation Debug] Set " + f.mDefaultLocalName + " Ore at X: " + aX + + " | Y: " + aY + " | Z: " + aZ); + return true; + } + } + } + } + if (this.mBetweenMeta == aMetaData) { + for (Materials f : Materials.values()) { + if (!gtOreMap.containsKey(f)) { + gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); + } + fString = gtOreMap.get(f); + if (fString.contains(ore3String)) { + int r = f.mMetaItemSubID; + if (setOreBlock(aWorld, aX, aY, aZ, r, false)) { + Logger.WARNING("[World Generation Debug] Set " + f.mDefaultLocalName + " Ore at X: " + aX + + " | Y: " + aY + " | Z: " + aZ); + return true; + } + } + } + } + if (this.mSporadicMeta == aMetaData) { + for (Materials f : Materials.values()) { + if (!gtOreMap.containsKey(f)) { + gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase())); + } + fString = gtOreMap.get(f); + if (fString.contains(ore4String)) { + int r = f.mMetaItemSubID; + if (setOreBlock(aWorld, aX, aY, aZ, r, false)) { + Logger.WARNING("[World Generation Debug] Set " + f.mDefaultLocalName + " Ore at X: " + aX + + " | Y: " + aY + " | Z: " + aZ); + return true; + } + } + } + } + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = aMetaData; + int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ); + String BlockName = tBlock.getUnlocalizedName(); + if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone) + || tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sand) + || tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt) + || tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites) + || (mUpdated && tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, mStoneTypes)) + || /* + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondLayer) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockMainFiller) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondaryFiller) ||*/ tBlock + .isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sandstone)) { + + if (aWorld.setBlock(aX, aY, aZ, tOreBlock, 0, 3)) { + Logger.WARNING("[World Generation Debug] Set " + tOreBlock.getLocalizedName() + " at X: " + aX + + " | Y: " + aY + " | Z: " + aZ); + return true; + } + } + return false; + } - //Get Class and Methods - Method setOres = null; - boolean is08 = !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; + private boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int mMetaItemSubID, boolean useless) { - //GT 5.08 - if (is08){ - try { - setOres = GT_TileEntity_Ores.class.getDeclaredMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class); - } - catch (NoSuchMethodException | SecurityException e) { + // Get Class and Methods + Method setOres = null; + boolean is08 = !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; - } - } - //GT 5.09 - else { - try { - setOres = GT_TileEntity_Ores.class.getDeclaredMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); - } - catch (NoSuchMethodException | SecurityException e) { + // GT 5.08 + if (is08) { + try { + setOres = GT_TileEntity_Ores.class.getDeclaredMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class); + } catch (NoSuchMethodException | SecurityException e) { - } - } + } + } + // GT 5.09 + else { + try { + setOres = GT_TileEntity_Ores.class.getDeclaredMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); + } catch (NoSuchMethodException | SecurityException e) { - try { - if (is08 && setOres != null){ - setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID); - } - else if (!is08 && setOres != null){ - setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID, useless); - } - else { - return false; - }} - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + try { + if (is08 && setOres != null) { + setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID); + } else if (!is08 && setOres != null) { + setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID, useless); + } else { + return false; + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - } - return false; - } -}
\ No newline at end of file + } + return false; + } +} 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; + } } diff --git a/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianOre.java b/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianOre.java index 9adb84eef2..d2f3b7e5cb 100644 --- a/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianOre.java +++ b/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianOre.java @@ -1,9 +1,8 @@ package gtPlusPlus.australia.gen.world; -import java.util.Random; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; @@ -11,77 +10,78 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenAustralianOre extends WorldGenerator { - - private Block mOreToSpawn; - private int numberOfBlocks; - private Block mBlockToReplace; - private int mineableBlockMeta; - public WorldGenAustralianOre(Block aBlock, int aNumber) { - this(aBlock, aNumber, Blocks.stone); - this.mineableBlockMeta = 0; - } + private Block mOreToSpawn; + private int numberOfBlocks; + private Block mBlockToReplace; + private int mineableBlockMeta; + + public WorldGenAustralianOre(Block aBlock, int aNumber) { + this(aBlock, aNumber, Blocks.stone); + this.mineableBlockMeta = 0; + } - public WorldGenAustralianOre(Block aBlock, int aNumber, Block aReplace) { - this.mOreToSpawn = aBlock; - this.numberOfBlocks = aNumber; - this.mBlockToReplace = aReplace; - } + public WorldGenAustralianOre(Block aBlock, int aNumber, Block aReplace) { + this.mOreToSpawn = aBlock; + this.numberOfBlocks = aNumber; + this.mBlockToReplace = aReplace; + } - public WorldGenAustralianOre(Block block, int meta, int number, Block target) { - this(block, number, target); - this.mineableBlockMeta = meta; - } - - + public WorldGenAustralianOre(Block block, int meta, int number, Block target) { + this(block, number, target); + this.mineableBlockMeta = meta; + } - public boolean generate(World aWorld, Random aRand, int aX, int aY, int aZ) { - float f = MathUtils.randFloat(0f, 1.5f) * CORE.PI; - double d0 = (double) ((float) (aX + 8) + MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F); - double d1 = (double) ((float) (aX + 8) - MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F); - double d2 = (double) ((float) (aZ + 8) + MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F); - double d3 = (double) ((float) (aZ + 8) - MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F); - double d4 = (double) (aY + aRand.nextInt(MathUtils.randInt(3, 6)) - 2); - double d5 = (double) (aY + aRand.nextInt(MathUtils.randInt(3, 6)) - 2); + public boolean generate(World aWorld, Random aRand, int aX, int aY, int aZ) { + float f = MathUtils.randFloat(0f, 1.5f) * CORE.PI; + double d0 = (double) ((float) (aX + 8) + MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F); + double d1 = (double) ((float) (aX + 8) - MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F); + double d2 = (double) ((float) (aZ + 8) + MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F); + double d3 = (double) ((float) (aZ + 8) - MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F); + double d4 = (double) (aY + aRand.nextInt(MathUtils.randInt(3, 6)) - 2); + double d5 = (double) (aY + aRand.nextInt(MathUtils.randInt(3, 6)) - 2); - for (int aOreGenerated = 0; aOreGenerated <= this.numberOfBlocks; ++aOreGenerated) { - double d6 = d0 + (d1 - d0) * (double) aOreGenerated / (double) this.numberOfBlocks; - double d7 = d4 + (d5 - d4) * (double) aOreGenerated / (double) this.numberOfBlocks; - double d8 = d2 + (d3 - d2) * (double) aOreGenerated / (double) this.numberOfBlocks; - double d9 = aRand.nextDouble() * (double) this.numberOfBlocks / 16.0D; - double d10 = (double) (MathHelper.sin((float) aOreGenerated * CORE.PI / (float) this.numberOfBlocks) + 1.0F) - * d9 + 1.0D; - double d11 = (double) (MathHelper.sin((float) aOreGenerated * CORE.PI / (float) this.numberOfBlocks) + 1.0F) - * d9 + 1.0D; - int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); - int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); - int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); - int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); - int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); - int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); + for (int aOreGenerated = 0; aOreGenerated <= this.numberOfBlocks; ++aOreGenerated) { + double d6 = d0 + (d1 - d0) * (double) aOreGenerated / (double) this.numberOfBlocks; + double d7 = d4 + (d5 - d4) * (double) aOreGenerated / (double) this.numberOfBlocks; + double d8 = d2 + (d3 - d2) * (double) aOreGenerated / (double) this.numberOfBlocks; + double d9 = aRand.nextDouble() * (double) this.numberOfBlocks / 16.0D; + double d10 = + (double) (MathHelper.sin((float) aOreGenerated * CORE.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + + 1.0D; + double d11 = + (double) (MathHelper.sin((float) aOreGenerated * CORE.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + + 1.0D; + int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); + int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); + int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); + int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); + int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); + int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); - for (int k2 = i1; k2 <= l1; ++k2) { - double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D); + for (int k2 = i1; k2 <= l1; ++k2) { + double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D); - if (d12 * d12 < 1.0D) { - for (int l2 = j1; l2 <= i2; ++l2) { - double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D); + if (d12 * d12 < 1.0D) { + for (int l2 = j1; l2 <= i2; ++l2) { + double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D); - if (d12 * d12 + d13 * d13 < 1.0D) { - for (int i3 = k1; i3 <= j2; ++i3) { - double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D); + if (d12 * d12 + d13 * d13 < 1.0D) { + for (int i3 = k1; i3 <= j2; ++i3) { + double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D); - if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && aWorld.getBlock(k2, l2, i3) - .isReplaceableOreGen(aWorld, k2, l2, i3, mBlockToReplace)) { - aWorld.setBlock(k2, l2, i3, this.mOreToSpawn, mineableBlockMeta, 2); - } - } - } - } - } - } - } + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D + && aWorld.getBlock(k2, l2, i3) + .isReplaceableOreGen(aWorld, k2, l2, i3, mBlockToReplace)) { + aWorld.setBlock(k2, l2, i3, this.mOreToSpawn, mineableBlockMeta, 2); + } + } + } + } + } + } + } - return true; - } -}
\ No newline at end of file + return true; + } +} diff --git a/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianTrees.java b/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianTrees.java index f3529aff0b..da0830d982 100644 --- a/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianTrees.java +++ b/src/main/java/gtPlusPlus/australia/gen/world/WorldGenAustralianTrees.java @@ -1,11 +1,9 @@ package gtPlusPlus.australia.gen.world; -import java.util.Random; - import gtPlusPlus.core.util.math.MathUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; -import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.util.Direction; import net.minecraft.world.World; @@ -14,237 +12,257 @@ import net.minecraftforge.common.util.ForgeDirection; public class WorldGenAustralianTrees extends WorldGenTrees { - /** The minimum height of a generated tree. */ - private final int minHeight; - /** True if this tree should grow Vines. */ - private final boolean growVines; - /** The metadata value of the wood to use in tree generation. */ - private final int woodMeta; - /** The metadata value of the leaves to use in tree generation. */ - private final int leavesMeta; - - public WorldGenAustralianTrees(boolean p_i2027_1_) { - this(p_i2027_1_, 4, false); - } - - public WorldGenAustralianTrees(boolean p_i2028_1_, int aMinHeight, boolean aVinesGrow) { - super(p_i2028_1_, aMinHeight, 0, 0, aVinesGrow); - this.minHeight = aMinHeight; - this.woodMeta = 0; - this.leavesMeta = 0; - this.growVines = aVinesGrow; - } - - public boolean generate(World aWorld, Random aRand, int aX, int aY, int aZ) { - int aActualMinHeight = MathUtils.randInt(4, 8) + this.minHeight; - boolean flag = true; - - if (aY >= 1 && aY + aActualMinHeight + 1 <= 256) { - byte b0; - int k1; - Block block; - - for (int i1 = aY; i1 <= aY + 1 + aActualMinHeight; ++i1) { - b0 = 1; - - if (i1 == aY) { - b0 = 0; - } - - if (i1 >= aY + 1 + aActualMinHeight - 2) { - b0 = 2; - } - - for (int j1 = aX - b0; j1 <= aX + b0 && flag; ++j1) { - for (k1 = aZ - b0; k1 <= aZ + b0 && flag; ++k1) { - if (i1 >= 0 && i1 < 256) { - block = aWorld.getBlock(j1, i1, k1); - - if (!this.isReplaceable(aWorld, j1, i1, k1)) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - Block block2 = aWorld.getBlock(aX, aY - 1, aZ); - boolean isSoil = true; - for (int gh = 0; gh < 5; gh++) { - int xMod, zMod; - if (gh == 0) { - xMod = 1; - zMod = 0; - } - else if (gh == 1) { - xMod = 0; - zMod = 1; - } - else if (gh == 2) { - xMod = -1; - zMod = 0; - } - else if (gh == 3) { - xMod = 0; - zMod = -1; - } - else { - xMod = 0; - zMod = 0; - } - block2 = aWorld.getBlock(aX+xMod, aY - 1, aZ+zMod); - if (block2 == Blocks.air || !block2.canSustainPlant(aWorld, aX+xMod, aY - 1, aZ+zMod, ForgeDirection.UP, (BlockSapling) Blocks.sapling)) { - isSoil = false; - break; - } - } - - if (isSoil && aY < 256 - aActualMinHeight - 1) { - block2.onPlantGrow(aWorld, aX, aY - 1, aZ, aX, aY, aZ); - b0 = 5; - byte b1 = 0; - int l1; - int i2; - int j2; - int i3; - - for (k1 = aY - b0 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) { - i3 = k1 - (aY + aActualMinHeight); - l1 = b1 + 3 - i3 / 2; - - for (i2 = aX - l1; i2 <= aX + l1; ++i2) { - j2 = i2 - aX; - - for (int k2 = aZ - l1; k2 <= aZ + l1; ++k2) { - int l2 = k2 - aZ; - - if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || aRand.nextInt(2) != 0 && i3 != 0) { - Block block1 = aWorld.getBlock(i2, k1, k2); - - if (block1.isAir(aWorld, i2, k1, k2) || block1.isLeaves(aWorld, i2, k1, k2)) { - this.setBlockAndNotifyAdequately(aWorld, i2, k1, k2, Blocks.leaves, - this.leavesMeta); - } - } - } - } - } - - for (k1 = 0; k1 < aActualMinHeight; ++k1) { - block = aWorld.getBlock(aX, aY + k1, aZ); - - if (block.isAir(aWorld, aX, aY + k1, aZ) || block.isLeaves(aWorld, aX, aY + k1, aZ)) { - - //Set Middle Trunk - this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ, Blocks.log, this.woodMeta); - //Set Sides - if (k1 < (aActualMinHeight - 2)) { - if (aWorld.isAirBlock(aX+1, aY + k1, aZ) || block.isLeaves(aWorld, aX+1, aY + k1, aZ)) this.setBlockAndNotifyAdequately(aWorld, aX+1, aY + k1, aZ, Blocks.log, this.woodMeta); - if (aWorld.isAirBlock(aX-1, aY + k1, aZ) || block.isLeaves(aWorld, aX-1, aY + k1, aZ)) this.setBlockAndNotifyAdequately(aWorld, aX-1, aY + k1, aZ, Blocks.log, this.woodMeta); - if (aWorld.isAirBlock(aX, aY + k1, aZ+1) || block.isLeaves(aWorld, aX, aY + k1, aZ+1)) this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ+1, Blocks.log, this.woodMeta); - if (aWorld.isAirBlock(aX, aY + k1, aZ-1) || block.isLeaves(aWorld, aX, aY + k1, aZ-1)) this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ-1, Blocks.log, this.woodMeta); - } - - if (this.growVines && k1 > 0) { - if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX - 1, aY + k1, aZ)) { - this.setBlockAndNotifyAdequately(aWorld, aX - 1, aY + k1, aZ, Blocks.vine, 8); - } - - if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX + 1, aY + k1, aZ)) { - this.setBlockAndNotifyAdequately(aWorld, aX + 1, aY + k1, aZ, Blocks.vine, 2); - } - - if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ - 1)) { - this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ - 1, Blocks.vine, 1); - } - - if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ + 1)) { - this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ + 1, Blocks.vine, 4); - } - } - } - } - - if (this.growVines) { - for (k1 = aY - 3 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) { - i3 = k1 - (aY + aActualMinHeight); - l1 = 2 - i3 / 2; - - for (i2 = aX - l1; i2 <= aX + l1; ++i2) { - for (j2 = aZ - l1; j2 <= aZ + l1; ++j2) { - if (aWorld.getBlock(i2, k1, j2).isLeaves(aWorld, i2, k1, j2)) { - if (aRand.nextInt(4) == 0 - && aWorld.getBlock(i2 - 1, k1, j2).isAir(aWorld, i2 - 1, k1, j2)) { - this.growVines(aWorld, i2 - 1, k1, j2, 8); - } - - if (aRand.nextInt(4) == 0 - && aWorld.getBlock(i2 + 1, k1, j2).isAir(aWorld, i2 + 1, k1, j2)) { - this.growVines(aWorld, i2 + 1, k1, j2, 2); - } - - if (aRand.nextInt(4) == 0 - && aWorld.getBlock(i2, k1, j2 - 1).isAir(aWorld, i2, k1, j2 - 1)) { - this.growVines(aWorld, i2, k1, j2 - 1, 1); - } - - if (aRand.nextInt(4) == 0 - && aWorld.getBlock(i2, k1, j2 + 1).isAir(aWorld, i2, k1, j2 + 1)) { - this.growVines(aWorld, i2, k1, j2 + 1, 4); - } - } - } - } - } - - if (aRand.nextInt(5) == 0 && aActualMinHeight > 5) { - for (k1 = 0; k1 < 2; ++k1) { - for (i3 = 0; i3 < 4; ++i3) { - if (aRand.nextInt(4 - k1) == 0) { - l1 = aRand.nextInt(3); - this.setBlockAndNotifyAdequately(aWorld, - aX + Direction.offsetX[Direction.rotateOpposite[i3]], aY + aActualMinHeight - 5 + k1, - aZ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, - l1 << 2 | i3); - } - } - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - /** - * Grows vines downward from the given block for a given length. Args: World, x, - * starty, z, vine-length - */ - private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_) { - this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); - int i1 = 4; - - while (true) { - --p_76529_3_; - - if (!p_76529_1_.getBlock(p_76529_2_, p_76529_3_, p_76529_4_).isAir(p_76529_1_, p_76529_2_, p_76529_3_, - p_76529_4_) || i1 <= 0) { - return; - } - - this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); - --i1; - } - } -}
\ No newline at end of file + /** The minimum height of a generated tree. */ + private final int minHeight; + /** True if this tree should grow Vines. */ + private final boolean growVines; + /** The metadata value of the wood to use in tree generation. */ + private final int woodMeta; + /** The metadata value of the leaves to use in tree generation. */ + private final int leavesMeta; + + public WorldGenAustralianTrees(boolean p_i2027_1_) { + this(p_i2027_1_, 4, false); + } + + public WorldGenAustralianTrees(boolean p_i2028_1_, int aMinHeight, boolean aVinesGrow) { + super(p_i2028_1_, aMinHeight, 0, 0, aVinesGrow); + this.minHeight = aMinHeight; + this.woodMeta = 0; + this.leavesMeta = 0; + this.growVines = aVinesGrow; + } + + public boolean generate(World aWorld, Random aRand, int aX, int aY, int aZ) { + int aActualMinHeight = MathUtils.randInt(4, 8) + this.minHeight; + boolean flag = true; + + if (aY >= 1 && aY + aActualMinHeight + 1 <= 256) { + byte b0; + int k1; + Block block; + + for (int i1 = aY; i1 <= aY + 1 + aActualMinHeight; ++i1) { + b0 = 1; + + if (i1 == aY) { + b0 = 0; + } + + if (i1 >= aY + 1 + aActualMinHeight - 2) { + b0 = 2; + } + + for (int j1 = aX - b0; j1 <= aX + b0 && flag; ++j1) { + for (k1 = aZ - b0; k1 <= aZ + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < 256) { + block = aWorld.getBlock(j1, i1, k1); + + if (!this.isReplaceable(aWorld, j1, i1, k1)) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + Block block2 = aWorld.getBlock(aX, aY - 1, aZ); + boolean isSoil = true; + for (int gh = 0; gh < 5; gh++) { + int xMod, zMod; + if (gh == 0) { + xMod = 1; + zMod = 0; + } else if (gh == 1) { + xMod = 0; + zMod = 1; + } else if (gh == 2) { + xMod = -1; + zMod = 0; + } else if (gh == 3) { + xMod = 0; + zMod = -1; + } else { + xMod = 0; + zMod = 0; + } + block2 = aWorld.getBlock(aX + xMod, aY - 1, aZ + zMod); + if (block2 == Blocks.air + || !block2.canSustainPlant( + aWorld, aX + xMod, aY - 1, aZ + zMod, ForgeDirection.UP, (BlockSapling) + Blocks.sapling)) { + isSoil = false; + break; + } + } + + if (isSoil && aY < 256 - aActualMinHeight - 1) { + block2.onPlantGrow(aWorld, aX, aY - 1, aZ, aX, aY, aZ); + b0 = 5; + byte b1 = 0; + int l1; + int i2; + int j2; + int i3; + + for (k1 = aY - b0 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) { + i3 = k1 - (aY + aActualMinHeight); + l1 = b1 + 3 - i3 / 2; + + for (i2 = aX - l1; i2 <= aX + l1; ++i2) { + j2 = i2 - aX; + + for (int k2 = aZ - l1; k2 <= aZ + l1; ++k2) { + int l2 = k2 - aZ; + + if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || aRand.nextInt(2) != 0 && i3 != 0) { + Block block1 = aWorld.getBlock(i2, k1, k2); + + if (block1.isAir(aWorld, i2, k1, k2) || block1.isLeaves(aWorld, i2, k1, k2)) { + this.setBlockAndNotifyAdequately( + aWorld, i2, k1, k2, Blocks.leaves, this.leavesMeta); + } + } + } + } + } + + for (k1 = 0; k1 < aActualMinHeight; ++k1) { + block = aWorld.getBlock(aX, aY + k1, aZ); + + if (block.isAir(aWorld, aX, aY + k1, aZ) || block.isLeaves(aWorld, aX, aY + k1, aZ)) { + + // Set Middle Trunk + this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ, Blocks.log, this.woodMeta); + // Set Sides + if (k1 < (aActualMinHeight - 2)) { + if (aWorld.isAirBlock(aX + 1, aY + k1, aZ) + || block.isLeaves(aWorld, aX + 1, aY + k1, aZ)) + this.setBlockAndNotifyAdequately( + aWorld, aX + 1, aY + k1, aZ, Blocks.log, this.woodMeta); + if (aWorld.isAirBlock(aX - 1, aY + k1, aZ) + || block.isLeaves(aWorld, aX - 1, aY + k1, aZ)) + this.setBlockAndNotifyAdequately( + aWorld, aX - 1, aY + k1, aZ, Blocks.log, this.woodMeta); + if (aWorld.isAirBlock(aX, aY + k1, aZ + 1) + || block.isLeaves(aWorld, aX, aY + k1, aZ + 1)) + this.setBlockAndNotifyAdequately( + aWorld, aX, aY + k1, aZ + 1, Blocks.log, this.woodMeta); + if (aWorld.isAirBlock(aX, aY + k1, aZ - 1) + || block.isLeaves(aWorld, aX, aY + k1, aZ - 1)) + this.setBlockAndNotifyAdequately( + aWorld, aX, aY + k1, aZ - 1, Blocks.log, this.woodMeta); + } + + if (this.growVines && k1 > 0) { + if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX - 1, aY + k1, aZ)) { + this.setBlockAndNotifyAdequately(aWorld, aX - 1, aY + k1, aZ, Blocks.vine, 8); + } + + if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX + 1, aY + k1, aZ)) { + this.setBlockAndNotifyAdequately(aWorld, aX + 1, aY + k1, aZ, Blocks.vine, 2); + } + + if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ - 1)) { + this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ - 1, Blocks.vine, 1); + } + + if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ + 1)) { + this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ + 1, Blocks.vine, 4); + } + } + } + } + + if (this.growVines) { + for (k1 = aY - 3 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) { + i3 = k1 - (aY + aActualMinHeight); + l1 = 2 - i3 / 2; + + for (i2 = aX - l1; i2 <= aX + l1; ++i2) { + for (j2 = aZ - l1; j2 <= aZ + l1; ++j2) { + if (aWorld.getBlock(i2, k1, j2).isLeaves(aWorld, i2, k1, j2)) { + if (aRand.nextInt(4) == 0 + && aWorld.getBlock(i2 - 1, k1, j2) + .isAir(aWorld, i2 - 1, k1, j2)) { + this.growVines(aWorld, i2 - 1, k1, j2, 8); + } + + if (aRand.nextInt(4) == 0 + && aWorld.getBlock(i2 + 1, k1, j2) + .isAir(aWorld, i2 + 1, k1, j2)) { + this.growVines(aWorld, i2 + 1, k1, j2, 2); + } + + if (aRand.nextInt(4) == 0 + && aWorld.getBlock(i2, k1, j2 - 1) + .isAir(aWorld, i2, k1, j2 - 1)) { + this.growVines(aWorld, i2, k1, j2 - 1, 1); + } + + if (aRand.nextInt(4) == 0 + && aWorld.getBlock(i2, k1, j2 + 1) + .isAir(aWorld, i2, k1, j2 + 1)) { + this.growVines(aWorld, i2, k1, j2 + 1, 4); + } + } + } + } + } + + if (aRand.nextInt(5) == 0 && aActualMinHeight > 5) { + for (k1 = 0; k1 < 2; ++k1) { + for (i3 = 0; i3 < 4; ++i3) { + if (aRand.nextInt(4 - k1) == 0) { + l1 = aRand.nextInt(3); + this.setBlockAndNotifyAdequately( + aWorld, + aX + Direction.offsetX[Direction.rotateOpposite[i3]], + aY + aActualMinHeight - 5 + k1, + aZ + Direction.offsetZ[Direction.rotateOpposite[i3]], + Blocks.cocoa, + l1 << 2 | i3); + } + } + } + } + } + + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + /** + * Grows vines downward from the given block for a given length. Args: World, x, + * starty, z, vine-length + */ + private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_) { + this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); + int i1 = 4; + + while (true) { + --p_76529_3_; + + if (!p_76529_1_ + .getBlock(p_76529_2_, p_76529_3_, p_76529_4_) + .isAir(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_) + || i1 <= 0) { + return; + } + + this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); + --i1; + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java b/src/main/java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java index 5100ed31c5..064c6a3149 100644 --- a/src/main/java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java +++ b/src/main/java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java @@ -1,7 +1,10 @@ package gtPlusPlus.australia.item; +import gtPlusPlus.australia.dimension.Dimension_Australia; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -11,90 +14,97 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.australia.dimension.Dimension_Australia; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; public class ItemAustraliaPortalTrigger extends Item { - public ItemAustraliaPortalTrigger() { - super(); - this.maxStackSize = 1; - setMaxDamage(64); - setCreativeTab(CreativeTabs.tabTools); - this.setTextureName(CORE.MODID + ":" + "itemAlkalusDisk"); - } + public ItemAustraliaPortalTrigger() { + super(); + this.maxStackSize = 1; + setMaxDamage(64); + setCreativeTab(CreativeTabs.tabTools); + this.setTextureName(CORE.MODID + ":" + "itemAlkalusDisk"); + } - @Override - public Item setMaxStackSize(int int1) { - return super.setMaxStackSize(1); - } + @Override + public Item setMaxStackSize(int int1) { + return super.setMaxStackSize(1); + } - @Override - public EnumRarity getRarity(ItemStack thisItem) { - return EnumRarity.rare; - } + @Override + public EnumRarity getRarity(ItemStack thisItem) { + return EnumRarity.rare; + } - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return false; - } + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return false; + } - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return EnumChatFormatting.GOLD+"Alkalus ROM ["+EnumChatFormatting.RED+"Activated"+EnumChatFormatting.GOLD+"]"; - } + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return EnumChatFormatting.GOLD + "Alkalus ROM [" + EnumChatFormatting.RED + "Activated" + + EnumChatFormatting.GOLD + "]"; + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GREEN+"Shows a glipse of the past."); - list.add(EnumChatFormatting.GREEN+"This item produces such a temperature, that you'd hate to use it incorrectly."); - super.addInformation(stack, aPlayer, list, bool); - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GREEN + "Shows a glipse of the past."); + list.add(EnumChatFormatting.GREEN + + "This item produces such a temperature, that you'd hate to use it incorrectly."); + super.addInformation(stack, aPlayer, list, bool); + } - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - return Utils.rgbtoHexValue(128, 192, 64); - } + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(128, 192, 64); + } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, - float par8, float par9, float par10) { - if (par7 == 0) { - par5--; - } - if (par7 == 1) { - par5++; - } - if (par7 == 2) { - par6--; - } - if (par7 == 3) { - par6++; - } - if (par7 == 4) { - par4--; - } - if (par7 == 5) { - par4++; - } - if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { - return false; - } - Block i1 = par3World.getBlock(par4, par5, par6); - if (i1 == Blocks.air) { - par3World.playSoundEffect(par4 + 0.5D, par5 + 0.5D, par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); - if (Dimension_Australia.portalBlock.tryToCreatePortal(par3World, par4, par5, par6)){ - //Make a Portal - } - else { - if (!par3World.isRemote){ - par3World.setBlock(par4, par5, par6, ModBlocks.blockHellfire, 0, 3); - } - } - } - par1ItemStack.damageItem(1, par2EntityPlayer); - return true; - } -}
\ No newline at end of file + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par7 == 0) { + par5--; + } + if (par7 == 1) { + par5++; + } + if (par7 == 2) { + par6--; + } + if (par7 == 3) { + par6++; + } + if (par7 == 4) { + par4--; + } + if (par7 == 5) { + par4++; + } + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { + return false; + } + Block i1 = par3World.getBlock(par4, par5, par6); + if (i1 == Blocks.air) { + par3World.playSoundEffect( + par4 + 0.5D, par5 + 0.5D, par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + if (Dimension_Australia.portalBlock.tryToCreatePortal(par3World, par4, par5, par6)) { + // Make a Portal + } else { + if (!par3World.isRemote) { + par3World.setBlock(par4, par5, par6, ModBlocks.blockHellfire, 0, 3); + } + } + } + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } +} diff --git a/src/main/java/gtPlusPlus/australia/item/ItemBlockAustralia.java b/src/main/java/gtPlusPlus/australia/item/ItemBlockAustralia.java index 9854f9fa6a..b7c84bb6f0 100644 --- a/src/main/java/gtPlusPlus/australia/item/ItemBlockAustralia.java +++ b/src/main/java/gtPlusPlus/australia/item/ItemBlockAustralia.java @@ -1,39 +1,32 @@ package gtPlusPlus.australia.item; +import gtPlusPlus.api.interfaces.ITileTooltip; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.interfaces.ITileTooltip; - public class ItemBlockAustralia extends ItemBlock { - - protected final int mID; - - public ItemBlockAustralia(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mID == 0){ //blockDarkWorldPortalFrame - list.add("Use this to access Australia."); - list.add("Assembled in the same shape as the Nether Portal."); - } - else if (this.mID == 1){ //blockDarkWorldPortal - list.add("Place this if you are lazy to create the portal structure, slacker."); - } - else if (this.mID == 2){ //blockDarkWorldGround - list.add("Pure Australian Outback."); - } - else if (this.mID == 3){ //blockDarkWorldPollutedDirt - list.add("Maybe you can do something with this?."); - } - } - + protected final int mID; + + public ItemBlockAustralia(final Block block) { + super(block); + this.mID = ((ITileTooltip) block).getTooltipID(); + } + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.mID == 0) { // blockDarkWorldPortalFrame + list.add("Use this to access Australia."); + list.add("Assembled in the same shape as the Nether Portal."); + } else if (this.mID == 1) { // blockDarkWorldPortal + list.add("Place this if you are lazy to create the portal structure, slacker."); + } else if (this.mID == 2) { // blockDarkWorldGround + list.add("Pure Australian Outback."); + } else if (this.mID == 3) { // blockDarkWorldPollutedDirt + list.add("Maybe you can do something with this?."); + } + } } diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaPortalPosition.java b/src/main/java/gtPlusPlus/australia/world/AustraliaPortalPosition.java index 865c0c3bb2..cc7ae1c37d 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaPortalPosition.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaPortalPosition.java @@ -3,12 +3,13 @@ package gtPlusPlus.australia.world; import net.minecraft.util.ChunkCoordinates; public class AustraliaPortalPosition extends ChunkCoordinates { - public long field_85087_d; - final AustraliaTeleporterDimensionMod field_85088_e; + public long field_85087_d; + final AustraliaTeleporterDimensionMod field_85088_e; - public AustraliaPortalPosition(AustraliaTeleporterDimensionMod gladesTeleporter, int par2, int par3, int par4, long par5) { - super(par2, par3, par4); - this.field_85088_e = gladesTeleporter; - this.field_85087_d = par5; - } -}
\ No newline at end of file + public AustraliaPortalPosition( + AustraliaTeleporterDimensionMod gladesTeleporter, int par2, int par3, int par4, long par5) { + super(par2, par3, par4); + this.field_85088_e = gladesTeleporter; + this.field_85087_d = par5; + } +} diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java b/src/main/java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java index 4ad693263e..f277800b72 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java @@ -1,470 +1,471 @@ package gtPlusPlus.australia.world; +import gtPlusPlus.australia.dimension.Dimension_Australia; import java.util.*; - import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.*; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; -import gtPlusPlus.australia.dimension.Dimension_Australia; public class AustraliaTeleporterDimensionMod extends Teleporter { - private final WorldServer worldServerInstance; - /** - * A private Random() function in Teleporter - */ - private final Random random; - /** - * Stores successful portal placement locations for rapid lookup. - */ - private final LongHashMap destinationCoordinateCache = new LongHashMap(); - /** - * A list of valid keys for the destinationCoordainteCache. These are - * based on the X & Z of the players initial location. - */ - @SuppressWarnings("rawtypes") - private final List destinationCoordinateKeys = new ArrayList(); - - public AustraliaTeleporterDimensionMod(WorldServer par1WorldServer) { - super(par1WorldServer); - this.worldServerInstance = par1WorldServer; - this.random = new Random(par1WorldServer.getSeed()); - } - - /** - * Place an entity in a nearby portal, creating one if necessary. - */ - @Override - public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { - if (this.worldServerInstance.provider.dimensionId != 1) { - if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) { - this.makePortal(par1Entity); - this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); - } - } - else { - int i = MathHelper.floor_double(par1Entity.posX); - int j = MathHelper.floor_double(par1Entity.posY) - 1; - int k = MathHelper.floor_double(par1Entity.posZ); - byte b0 = 1; - byte b1 = 0; - - for (int l = -2; l <= 2; ++l) { - for (int i1 = -2; i1 <= 2; ++i1) { - for (int j1 = -1; j1 < 3; ++j1) { - int k1 = i + i1 * b0 + l * b1; - int l1 = j + j1; - int i2 = k + i1 * b1 - l * b0; - boolean flag = j1 < 0; - this.worldServerInstance.setBlock(k1, l1, i2, flag ? Dimension_Australia.blockPortalFrame : Blocks.air); - } - } - } - - par1Entity.setLocationAndAngles(i, j, k, par1Entity.rotationYaw, 0.0F); - par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; - } - } - - /** - * Place an entity in a nearby portal which already exists. - */ - @Override - public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { - short short1 = 128; - double d3 = -1.0D; - int i = 0; - int j = 0; - int k = 0; - int l = MathHelper.floor_double(par1Entity.posX); - int i1 = MathHelper.floor_double(par1Entity.posZ); - long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); - boolean flag = true; - double d7; - int l3; - - if (this.destinationCoordinateCache.containsItem(j1)) { - Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition) this.destinationCoordinateCache - .getValueByKey(j1); - d3 = 0.0D; - i = portalposition.posX; - j = portalposition.posY; - k = portalposition.posZ; - portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); - flag = false; - } - else { - for (l3 = l - short1; l3 <= l + short1; ++l3) { - double d4 = l3 + 0.5D - par1Entity.posX; - - for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { - double d5 = l1 + 0.5D - par1Entity.posZ; - - for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) { - if (this.worldServerInstance.getBlock(l3, i2, l1) == Dimension_Australia.portalBlock) { - while (this.worldServerInstance.getBlock(l3, i2 - 1, l1) == Dimension_Australia.portalBlock) { - --i2; - } - - d7 = i2 + 0.5D - par1Entity.posY; - double d8 = d4 * d4 + d7 * d7 + d5 * d5; - - if (d3 < 0.0D || d8 < d3) { - d3 = d8; - i = l3; - j = i2; - k = l1; - } - } - } - } - } - } - - if (d3 >= 0.0D) { - if (flag) { - this.destinationCoordinateCache.add(j1, - new Teleporter.PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); - this.destinationCoordinateKeys.add(Long.valueOf(j1)); - } - - double d11 = i + 0.5D; - double d6 = j + 0.5D; - d7 = k + 0.5D; - int i4 = -1; - - if (this.worldServerInstance.getBlock(i - 1, j, k) == Dimension_Australia.portalBlock) { - i4 = 2; - } - - if (this.worldServerInstance.getBlock(i + 1, j, k) == Dimension_Australia.portalBlock) { - i4 = 0; - } - - if (this.worldServerInstance.getBlock(i, j, k - 1) == Dimension_Australia.portalBlock) { - i4 = 3; - } - - if (this.worldServerInstance.getBlock(i, j, k + 1) == Dimension_Australia.portalBlock) { - i4 = 1; - } - - int j2 = par1Entity.getTeleportDirection(); - - if (i4 > -1) { - int k2 = Direction.rotateLeft[i4]; - int l2 = Direction.offsetX[i4]; - int i3 = Direction.offsetZ[i4]; - int j3 = Direction.offsetX[k2]; - int k3 = Direction.offsetZ[k2]; - boolean flag1 = !this.worldServerInstance.isAirBlock(i + l2 + j3, j, k + i3 + k3) - || !this.worldServerInstance.isAirBlock(i + l2 + j3, j + 1, k + i3 + k3); - boolean flag2 = !this.worldServerInstance.isAirBlock(i + l2, j, k + i3) - || !this.worldServerInstance.isAirBlock(i + l2, j + 1, k + i3); - - if (flag1 && flag2) { - i4 = Direction.rotateOpposite[i4]; - k2 = Direction.rotateOpposite[k2]; - l2 = Direction.offsetX[i4]; - i3 = Direction.offsetZ[i4]; - j3 = Direction.offsetX[k2]; - k3 = Direction.offsetZ[k2]; - l3 = i - j3; - d11 -= j3; - int k1 = k - k3; - d7 -= k3; - flag1 = !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j, k1 + i3 + k3) - || !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j + 1, k1 + i3 + k3); - flag2 = !this.worldServerInstance.isAirBlock(l3 + l2, j, k1 + i3) - || !this.worldServerInstance.isAirBlock(l3 + l2, j + 1, k1 + i3); - } - - float f1 = 0.5F; - float f2 = 0.5F; - - if (!flag1 && flag2) { - f1 = 1.0F; - } - else if (flag1 && !flag2) { - f1 = 0.0F; - } - else if (flag1 && flag2) { - f2 = 0.0F; - } - - d11 += j3 * f1 + f2 * l2; - d7 += k3 * f1 + f2 * i3; - float f3 = 0.0F; - float f4 = 0.0F; - float f5 = 0.0F; - float f6 = 0.0F; - - if (i4 == j2) { - f3 = 1.0F; - f4 = 1.0F; - } - else if (i4 == Direction.rotateOpposite[j2]) { - f3 = -1.0F; - f4 = -1.0F; - } - else if (i4 == Direction.rotateRight[j2]) { - f5 = 1.0F; - f6 = -1.0F; - } - else { - f5 = -1.0F; - f6 = 1.0F; - } - - double d9 = par1Entity.motionX; - double d10 = par1Entity.motionZ; - par1Entity.motionX = d9 * f3 + d10 * f6; - par1Entity.motionZ = d9 * f5 + d10 * f4; - par1Entity.rotationYaw = par8 - j2 * 90 + i4 * 90; - } - else { - par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; - } - - par1Entity.setLocationAndAngles(d11, d6, d7, par1Entity.rotationYaw, par1Entity.rotationPitch); - return true; - } - else { - return false; - } - } - - @Override - public boolean makePortal(Entity par1Entity) { - byte b0 = 16; - double d0 = -1.0D; - int i = MathHelper.floor_double(par1Entity.posX); - int j = MathHelper.floor_double(par1Entity.posY); - int k = MathHelper.floor_double(par1Entity.posZ); - int l = i; - int i1 = j; - int j1 = k; - int k1 = 0; - int l1 = this.random.nextInt(4); - int i2; - double d1; - double d2; - int k2; - int i3; - int k3; - int j3; - int i4; - int l3; - int k4; - int j4; - int i5; - int l4; - double d3; - double d4; - - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = i2 + 0.5D - par1Entity.posX; - - for (k2 = k - b0; k2 <= k + b0; ++k2) { - d2 = k2 + 0.5D - par1Entity.posZ; - label274: - - for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { - if (this.worldServerInstance.isAirBlock(i2, i3, k2)) { - while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) { - --i3; - } - - for (j3 = l1; j3 < l1 + 4; ++j3) { - k3 = j3 % 2; - l3 = 1 - k3; - - if (j3 % 4 >= 2) { - k3 = -k3; - l3 = -l3; - } - - for (i4 = 0; i4 < 3; ++i4) { - for (j4 = 0; j4 < 4; ++j4) { - for (k4 = -1; k4 < 4; ++k4) { - l4 = i2 + (j4 - 1) * k3 + i4 * l3; - i5 = i3 + k4; - int j5 = k2 + (j4 - 1) * l3 - i4 * k3; - - if (k4 < 0 - && !this.worldServerInstance.getBlock(l4, i5, j5).getMaterial() - .isSolid() - || k4 >= 0 && !this.worldServerInstance.isAirBlock(l4, i5, j5)) { - continue label274; - } - } - } - } - - d4 = i3 + 0.5D - par1Entity.posY; - d3 = d1 * d1 + d4 * d4 + d2 * d2; - - if (d0 < 0.0D || d3 < d0) { - d0 = d3; - l = i2; - i1 = i3; - j1 = k2; - k1 = j3 % 4; - } - } - } - } - } - } - - if (d0 < 0.0D) { - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = i2 + 0.5D - par1Entity.posX; - - for (k2 = k - b0; k2 <= k + b0; ++k2) { - d2 = k2 + 0.5D - par1Entity.posZ; - label222: - - for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { - if (this.worldServerInstance.isAirBlock(i2, i3, k2)) { - while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) { - --i3; - } - - for (j3 = l1; j3 < l1 + 2; ++j3) { - k3 = j3 % 2; - l3 = 1 - k3; - - for (i4 = 0; i4 < 4; ++i4) { - for (j4 = -1; j4 < 4; ++j4) { - k4 = i2 + (i4 - 1) * k3; - l4 = i3 + j4; - i5 = k2 + (i4 - 1) * l3; - - if (j4 < 0 - && !this.worldServerInstance.getBlock(k4, l4, i5).getMaterial() - .isSolid() - || j4 >= 0 && !this.worldServerInstance.isAirBlock(k4, l4, i5)) { - continue label222; - } - } - } - - d4 = i3 + 0.5D - par1Entity.posY; - d3 = d1 * d1 + d4 * d4 + d2 * d2; - - if (d0 < 0.0D || d3 < d0) { - d0 = d3; - l = i2; - i1 = i3; - j1 = k2; - k1 = j3 % 2; - } - } - } - } - } - } - } - - int k5 = l; - int j2 = i1; - k2 = j1; - int l5 = k1 % 2; - int l2 = 1 - l5; - - if (k1 % 4 >= 2) { - l5 = -l5; - l2 = -l2; - } - - boolean flag; - - if (d0 < 0.0D) { - if (i1 < 70) { - i1 = 70; - } - - if (i1 > this.worldServerInstance.getActualHeight() - 10) { - i1 = this.worldServerInstance.getActualHeight() - 10; - } - - j2 = i1; - - for (i3 = -1; i3 <= 1; ++i3) { - for (j3 = 1; j3 < 3; ++j3) { - for (k3 = -1; k3 < 3; ++k3) { - l3 = k5 + (j3 - 1) * l5 + i3 * l2; - i4 = j2 + k3; - j4 = k2 + (j3 - 1) * l2 - i3 * l5; - flag = k3 < 0; - this.worldServerInstance.setBlock(l3, i4, j4, flag ? Dimension_Australia.blockPortalFrame : Blocks.air); - } - } - } - } - - for (i3 = 0; i3 < 4; ++i3) { - for (j3 = 0; j3 < 4; ++j3) { - for (k3 = -1; k3 < 4; ++k3) { - l3 = k5 + (j3 - 1) * l5; - i4 = j2 + k3; - j4 = k2 + (j3 - 1) * l2; - flag = j3 == 0 || j3 == 3 || k3 == -1 || k3 == 3; - this.worldServerInstance.setBlock(l3, i4, j4, flag ? Dimension_Australia.blockPortalFrame : Dimension_Australia.portalBlock, 0, 2); - } - } - - for (j3 = 0; j3 < 4; ++j3) { - for (k3 = -1; k3 < 4; ++k3) { - l3 = k5 + (j3 - 1) * l5; - i4 = j2 + k3; - j4 = k2 + (j3 - 1) * l2; - this.worldServerInstance.notifyBlocksOfNeighborChange(l3, i4, j4, - this.worldServerInstance.getBlock(l3, i4, j4)); - } - } - } - - return true; - } - - /** - * called periodically to remove out-of-date portal locations from the - * cache list. Argument par1 is a WorldServer.getTotalWorldTime() value. - */ - @Override - public void removeStalePortalLocations(long par1) { - if (par1 % 100L == 0L) { - @SuppressWarnings("rawtypes") - Iterator iterator = this.destinationCoordinateKeys.iterator(); - long j = par1 - 600L; - - while (iterator.hasNext()) { - Long olong = (Long) iterator.next(); - Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition) this.destinationCoordinateCache - .getValueByKey(olong.longValue()); - - if (portalposition == null || portalposition.lastUpdateTime < j) { - iterator.remove(); - this.destinationCoordinateCache.remove(olong.longValue()); - } - } - } - } - - public class PortalPosition extends ChunkCoordinates { - /** - * The worldtime at which this PortalPosition was last verified - */ - public long lastUpdateTime; - - public PortalPosition(int par2, int par3, int par4, long par5) { - super(par2, par3, par4); - this.lastUpdateTime = par5; - } - } -}
\ No newline at end of file + private final WorldServer worldServerInstance; + /** + * A private Random() function in Teleporter + */ + private final Random random; + /** + * Stores successful portal placement locations for rapid lookup. + */ + private final LongHashMap destinationCoordinateCache = new LongHashMap(); + /** + * A list of valid keys for the destinationCoordainteCache. These are + * based on the X & Z of the players initial location. + */ + @SuppressWarnings("rawtypes") + private final List destinationCoordinateKeys = new ArrayList(); + + public AustraliaTeleporterDimensionMod(WorldServer par1WorldServer) { + super(par1WorldServer); + this.worldServerInstance = par1WorldServer; + this.random = new Random(par1WorldServer.getSeed()); + } + + /** + * Place an entity in a nearby portal, creating one if necessary. + */ + @Override + public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { + if (this.worldServerInstance.provider.dimensionId != 1) { + if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) { + this.makePortal(par1Entity); + this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); + } + } else { + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY) - 1; + int k = MathHelper.floor_double(par1Entity.posZ); + byte b0 = 1; + byte b1 = 0; + + for (int l = -2; l <= 2; ++l) { + for (int i1 = -2; i1 <= 2; ++i1) { + for (int j1 = -1; j1 < 3; ++j1) { + int k1 = i + i1 * b0 + l * b1; + int l1 = j + j1; + int i2 = k + i1 * b1 - l * b0; + boolean flag = j1 < 0; + this.worldServerInstance.setBlock( + k1, l1, i2, flag ? Dimension_Australia.blockPortalFrame : Blocks.air); + } + } + } + + par1Entity.setLocationAndAngles(i, j, k, par1Entity.rotationYaw, 0.0F); + par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; + } + } + + /** + * Place an entity in a nearby portal which already exists. + */ + @Override + public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { + short short1 = 128; + double d3 = -1.0D; + int i = 0; + int j = 0; + int k = 0; + int l = MathHelper.floor_double(par1Entity.posX); + int i1 = MathHelper.floor_double(par1Entity.posZ); + long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); + boolean flag = true; + double d7; + int l3; + + if (this.destinationCoordinateCache.containsItem(j1)) { + Teleporter.PortalPosition portalposition = + (Teleporter.PortalPosition) this.destinationCoordinateCache.getValueByKey(j1); + d3 = 0.0D; + i = portalposition.posX; + j = portalposition.posY; + k = portalposition.posZ; + portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); + flag = false; + } else { + for (l3 = l - short1; l3 <= l + short1; ++l3) { + double d4 = l3 + 0.5D - par1Entity.posX; + + for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { + double d5 = l1 + 0.5D - par1Entity.posZ; + + for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) { + if (this.worldServerInstance.getBlock(l3, i2, l1) == Dimension_Australia.portalBlock) { + while (this.worldServerInstance.getBlock(l3, i2 - 1, l1) + == Dimension_Australia.portalBlock) { + --i2; + } + + d7 = i2 + 0.5D - par1Entity.posY; + double d8 = d4 * d4 + d7 * d7 + d5 * d5; + + if (d3 < 0.0D || d8 < d3) { + d3 = d8; + i = l3; + j = i2; + k = l1; + } + } + } + } + } + } + + if (d3 >= 0.0D) { + if (flag) { + this.destinationCoordinateCache.add( + j1, new Teleporter.PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); + this.destinationCoordinateKeys.add(Long.valueOf(j1)); + } + + double d11 = i + 0.5D; + double d6 = j + 0.5D; + d7 = k + 0.5D; + int i4 = -1; + + if (this.worldServerInstance.getBlock(i - 1, j, k) == Dimension_Australia.portalBlock) { + i4 = 2; + } + + if (this.worldServerInstance.getBlock(i + 1, j, k) == Dimension_Australia.portalBlock) { + i4 = 0; + } + + if (this.worldServerInstance.getBlock(i, j, k - 1) == Dimension_Australia.portalBlock) { + i4 = 3; + } + + if (this.worldServerInstance.getBlock(i, j, k + 1) == Dimension_Australia.portalBlock) { + i4 = 1; + } + + int j2 = par1Entity.getTeleportDirection(); + + if (i4 > -1) { + int k2 = Direction.rotateLeft[i4]; + int l2 = Direction.offsetX[i4]; + int i3 = Direction.offsetZ[i4]; + int j3 = Direction.offsetX[k2]; + int k3 = Direction.offsetZ[k2]; + boolean flag1 = !this.worldServerInstance.isAirBlock(i + l2 + j3, j, k + i3 + k3) + || !this.worldServerInstance.isAirBlock(i + l2 + j3, j + 1, k + i3 + k3); + boolean flag2 = !this.worldServerInstance.isAirBlock(i + l2, j, k + i3) + || !this.worldServerInstance.isAirBlock(i + l2, j + 1, k + i3); + + if (flag1 && flag2) { + i4 = Direction.rotateOpposite[i4]; + k2 = Direction.rotateOpposite[k2]; + l2 = Direction.offsetX[i4]; + i3 = Direction.offsetZ[i4]; + j3 = Direction.offsetX[k2]; + k3 = Direction.offsetZ[k2]; + l3 = i - j3; + d11 -= j3; + int k1 = k - k3; + d7 -= k3; + flag1 = !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j, k1 + i3 + k3) + || !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j + 1, k1 + i3 + k3); + flag2 = !this.worldServerInstance.isAirBlock(l3 + l2, j, k1 + i3) + || !this.worldServerInstance.isAirBlock(l3 + l2, j + 1, k1 + i3); + } + + float f1 = 0.5F; + float f2 = 0.5F; + + if (!flag1 && flag2) { + f1 = 1.0F; + } else if (flag1 && !flag2) { + f1 = 0.0F; + } else if (flag1 && flag2) { + f2 = 0.0F; + } + + d11 += j3 * f1 + f2 * l2; + d7 += k3 * f1 + f2 * i3; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + + if (i4 == j2) { + f3 = 1.0F; + f4 = 1.0F; + } else if (i4 == Direction.rotateOpposite[j2]) { + f3 = -1.0F; + f4 = -1.0F; + } else if (i4 == Direction.rotateRight[j2]) { + f5 = 1.0F; + f6 = -1.0F; + } else { + f5 = -1.0F; + f6 = 1.0F; + } + + double d9 = par1Entity.motionX; + double d10 = par1Entity.motionZ; + par1Entity.motionX = d9 * f3 + d10 * f6; + par1Entity.motionZ = d9 * f5 + d10 * f4; + par1Entity.rotationYaw = par8 - j2 * 90 + i4 * 90; + } else { + par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; + } + + par1Entity.setLocationAndAngles(d11, d6, d7, par1Entity.rotationYaw, par1Entity.rotationPitch); + return true; + } else { + return false; + } + } + + @Override + public boolean makePortal(Entity par1Entity) { + byte b0 = 16; + double d0 = -1.0D; + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY); + int k = MathHelper.floor_double(par1Entity.posZ); + int l = i; + int i1 = j; + int j1 = k; + int k1 = 0; + int l1 = this.random.nextInt(4); + int i2; + double d1; + double d2; + int k2; + int i3; + int k3; + int j3; + int i4; + int l3; + int k4; + int j4; + int i5; + int l4; + double d3; + double d4; + + for (i2 = i - b0; i2 <= i + b0; ++i2) { + d1 = i2 + 0.5D - par1Entity.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) { + d2 = k2 + 0.5D - par1Entity.posZ; + label274: + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) { + --i3; + } + + for (j3 = l1; j3 < l1 + 4; ++j3) { + k3 = j3 % 2; + l3 = 1 - k3; + + if (j3 % 4 >= 2) { + k3 = -k3; + l3 = -l3; + } + + for (i4 = 0; i4 < 3; ++i4) { + for (j4 = 0; j4 < 4; ++j4) { + for (k4 = -1; k4 < 4; ++k4) { + l4 = i2 + (j4 - 1) * k3 + i4 * l3; + i5 = i3 + k4; + int j5 = k2 + (j4 - 1) * l3 - i4 * k3; + + if (k4 < 0 + && !this.worldServerInstance + .getBlock(l4, i5, j5) + .getMaterial() + .isSolid() + || k4 >= 0 && !this.worldServerInstance.isAirBlock(l4, i5, j5)) { + continue label274; + } + } + } + } + + d4 = i3 + 0.5D - par1Entity.posY; + d3 = d1 * d1 + d4 * d4 + d2 * d2; + + if (d0 < 0.0D || d3 < d0) { + d0 = d3; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 4; + } + } + } + } + } + } + + if (d0 < 0.0D) { + for (i2 = i - b0; i2 <= i + b0; ++i2) { + d1 = i2 + 0.5D - par1Entity.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) { + d2 = k2 + 0.5D - par1Entity.posZ; + label222: + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) { + --i3; + } + + for (j3 = l1; j3 < l1 + 2; ++j3) { + k3 = j3 % 2; + l3 = 1 - k3; + + for (i4 = 0; i4 < 4; ++i4) { + for (j4 = -1; j4 < 4; ++j4) { + k4 = i2 + (i4 - 1) * k3; + l4 = i3 + j4; + i5 = k2 + (i4 - 1) * l3; + + if (j4 < 0 + && !this.worldServerInstance + .getBlock(k4, l4, i5) + .getMaterial() + .isSolid() + || j4 >= 0 && !this.worldServerInstance.isAirBlock(k4, l4, i5)) { + continue label222; + } + } + } + + d4 = i3 + 0.5D - par1Entity.posY; + d3 = d1 * d1 + d4 * d4 + d2 * d2; + + if (d0 < 0.0D || d3 < d0) { + d0 = d3; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 2; + } + } + } + } + } + } + } + + int k5 = l; + int j2 = i1; + k2 = j1; + int l5 = k1 % 2; + int l2 = 1 - l5; + + if (k1 % 4 >= 2) { + l5 = -l5; + l2 = -l2; + } + + boolean flag; + + if (d0 < 0.0D) { + if (i1 < 70) { + i1 = 70; + } + + if (i1 > this.worldServerInstance.getActualHeight() - 10) { + i1 = this.worldServerInstance.getActualHeight() - 10; + } + + j2 = i1; + + for (i3 = -1; i3 <= 1; ++i3) { + for (j3 = 1; j3 < 3; ++j3) { + for (k3 = -1; k3 < 3; ++k3) { + l3 = k5 + (j3 - 1) * l5 + i3 * l2; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2 - i3 * l5; + flag = k3 < 0; + this.worldServerInstance.setBlock( + l3, i4, j4, flag ? Dimension_Australia.blockPortalFrame : Blocks.air); + } + } + } + } + + for (i3 = 0; i3 < 4; ++i3) { + for (j3 = 0; j3 < 4; ++j3) { + for (k3 = -1; k3 < 4; ++k3) { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + flag = j3 == 0 || j3 == 3 || k3 == -1 || k3 == 3; + this.worldServerInstance.setBlock( + l3, + i4, + j4, + flag ? Dimension_Australia.blockPortalFrame : Dimension_Australia.portalBlock, + 0, + 2); + } + } + + for (j3 = 0; j3 < 4; ++j3) { + for (k3 = -1; k3 < 4; ++k3) { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + this.worldServerInstance.notifyBlocksOfNeighborChange( + l3, i4, j4, this.worldServerInstance.getBlock(l3, i4, j4)); + } + } + } + + return true; + } + + /** + * called periodically to remove out-of-date portal locations from the + * cache list. Argument par1 is a WorldServer.getTotalWorldTime() value. + */ + @Override + public void removeStalePortalLocations(long par1) { + if (par1 % 100L == 0L) { + @SuppressWarnings("rawtypes") + Iterator iterator = this.destinationCoordinateKeys.iterator(); + long j = par1 - 600L; + + while (iterator.hasNext()) { + Long olong = (Long) iterator.next(); + Teleporter.PortalPosition portalposition = + (Teleporter.PortalPosition) this.destinationCoordinateCache.getValueByKey(olong.longValue()); + + if (portalposition == null || portalposition.lastUpdateTime < j) { + iterator.remove(); + this.destinationCoordinateCache.remove(olong.longValue()); + } + } + } + } + + public class PortalPosition extends ChunkCoordinates { + /** + * The worldtime at which this PortalPosition was last verified + */ + public long lastUpdateTime; + + public PortalPosition(int par2, int par3, int par4, long par5) { + super(par2, par3, par4); + this.lastUpdateTime = par5; + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java index f0bd35a8b9..2b3a02203f 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java @@ -1,12 +1,11 @@ package gtPlusPlus.australia.world; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.australia.biome.GenLayerAustralia; import java.util.ArrayList; import java.util.List; import java.util.Random; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.util.ReportedException; @@ -18,240 +17,224 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.IntCache; -import gtPlusPlus.australia.biome.GenLayerAustralia; public class AustraliaWorldChunkManager extends WorldChunkManager { - private GenLayer genBiomes; - /** A GenLayer containing the indices into BiomeGenBase.biomeList[] */ - private GenLayer biomeIndexLayer; - /** The BiomeCache object for this world. */ - private BiomeCache biomeCache; - /** A list of biomes that the player can spawn in. */ - private List<BiomeGenBase> biomesToSpawnIn; - - @SuppressWarnings({ "rawtypes" }) - public AustraliaWorldChunkManager() { - this.biomeCache = new BiomeCache(this); - this.biomesToSpawnIn = new ArrayList(); - this.biomesToSpawnIn.addAll(allowedBiomes); // TODO - } - - public AustraliaWorldChunkManager(long seed, WorldType worldType) { - this(); - // i changed this to my GenLayerDarkWorld - GenLayer[] agenlayer = GenLayerAustralia.makeTheWorld(seed, worldType); - - agenlayer = getModdedBiomeGenerators(worldType, seed, agenlayer); - this.genBiomes = agenlayer[0]; - this.biomeIndexLayer = agenlayer[1]; - - - - } - - public AustraliaWorldChunkManager(World world) { - this(world.getSeed(), world.getWorldInfo().getTerrainType()); - - } - - /** - * Gets the list of valid biomes for the player to spawn in. - */ - @Override - public List<BiomeGenBase> getBiomesToSpawnIn() { - return this.biomesToSpawnIn; - } - - /** - * Returns a list of rainfall values for the specified blocks. Args: - * listToReuse, x, z, width, length. - */ - @Override - public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) { - IntCache.resetIntCache(); - - if ((listToReuse == null) || (listToReuse.length < width * length)) { - listToReuse = new float[width * length]; - } - int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); - for (int i1 = 0; i1 < width * length; i1++) { - try - { - float f = BiomeGenBase.getBiome(aint[i1]).getIntRainfall() / 65536.0F; - if (f > 1.0F) { - f = 1.0F; - } - listToReuse[i1] = f; - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); - CrashReportCategory crashreportcategory = crashreport.makeCategory("DownfallBlock"); - crashreportcategory.addCrashSection("biome id", Integer.valueOf(i1)); - crashreportcategory.addCrashSection("downfalls[] size", Integer.valueOf(listToReuse.length)); - crashreportcategory.addCrashSection("x", Integer.valueOf(x)); - crashreportcategory.addCrashSection("z", Integer.valueOf(z)); - crashreportcategory.addCrashSection("w", Integer.valueOf(width)); - crashreportcategory.addCrashSection("h", Integer.valueOf(length)); - throw new ReportedException(crashreport); - } - } - return listToReuse; - } - - /** - * Return an adjusted version of a given temperature based on the y - * height - */ - @Override - @SideOnly(Side.CLIENT) - public float getTemperatureAtHeight(float par1, int par2) { - return par1; - } - - /** - * Returns an array of biomes for the location input. - */ - @Override - public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { - IntCache.resetIntCache(); - - if ((par1ArrayOfBiomeGenBase == null) || (par1ArrayOfBiomeGenBase.length < par4 * par5)) { - par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; - } - int[] aint = this.genBiomes.getInts(par2, par3, par4, par5); - try - { - for (int i = 0; i < par4 * par5; i++) { - par1ArrayOfBiomeGenBase[i] = BiomeGenBase.getBiome(aint[i]); - } - return par1ArrayOfBiomeGenBase; - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); - CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock"); - crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(par1ArrayOfBiomeGenBase.length)); - crashreportcategory.addCrashSection("x", Integer.valueOf(par2)); - crashreportcategory.addCrashSection("z", Integer.valueOf(par3)); - crashreportcategory.addCrashSection("w", Integer.valueOf(par4)); - crashreportcategory.addCrashSection("h", Integer.valueOf(par5)); - throw new ReportedException(crashreport); - } - - } - - /** - * Returns biomes to use for the blocks and loads the other data like - * temperature and humidity onto the WorldChunkManager Args: - * oldBiomeList, x, z, width, depth - */ - @Override - public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] oldBiomeList, int x, int z, int width, int depth) { - return this.getBiomeGenAt(oldBiomeList, x, z, width, depth, true); - } - - /** - * Return a list of biomes for the specified blocks. Args: listToReuse, - * x, y, width, length, cacheFlag (if false, don't check biomeCache to - * avoid infinite loop in BiomeCacheBlock) - */ - @Override - public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] listToReuse, int x, int y, int width, int length, boolean cacheFlag) { - IntCache.resetIntCache(); - if ((listToReuse == null) || (listToReuse.length < width * length)) { - listToReuse = new BiomeGenBase[width * length]; - } - if ((cacheFlag) && (width == 16) && (length == 16) && ((x & 0xF) == 0) && ((y & 0xF) == 0)) - { - BiomeGenBase[] abiomegenbase1 = this.biomeCache.getCachedBiomes(x, y); - System.arraycopy(abiomegenbase1, 0, listToReuse, 0, width * length); - return listToReuse; - } - int[] aint = this.biomeIndexLayer.getInts(x, y, width, length); - for (int i = 0; i < width * length; i++) { - listToReuse[i] = BiomeGenBase.getBiome(aint[i]); - } - return listToReuse; - } - - /** - * checks given Chunk's Biomes against List of allowed ones - */ - @Override - @SuppressWarnings("rawtypes") - public boolean areBiomesViable(int x, int y, int z, List par4List) { - IntCache.resetIntCache(); - int l = x - z >> 2; - int i1 = y - z >> 2; - int j1 = x + z >> 2; - int k1 = y + z >> 2; - int l1 = j1 - l + 1; - int i2 = k1 - i1 + 1; - int[] aint = this.genBiomes.getInts(l, i1, l1, i2); - try - { - for (int j2 = 0; j2 < l1 * i2; j2++) - { - BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[j2]); - if (!par4List.contains(biomegenbase)) { - return false; - } - } - return true; - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); - CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer"); - crashreportcategory.addCrashSection("Layer", this.genBiomes.toString()); - crashreportcategory.addCrashSection("x", Integer.valueOf(x)); - crashreportcategory.addCrashSection("z", Integer.valueOf(y)); - crashreportcategory.addCrashSection("radius", Integer.valueOf(z)); - crashreportcategory.addCrashSection("allowed", par4List); - throw new ReportedException(crashreport); - } - } - - /** - * Finds a valid position within a range, that is in one of the listed - * biomes. Searches {par1,par2} +-par3 blocks. Strongly favors positive - * y positions. - */ - @Override - @SuppressWarnings("rawtypes") - public ChunkPosition findBiomePosition(int p_150795_1_, int p_150795_2_, int p_150795_3_, List p_150795_4_, Random p_150795_5_) { - IntCache.resetIntCache(); - int l = p_150795_1_ - p_150795_3_ >> 2; - int i1 = p_150795_2_ - p_150795_3_ >> 2; - int j1 = p_150795_1_ + p_150795_3_ >> 2; - int k1 = p_150795_2_ + p_150795_3_ >> 2; - int l1 = j1 - l + 1; - int i2 = k1 - i1 + 1; - int[] aint = this.genBiomes.getInts(l, i1, l1, i2); - ChunkPosition chunkposition = null; - int j2 = 0; - for (int k2 = 0; k2 < l1 * i2; k2++) - { - int l2 = l + k2 % l1 << 2; - int i3 = i1 + k2 / l1 << 2; - BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[k2]); - if ((p_150795_4_.contains(biomegenbase)) && ((chunkposition == null) || (p_150795_5_.nextInt(j2 + 1) == 0))) - { - chunkposition = new ChunkPosition(l2, 0, i3); - j2++; - } - } - return chunkposition; - } - - /** - * Calls the WorldChunkManager's biomeCache.cleanupCache() - */ - @Override - public void cleanupCache() { - this.biomeCache.cleanupCache(); - } - -}
\ No newline at end of file + private GenLayer genBiomes; + /** A GenLayer containing the indices into BiomeGenBase.biomeList[] */ + private GenLayer biomeIndexLayer; + /** The BiomeCache object for this world. */ + private BiomeCache biomeCache; + /** A list of biomes that the player can spawn in. */ + private List<BiomeGenBase> biomesToSpawnIn; + + @SuppressWarnings({"rawtypes"}) + public AustraliaWorldChunkManager() { + this.biomeCache = new BiomeCache(this); + this.biomesToSpawnIn = new ArrayList(); + this.biomesToSpawnIn.addAll(allowedBiomes); // TODO + } + + public AustraliaWorldChunkManager(long seed, WorldType worldType) { + this(); + // i changed this to my GenLayerDarkWorld + GenLayer[] agenlayer = GenLayerAustralia.makeTheWorld(seed, worldType); + + agenlayer = getModdedBiomeGenerators(worldType, seed, agenlayer); + this.genBiomes = agenlayer[0]; + this.biomeIndexLayer = agenlayer[1]; + } + + public AustraliaWorldChunkManager(World world) { + this(world.getSeed(), world.getWorldInfo().getTerrainType()); + } + + /** + * Gets the list of valid biomes for the player to spawn in. + */ + @Override + public List<BiomeGenBase> getBiomesToSpawnIn() { + return this.biomesToSpawnIn; + } + + /** + * Returns a list of rainfall values for the specified blocks. Args: + * listToReuse, x, z, width, length. + */ + @Override + public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) { + IntCache.resetIntCache(); + + if ((listToReuse == null) || (listToReuse.length < width * length)) { + listToReuse = new float[width * length]; + } + int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); + for (int i1 = 0; i1 < width * length; i1++) { + try { + float f = BiomeGenBase.getBiome(aint[i1]).getIntRainfall() / 65536.0F; + if (f > 1.0F) { + f = 1.0F; + } + listToReuse[i1] = f; + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("DownfallBlock"); + crashreportcategory.addCrashSection("biome id", Integer.valueOf(i1)); + crashreportcategory.addCrashSection("downfalls[] size", Integer.valueOf(listToReuse.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(x)); + crashreportcategory.addCrashSection("z", Integer.valueOf(z)); + crashreportcategory.addCrashSection("w", Integer.valueOf(width)); + crashreportcategory.addCrashSection("h", Integer.valueOf(length)); + throw new ReportedException(crashreport); + } + } + return listToReuse; + } + + /** + * Return an adjusted version of a given temperature based on the y + * height + */ + @Override + @SideOnly(Side.CLIENT) + public float getTemperatureAtHeight(float par1, int par2) { + return par1; + } + + /** + * Returns an array of biomes for the location input. + */ + @Override + public BiomeGenBase[] getBiomesForGeneration( + BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { + IntCache.resetIntCache(); + + if ((par1ArrayOfBiomeGenBase == null) || (par1ArrayOfBiomeGenBase.length < par4 * par5)) { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + int[] aint = this.genBiomes.getInts(par2, par3, par4, par5); + try { + for (int i = 0; i < par4 * par5; i++) { + par1ArrayOfBiomeGenBase[i] = BiomeGenBase.getBiome(aint[i]); + } + return par1ArrayOfBiomeGenBase; + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock"); + crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(par1ArrayOfBiomeGenBase.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("z", Integer.valueOf(par3)); + crashreportcategory.addCrashSection("w", Integer.valueOf(par4)); + crashreportcategory.addCrashSection("h", Integer.valueOf(par5)); + throw new ReportedException(crashreport); + } + } + + /** + * Returns biomes to use for the blocks and loads the other data like + * temperature and humidity onto the WorldChunkManager Args: + * oldBiomeList, x, z, width, depth + */ + @Override + public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] oldBiomeList, int x, int z, int width, int depth) { + return this.getBiomeGenAt(oldBiomeList, x, z, width, depth, true); + } + + /** + * Return a list of biomes for the specified blocks. Args: listToReuse, + * x, y, width, length, cacheFlag (if false, don't check biomeCache to + * avoid infinite loop in BiomeCacheBlock) + */ + @Override + public BiomeGenBase[] getBiomeGenAt( + BiomeGenBase[] listToReuse, int x, int y, int width, int length, boolean cacheFlag) { + IntCache.resetIntCache(); + if ((listToReuse == null) || (listToReuse.length < width * length)) { + listToReuse = new BiomeGenBase[width * length]; + } + if ((cacheFlag) && (width == 16) && (length == 16) && ((x & 0xF) == 0) && ((y & 0xF) == 0)) { + BiomeGenBase[] abiomegenbase1 = this.biomeCache.getCachedBiomes(x, y); + System.arraycopy(abiomegenbase1, 0, listToReuse, 0, width * length); + return listToReuse; + } + int[] aint = this.biomeIndexLayer.getInts(x, y, width, length); + for (int i = 0; i < width * length; i++) { + listToReuse[i] = BiomeGenBase.getBiome(aint[i]); + } + return listToReuse; + } + + /** + * checks given Chunk's Biomes against List of allowed ones + */ + @Override + @SuppressWarnings("rawtypes") + public boolean areBiomesViable(int x, int y, int z, List par4List) { + IntCache.resetIntCache(); + int l = x - z >> 2; + int i1 = y - z >> 2; + int j1 = x + z >> 2; + int k1 = y + z >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + try { + for (int j2 = 0; j2 < l1 * i2; j2++) { + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[j2]); + if (!par4List.contains(biomegenbase)) { + return false; + } + } + return true; + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer"); + crashreportcategory.addCrashSection("Layer", this.genBiomes.toString()); + crashreportcategory.addCrashSection("x", Integer.valueOf(x)); + crashreportcategory.addCrashSection("z", Integer.valueOf(y)); + crashreportcategory.addCrashSection("radius", Integer.valueOf(z)); + crashreportcategory.addCrashSection("allowed", par4List); + throw new ReportedException(crashreport); + } + } + + /** + * Finds a valid position within a range, that is in one of the listed + * biomes. Searches {par1,par2} +-par3 blocks. Strongly favors positive + * y positions. + */ + @Override + @SuppressWarnings("rawtypes") + public ChunkPosition findBiomePosition( + int p_150795_1_, int p_150795_2_, int p_150795_3_, List p_150795_4_, Random p_150795_5_) { + IntCache.resetIntCache(); + int l = p_150795_1_ - p_150795_3_ >> 2; + int i1 = p_150795_2_ - p_150795_3_ >> 2; + int j1 = p_150795_1_ + p_150795_3_ >> 2; + int k1 = p_150795_2_ + p_150795_3_ >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + ChunkPosition chunkposition = null; + int j2 = 0; + for (int k2 = 0; k2 < l1 * i2; k2++) { + int l2 = l + k2 % l1 << 2; + int i3 = i1 + k2 / l1 << 2; + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[k2]); + if ((p_150795_4_.contains(biomegenbase)) + && ((chunkposition == null) || (p_150795_5_.nextInt(j2 + 1) == 0))) { + chunkposition = new ChunkPosition(l2, 0, i3); + j2++; + } + } + return chunkposition; + } + + /** + * Calls the WorldChunkManager's biomeCache.cleanupCache() + */ + @Override + public void cleanupCache() { + this.biomeCache.cleanupCache(); + } +} diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldGenerator.java b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldGenerator.java index 93112bb30f..d3fe343d80 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldGenerator.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldGenerator.java @@ -2,14 +2,11 @@ package gtPlusPlus.australia.world; import cpw.mods.fml.common.IWorldGenerator; import gtPlusPlus.api.interfaces.IGeneratorWorld; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.australia.GTplusplus_Australia; -import gtPlusPlus.australia.gen.map.MapGenExtendedVillage; import gtPlusPlus.australia.gen.map.component.ComponentHut.WorldHandlerHut; import gtPlusPlus.australia.gen.map.component.ComponentShack.WorldHandlerShack; import gtPlusPlus.core.lib.CORE; - import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; @@ -17,126 +14,132 @@ import java.util.List; import java.util.Random; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; public class AustraliaWorldGenerator implements IWorldGenerator { - private LinkedList<ChunkCoordIntPair> structuresList = new LinkedList<ChunkCoordIntPair>(); - //private final WorldHandlerCoven covenGen; - //private final WorldHandlerWickerMan wickerManGen; - private final WorldHandlerShack shackGen; - private final WorldHandlerHut hutGen; - private final List<IGeneratorWorld> generators; - private int midX; - private int midZ; - int field_82665_g; - int field_82666_h = 8; - - public static final AutoMap<Integer> SHACK_ALLOWED_BIOMES = new AutoMap<Integer>(); - public static final AutoMap<Integer> HUT_ALLOWED_BIOMES = new AutoMap<Integer>(); - public static final AutoMap<Integer> ALLOWED_BIOMES = new AutoMap<Integer>(); - - public AustraliaWorldGenerator() { - - SHACK_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Plains_Biome.biomeID); - SHACK_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Forest_Biome.biomeID); - HUT_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Desert_Biome_3.biomeID); - HUT_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Outback_Biome.biomeID); - - ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Plains_Biome.biomeID); - ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Forest_Biome.biomeID); - ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Desert_Biome_3.biomeID); - ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Outback_Biome.biomeID); - - - this.shackGen = new WorldHandlerShack(3); - this.hutGen = new WorldHandlerHut(5); - - //IGeneratorWorld goblinHut = new WorldHandlerClonedStructure(ComponentGoblinHut.class, 1.0D, 400, 7, 7, 7); - this.generators = Arrays - .asList(new IGeneratorWorld[] { this.shackGen, this.hutGen }); - - this.field_82665_g = (8 + Math.max(gtPlusPlus.core.util.math.MathUtils.randInt(/*Config.instance().worldGenFrequency*/32, 64), 1)); - - this.midX = 0; - this.midZ = 0; - for (IGeneratorWorld gen : this.generators) { - this.midX = Math.max(this.midX, gen.getExtentX() / 2); - this.midZ = Math.max(this.midZ, gen.getExtentZ() / 2); - } - } - - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, - IChunkProvider chunkProvider) { - if (world.provider.dimensionId == CORE.AUSTRALIA_ID) { - generateOverworld(world, world.rand, chunkX * 16, chunkZ * 16); - } - } - - private void generateOverworld(World world, Random random, int x, int z) { - boolean gen = false; - try { - if (ALLOWED_BIOMES.containsValue(Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { - Collections.shuffle(this.generators, random); - for (IGeneratorWorld generator : this.generators) { - boolean canGenerate = false; - - if (generator instanceof WorldHandlerShack) { - if (SHACK_ALLOWED_BIOMES.containsValue(Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { - canGenerate = true; - } - } - else if (generator instanceof WorldHandlerHut) { - if (HUT_ALLOWED_BIOMES.containsValue(Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { - canGenerate = true; - } - } - - if (canGenerate) { - //Logger.WORLD("Running World Generator on Australia."); - boolean a1, a2; - a1 = generator.generate(world, random, x, z); - a2 = nonInRange(world, x, z, generator.getRange()); - //Logger.INFO("A1: "+a1+" | A2: "+a2); - if (a1 && a2) { - this.structuresList.add(new ChunkCoordIntPair(x, z)); - gen = true; - //Logger.INFO("Generated a structure"); - break; - } - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - protected boolean nonInRange(World worldObj, int x, int z, int range) { - int par1 = x / 16; - int par2 = z / 16; - - int k = par1; - int l = par2; - if (par1 < 0) { - par1 -= this.field_82665_g - 1; - } - if (par2 < 0) { - par2 -= this.field_82665_g - 1; - } - int i1 = par1 / this.field_82665_g; - int j1 = par2 / this.field_82665_g; - Random random = worldObj.setRandomSeed(i1, j1, 10387312); - i1 *= this.field_82665_g; - j1 *= this.field_82665_g; - i1 += random.nextInt(this.field_82665_g - this.field_82666_h); - j1 += random.nextInt(this.field_82665_g - this.field_82666_h); - - return (k == i1) && (l == j1); - } - - public void initiate() { - this.structuresList.clear(); - } + private LinkedList<ChunkCoordIntPair> structuresList = new LinkedList<ChunkCoordIntPair>(); + // private final WorldHandlerCoven covenGen; + // private final WorldHandlerWickerMan wickerManGen; + private final WorldHandlerShack shackGen; + private final WorldHandlerHut hutGen; + private final List<IGeneratorWorld> generators; + private int midX; + private int midZ; + int field_82665_g; + int field_82666_h = 8; + + public static final AutoMap<Integer> SHACK_ALLOWED_BIOMES = new AutoMap<Integer>(); + public static final AutoMap<Integer> HUT_ALLOWED_BIOMES = new AutoMap<Integer>(); + public static final AutoMap<Integer> ALLOWED_BIOMES = new AutoMap<Integer>(); + + public AustraliaWorldGenerator() { + + SHACK_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Plains_Biome.biomeID); + SHACK_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Forest_Biome.biomeID); + HUT_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Desert_Biome_3.biomeID); + HUT_ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Outback_Biome.biomeID); + + ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Plains_Biome.biomeID); + ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Forest_Biome.biomeID); + ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Desert_Biome_3.biomeID); + ALLOWED_BIOMES.put(GTplusplus_Australia.Australian_Outback_Biome.biomeID); + + this.shackGen = new WorldHandlerShack(3); + this.hutGen = new WorldHandlerHut(5); + + // IGeneratorWorld goblinHut = new WorldHandlerClonedStructure(ComponentGoblinHut.class, 1.0D, 400, 7, 7, 7); + this.generators = Arrays.asList(new IGeneratorWorld[] {this.shackGen, this.hutGen}); + + this.field_82665_g = (8 + + Math.max( + gtPlusPlus.core.util.math.MathUtils.randInt(/*Config.instance().worldGenFrequency*/ 32, 64), + 1)); + + this.midX = 0; + this.midZ = 0; + for (IGeneratorWorld gen : this.generators) { + this.midX = Math.max(this.midX, gen.getExtentX() / 2); + this.midZ = Math.max(this.midZ, gen.getExtentZ() / 2); + } + } + + public void generate( + Random random, + int chunkX, + int chunkZ, + World world, + IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + if (world.provider.dimensionId == CORE.AUSTRALIA_ID) { + generateOverworld(world, world.rand, chunkX * 16, chunkZ * 16); + } + } + + private void generateOverworld(World world, Random random, int x, int z) { + boolean gen = false; + try { + if (ALLOWED_BIOMES.containsValue( + Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { + Collections.shuffle(this.generators, random); + for (IGeneratorWorld generator : this.generators) { + boolean canGenerate = false; + + if (generator instanceof WorldHandlerShack) { + if (SHACK_ALLOWED_BIOMES.containsValue( + Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { + canGenerate = true; + } + } else if (generator instanceof WorldHandlerHut) { + if (HUT_ALLOWED_BIOMES.containsValue( + Integer.valueOf(world.getBiomeGenForCoords(x + this.midX, z + this.midZ).biomeID))) { + canGenerate = true; + } + } + + if (canGenerate) { + // Logger.WORLD("Running World Generator on Australia."); + boolean a1, a2; + a1 = generator.generate(world, random, x, z); + a2 = nonInRange(world, x, z, generator.getRange()); + // Logger.INFO("A1: "+a1+" | A2: "+a2); + if (a1 && a2) { + this.structuresList.add(new ChunkCoordIntPair(x, z)); + gen = true; + // Logger.INFO("Generated a structure"); + break; + } + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + protected boolean nonInRange(World worldObj, int x, int z, int range) { + int par1 = x / 16; + int par2 = z / 16; + + int k = par1; + int l = par2; + if (par1 < 0) { + par1 -= this.field_82665_g - 1; + } + if (par2 < 0) { + par2 -= this.field_82665_g - 1; + } + int i1 = par1 / this.field_82665_g; + int j1 = par2 / this.field_82665_g; + Random random = worldObj.setRandomSeed(i1, j1, 10387312); + i1 *= this.field_82665_g; + j1 *= this.field_82665_g; + i1 += random.nextInt(this.field_82665_g - this.field_82666_h); + j1 += random.nextInt(this.field_82665_g - this.field_82666_h); + + return (k == i1) && (l == j1); + } + + public void initiate() { + this.structuresList.clear(); + } } diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldProvider.java b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldProvider.java index af1ca90cc9..39d7db9a0b 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldProvider.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldProvider.java @@ -2,79 +2,69 @@ package gtPlusPlus.australia.world; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.australia.chunk.ChunkProviderAustralia; +import gtPlusPlus.australia.dimension.Dimension_Australia; import net.minecraft.util.Vec3; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; -import gtPlusPlus.australia.chunk.ChunkProviderAustralia; -import gtPlusPlus.australia.dimension.Dimension_Australia; public class AustraliaWorldProvider extends WorldProvider { - @Override - public void registerWorldChunkManager() { - this.worldChunkMgr = new AustraliaWorldChunkManager(this.worldObj.getSeed(), WorldType.LARGE_BIOMES); - this.isHellWorld = false; - this.hasNoSky = false; - this.dimensionId = Dimension_Australia.DIMID; - } + @Override + public void registerWorldChunkManager() { + this.worldChunkMgr = new AustraliaWorldChunkManager(this.worldObj.getSeed(), WorldType.LARGE_BIOMES); + this.isHellWorld = false; + this.hasNoSky = false; + this.dimensionId = Dimension_Australia.DIMID; + } + + @Override + public float getSunBrightness(float par1) { + return (par1 * 2F); + } + + @Override + public float getStarBrightness(float par1) { + return (par1 * 5F); + } - @Override - public float getSunBrightness(float par1) { - return (par1*2F); - } + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1, float par2) { + return Vec3.createVectorHelper(0.8D, 0.8D, 0.8D); + } - @Override - public float getStarBrightness(float par1) { - return (par1*5F); - } - - @SideOnly(Side.CLIENT) - public Vec3 getFogColor(float par1, float par2) - { - return Vec3.createVectorHelper(0.8D, 0.8D, 0.8D); + @Override + public IChunkProvider createChunkGenerator() { + return new ChunkProviderAustralia(this.worldObj, this.worldObj.getSeed() - 15726L); } - @Override - public IChunkProvider createChunkGenerator() { - return new ChunkProviderAustralia(this.worldObj, this.worldObj.getSeed() - 15726L); - } - - public boolean isSurfaceWorld() - { - return true; + public boolean isSurfaceWorld() { + return true; } - - public boolean canCoordinateBeSpawn(int par1, int par2) - { - return false; + + public boolean canCoordinateBeSpawn(int par1, int par2) { + return false; } - - public boolean canRespawnHere() - { - return true; + + public boolean canRespawnHere() { + return true; } - + @SideOnly(Side.CLIENT) - public boolean doesXZShowFog(int par1, int par2) - { - return false; - } - - public String getDimensionName() - { - return "Australia"; + public boolean doesXZShowFog(int par1, int par2) { + return false; } - - protected void generateLightBrightnessTable() - { - float f = 0.5F; - for (int i = 0; i <= 15; i++) - { - float f1 = 1.0F - i / 15.0F; - this.lightBrightnessTable[i] = ((1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f); - } + + public String getDimensionName() { + return "Australia"; } -}
\ No newline at end of file + protected void generateLightBrightnessTable() { + float f = 0.5F; + for (int i = 0; i <= 15; i++) { + float f1 = 1.0F - i / 15.0F; + this.lightBrightnessTable[i] = ((1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f); + } + } +} diff --git a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldType.java b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldType.java index e8c8af4f76..71f1db5870 100644 --- a/src/main/java/gtPlusPlus/australia/world/AustraliaWorldType.java +++ b/src/main/java/gtPlusPlus/australia/world/AustraliaWorldType.java @@ -3,57 +3,54 @@ package gtPlusPlus.australia.world; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import net.minecraft.world.WorldType; -public class AustraliaWorldType extends WorldType{ - - public AustraliaWorldType(String name) { - super(name); - } - - public AustraliaWorldType(int p_i1959_1_, String p_i1959_2_){ - this("test"); - try { - //System.out.println(Arrays.toString(getClass().getSuperclass().getMethods())); - Method m = getClass().getSuperclass().getDeclaredMethod("WorldType", new Class<?>[]{}); - m.setAccessible(true); - m.invoke(this, p_i1959_1_, p_i1959_2_, 0); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public AustraliaWorldType(int p_i1960_1_, String p_i1960_2_, int p_i1960_3_){ - this("test2"); - try { - //System.out.println(Arrays.toString(getClass().getSuperclass().getMethods())); - Method m = getClass().getSuperclass().getDeclaredMethod("WorldType", new Class<?>[]{}); - m.setAccessible(true); - m.invoke(this, p_i1960_1_, p_i1960_2_, p_i1960_3_); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private WorldType getMC(){ - try { - Constructor<WorldType> c = WorldType.class.getDeclaredConstructor(); - c.setAccessible(true); // solution - return c.newInstance(); - - // production code should handle these exceptions more gracefully - } catch (InvocationTargetException x) { - x.printStackTrace(); - } catch (NoSuchMethodException x) { - x.printStackTrace(); - } catch (InstantiationException x) { - x.printStackTrace(); - } catch (IllegalAccessException x) { - x.printStackTrace(); - } - return null; - } +public class AustraliaWorldType extends WorldType { + + public AustraliaWorldType(String name) { + super(name); + } + + public AustraliaWorldType(int p_i1959_1_, String p_i1959_2_) { + this("test"); + try { + // System.out.println(Arrays.toString(getClass().getSuperclass().getMethods())); + Method m = getClass().getSuperclass().getDeclaredMethod("WorldType", new Class<?>[] {}); + m.setAccessible(true); + m.invoke(this, p_i1959_1_, p_i1959_2_, 0); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public AustraliaWorldType(int p_i1960_1_, String p_i1960_2_, int p_i1960_3_) { + this("test2"); + try { + // System.out.println(Arrays.toString(getClass().getSuperclass().getMethods())); + Method m = getClass().getSuperclass().getDeclaredMethod("WorldType", new Class<?>[] {}); + m.setAccessible(true); + m.invoke(this, p_i1960_1_, p_i1960_2_, p_i1960_3_); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private WorldType getMC() { + try { + Constructor<WorldType> c = WorldType.class.getDeclaredConstructor(); + c.setAccessible(true); // solution + return c.newInstance(); + + // production code should handle these exceptions more gracefully + } catch (InvocationTargetException x) { + x.printStackTrace(); + } catch (NoSuchMethodException x) { + x.printStackTrace(); + } catch (InstantiationException x) { + x.printStackTrace(); + } catch (IllegalAccessException x) { + x.printStackTrace(); + } + return null; + } } - |