From bf6713f0d1669e400b4545b173c18a3b66cad113 Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Wed, 14 Mar 2018 04:40:57 +1000 Subject: % Refactored all Everglades stuff to it's own package. $ Fixed inverted EIO tooltip logic. --- .../everglades/GTplusplus_Everglades.java | 187 ++++++++ .../everglades/biome/BiomeGenerator_Custom.java | 355 ++++++++++++++ .../everglades/biome/Biome_Everglades.java | 146 ++++++ .../everglades/biome/GenLayerBiomes.java | 31 ++ .../everglades/biome/GenLayerEverglades.java | 32 ++ .../everglades/block/BlockDarkWorldGround.java | 25 + .../block/BlockDarkWorldPollutedDirt.java | 74 +++ .../block/BlockDarkWorldPortalFrame.java | 30 ++ .../block/BlockDarkWorldSludgeFluid.java | 101 ++++ .../everglades/block/BlockEvergladesPortal.java | 403 ++++++++++++++++ .../everglades/block/DarkWorldContentLoader.java | 71 +++ .../everglades/chunk/ChunkProviderModded.java | 510 ++++++++++++++++++++ .../everglades/dimension/Dimension_Everglades.java | 30 ++ .../everglades/gen/WorldGenDeadLilly.java | 28 ++ .../everglades/gen/WorldGenMinable_Custom.java | 90 ++++ .../gtPlusPlus/everglades/gen/gt/WorldGen_GT.java | 49 ++ .../everglades/gen/gt/WorldGen_GT_Base.java | 471 +++++++++++++++++++ .../everglades/gen/gt/WorldGen_GT_Ore_Layer.java | 514 +++++++++++++++++++++ .../everglades/gen/gt/WorldGen_Ores.java | 327 +++++++++++++ .../everglades/item/ItemBlockToxicEverglades.java | 42 ++ .../item/ItemEvergladesPortalTrigger.java | 101 ++++ .../gtPlusPlus/everglades/object/BoxedQuad.java | 56 +++ .../everglades/world/CustomWorldType.java | 59 +++ .../everglades/world/EvergladesPortalPosition.java | 14 + .../everglades/world/TeleporterDimensionMod.java | 471 +++++++++++++++++++ .../everglades/world/WorldChunkManagerCustom.java | 263 +++++++++++ .../everglades/world/WorldProviderMod.java | 71 +++ 27 files changed, 4551 insertions(+) create mode 100644 src/Java/gtPlusPlus/everglades/GTplusplus_Everglades.java create mode 100644 src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java create mode 100644 src/Java/gtPlusPlus/everglades/biome/Biome_Everglades.java create mode 100644 src/Java/gtPlusPlus/everglades/biome/GenLayerBiomes.java create mode 100644 src/Java/gtPlusPlus/everglades/biome/GenLayerEverglades.java create mode 100644 src/Java/gtPlusPlus/everglades/block/BlockDarkWorldGround.java create mode 100644 src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPollutedDirt.java create mode 100644 src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPortalFrame.java create mode 100644 src/Java/gtPlusPlus/everglades/block/BlockDarkWorldSludgeFluid.java create mode 100644 src/Java/gtPlusPlus/everglades/block/BlockEvergladesPortal.java create mode 100644 src/Java/gtPlusPlus/everglades/block/DarkWorldContentLoader.java create mode 100644 src/Java/gtPlusPlus/everglades/chunk/ChunkProviderModded.java create mode 100644 src/Java/gtPlusPlus/everglades/dimension/Dimension_Everglades.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/WorldGenDeadLilly.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/WorldGenMinable_Custom.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Base.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java create mode 100644 src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_Ores.java create mode 100644 src/Java/gtPlusPlus/everglades/item/ItemBlockToxicEverglades.java create mode 100644 src/Java/gtPlusPlus/everglades/item/ItemEvergladesPortalTrigger.java create mode 100644 src/Java/gtPlusPlus/everglades/object/BoxedQuad.java create mode 100644 src/Java/gtPlusPlus/everglades/world/CustomWorldType.java create mode 100644 src/Java/gtPlusPlus/everglades/world/EvergladesPortalPosition.java create mode 100644 src/Java/gtPlusPlus/everglades/world/TeleporterDimensionMod.java create mode 100644 src/Java/gtPlusPlus/everglades/world/WorldChunkManagerCustom.java create mode 100644 src/Java/gtPlusPlus/everglades/world/WorldProviderMod.java (limited to 'src/Java/gtPlusPlus/everglades') diff --git a/src/Java/gtPlusPlus/everglades/GTplusplus_Everglades.java b/src/Java/gtPlusPlus/everglades/GTplusplus_Everglades.java new file mode 100644 index 0000000000..9174442a43 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/GTplusplus_Everglades.java @@ -0,0 +1,187 @@ +package gtPlusPlus.everglades; + +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.*; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.Everglades; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.everglades.biome.Biome_Everglades; +import gtPlusPlus.everglades.block.DarkWorldContentLoader; +import gtPlusPlus.everglades.dimension.Dimension_Everglades; +import gtPlusPlus.everglades.gen.gt.WorldGen_GT_Base; +import gtPlusPlus.everglades.gen.gt.WorldGen_Ores; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.config.Configuration; + +@MCVersion(value = "1.7.10") +@Mod(modid = Everglades.MODID, name = Everglades.NAME, version = Everglades.VERSION, dependencies = "required-after:Forge; after:dreamcraft; after:IC2; after:ihl; required-after:gregtech; after:miscutils;") +public class GTplusplus_Everglades implements ActionListener { + + //Mod Instance + @Mod.Instance(Everglades.MODID) + public static GTplusplus_Everglades instance; + + // Dark World Handler + protected static volatile Biome_Everglades Everglades_Biome; + protected static volatile Dimension_Everglades Everglades_Dimension; + public static int globalEvergladesPortalSpawnTimer = 0; + + // Pre-Init + @Mod.EventHandler + public void preInit(final FMLPreInitializationEvent event) { + Logger.INFO("Loading " + Everglades.MODID + " V" + Everglades.VERSION); + + //Setup + setVars(event); + + setEvergladesBiome(new Biome_Everglades()); + Everglades_Dimension = new Dimension_Everglades(); + + // Load Dark World + getEvergladesBiome().instance = instance; + Everglades_Dimension.instance = instance; + getEvergladesBiome().preInit(event); + + //Load/Set Custom Ore Gen + HANDLER_GT.sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "WorldGeneration.cfg"))); + + } + + @EventHandler + public void load(final FMLInitializationEvent e) { + Logger.INFO("Begin resource allocation for " + Everglades.MODID + " V" +Everglades.VERSION); + + //Load World and Biome + GameRegistry.registerWorldGenerator(new WorldGen_GT_Base(), Short.MAX_VALUE); + getEvergladesBiome().load(); + Everglades_Dimension.load(); + + } + + public static synchronized void GenerateOreMaterials() { + MaterialGenerator.generateOreMaterial(ORES.CROCROITE); + MaterialGenerator.generateOreMaterial(ORES.GEIKIELITE); + MaterialGenerator.generateOreMaterial(ORES.NICHROMITE); + MaterialGenerator.generateOreMaterial(ORES.TITANITE); + MaterialGenerator.generateOreMaterial(ORES.ZIMBABWEITE); + MaterialGenerator.generateOreMaterial(ORES.ZIRCONILITE); + MaterialGenerator.generateOreMaterial(ORES.GADOLINITE_CE); + MaterialGenerator.generateOreMaterial(ORES.GADOLINITE_Y); + MaterialGenerator.generateOreMaterial(ORES.LEPERSONNITE); + MaterialGenerator.generateOreMaterial(ORES.SAMARSKITE_Y); + MaterialGenerator.generateOreMaterial(ORES.SAMARSKITE_YB); + MaterialGenerator.generateOreMaterial(ORES.XENOTIME); + MaterialGenerator.generateOreMaterial(ORES.YTTRIAITE); + MaterialGenerator.generateOreMaterial(ORES.YTTRIALITE); + MaterialGenerator.generateOreMaterial(ORES.YTTROCERITE); + MaterialGenerator.generateOreMaterial(ORES.ZIRCON); + MaterialGenerator.generateOreMaterial(ORES.POLYCRASE); + MaterialGenerator.generateOreMaterial(ORES.ZIRCOPHYLLITE); + MaterialGenerator.generateOreMaterial(ORES.ZIRKELITE); + MaterialGenerator.generateOreMaterial(ORES.LANTHANITE_LA); + MaterialGenerator.generateOreMaterial(ORES.LANTHANITE_CE); + MaterialGenerator.generateOreMaterial(ORES.LANTHANITE_ND); + MaterialGenerator.generateOreMaterial(ORES.AGARDITE_Y); + MaterialGenerator.generateOreMaterial(ORES.AGARDITE_CD); + MaterialGenerator.generateOreMaterial(ORES.AGARDITE_LA); + MaterialGenerator.generateOreMaterial(ORES.AGARDITE_ND); + MaterialGenerator.generateOreMaterial(ORES.HIBONITE); + MaterialGenerator.generateOreMaterial(ORES.CERITE); + MaterialGenerator.generateOreMaterial(ORES.FLUORCAPHITE); + MaterialGenerator.generateOreMaterial(ORES.FLORENCITE); + MaterialGenerator.generateOreMaterial(ORES.CRYOLITE); + + //Custom Ores + if (LoadedMods.Big_Reactors) { + MaterialGenerator.generateOreMaterial(ELEMENT.getInstance().YELLORIUM, false, false, true, new short[] {255, 242, 10}); + } + } + + protected synchronized void setVars(FMLPreInitializationEvent event){ + //Init WorldGen config. + HANDLER_GT.sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "WorldGeneration.cfg"))); + + if (DimensionManager.isDimensionRegistered(Dimension_Everglades.DIMID)){ + Dimension_Everglades.DIMID = DimensionManager.getNextFreeDimId(); + } + + /* + * Set World Generation Values + */ + WorldGen_Ores.generateValidOreVeins(); + WorldGen_GT_Base.oreveinPercentage = 64; + WorldGen_GT_Base.oreveinAttempts = 32; + WorldGen_GT_Base.oreveinMaxPlacementAttempts = 6; + if (CORE.DEBUG || CORE.DEVENV){ + WorldGen_GT_Base.debugWorldGen = true; + } + DarkWorldContentLoader.run(); + } + + @EventHandler + public void serverLoad(FMLServerStartingEvent event) { + getEvergladesBiome().serverLoad(event); + } + + /*@Override + public int getBurnTime(ItemStack fuel) { + if (DarkWorld_Biome.addFuel(fuel) != 0) + return DarkWorld_Biome.addFuel(fuel); + if (DarkWorld_Dimension.addFuel(fuel) != 0) + return DarkWorld_Dimension.addFuel(fuel); + return 0; + }*/ + + /*@Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + chunkX = chunkX * 16; + chunkZ = chunkZ * 16; + + if (world.provider.dimensionId == Dimension_DarkWorld.DIMID) { + DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); + } + + //What does this even do? + if (world.provider.dimensionId == -1) { + DarkWorld_Biome.generateNether(world, random, chunkX, chunkZ); + } + if (world.provider.dimensionId == 0) { + DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); + } + + }*/ + + @EventHandler + public static void postInit(final FMLPostInitializationEvent e) { + Logger.INFO("Finished loading Everglades plugin for GT++."); + } + + public static synchronized Biome_Everglades getEvergladesBiome() { + return Everglades_Biome; + } + + public static synchronized void setEvergladesBiome(Biome_Everglades darkWorld_Biome) { + Everglades_Biome = darkWorld_Biome; + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java b/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java new file mode 100644 index 0000000000..83dedc376a --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java @@ -0,0 +1,355 @@ +package gtPlusPlus.everglades.biome; + +import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*; +import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*; + +import java.util.Random; + +import net.minecraft.block.BlockFlower; +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.gen.feature.*; + +import gtPlusPlus.everglades.gen.WorldGenDeadLilly; +import gtPlusPlus.everglades.gen.WorldGenMinable_Custom; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent; +import net.minecraftforge.event.terraingen.OreGenEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +public class BiomeGenerator_Custom extends BiomeDecorator { + /** The world the BiomeDecorator is currently decorating */ + public World currentWorld; + /** The Biome Decorator's random number generator. */ + public Random randomGenerator; + + public WorldGenerator fluoriteGen; + + public BiomeGenerator_Custom(){ + //Basic Blocks + this.sandGen = new WorldGenMinable_Custom(Blocks.sand, 12); + this.gravelAsSandGen = new WorldGenMinable_Custom(Blocks.gravel, 8); + this.dirtGen = new WorldGenMinable_Custom(Blocks.dirt, 32); + this.gravelGen = new WorldGenMinable_Custom(Blocks.gravel, 12); + + + //Oregen + this.coalGen = new WorldGenMinable_Custom(Blocks.coal_ore, 16); + this.ironGen = new WorldGenMinable_Custom(Blocks.iron_ore, 12); + this.goldGen = new WorldGenMinable_Custom(Blocks.gold_ore, 12); + this.redstoneGen = new WorldGenMinable_Custom(Blocks.redstone_ore, 10); + this.diamondGen = new WorldGenMinable_Custom(Blocks.diamond_ore, 12); + this.lapisGen = new WorldGenMinable_Custom(Blocks.lapis_ore, 8); + // this.fluoriteGen = new WorldGenMinable_Custom(ModBlocks.blockOreFluorite, 20); + + //Nature + 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 WorldGenDeadLilly(); + + this.flowersPerChunk = 1; + this.grassPerChunk = 5; + this.sandPerChunk = 3; + this.sandPerChunk2 = 5; + this.clayPerChunk = 7; + + this.generateLakes = true; + } + + @Override + public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_, int p_150512_5_) + { + if (this.currentWorld != null) + { + throw new RuntimeException("Already decorating!!"); + } + else + { + this.currentWorld = p_150512_1_; + this.randomGenerator = p_150512_2_; + this.chunk_X = p_150512_4_; + this.chunk_Z = p_150512_5_; + this.genDecorations(p_150512_3_); + this.currentWorld = null; + this.randomGenerator = null; + } + } + + @Override + 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); + } + + 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); + } + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } + + /** + * Standard ore generation helper. Generates most ores. + */ + @Override + protected void genStandardOre1(int p_76795_1_, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_) + { + for (int l = 0; l < p_76795_1_; ++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); + p_76795_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + /** + * Standard ore generation helper. Generates Lapis Lazuli. + */ + @Override + 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 + */ + @Override + 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(20, this.ironGen, 0, 64); + if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) + this.genStandardOre1(2, this.goldGen, 0, 32); + if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) + this.genStandardOre1(8, 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(1, 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 diff --git a/src/Java/gtPlusPlus/everglades/biome/Biome_Everglades.java b/src/Java/gtPlusPlus/everglades/biome/Biome_Everglades.java new file mode 100644 index 0000000000..aadbfeb495 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/biome/Biome_Everglades.java @@ -0,0 +1,146 @@ +package gtPlusPlus.everglades.biome; + +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; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.entity.monster.EntitySickBlaze; +import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.everglades.dimension.Dimension_Everglades; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeManager; + +public class Biome_Everglades { + + public static BiomeGenEverglades biome = new BiomeGenEverglades(); + + public Object instance; + + public Biome_Everglades() { + } + + public void load() { + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DEAD); + BiomeManager.addSpawnBiome(biome); + } + + public void generateNether(World world, Random random, int chunkX, int chunkZ) { + } + + public void generateSurface(World world, Random random, int chunkX, int chunkZ) { + } + + public void registerRenderers() { + } + + public int addFuel(ItemStack fuel) { + return 0; + } + + public void serverLoad(FMLServerStartingEvent event) { + } + + public void preInit(FMLPreInitializationEvent event) { + } + + static class BiomeGenEverglades extends BiomeGenBase { + @SuppressWarnings("unchecked") + public BiomeGenEverglades() { + super(CORE.EVERGLADESBIOME_ID); + this.setBiomeID(); + this.theBiomeDecorator = new BiomeGenerator_Custom(); + this.theBiomeDecorator.treesPerChunk = 10; + //Logger.INFO("Dark World Temperature Category: "+getTempCategory()); + this.setBiomeName("Toxic Everglades"); + this.topBlock = Dimension_Everglades.blockTopLayer; + this.fillerBlock = Dimension_Everglades.blockSecondLayer; + this.enableRain = true; + this.enableSnow = false; + this.rainfall = 0.7F; + this.setHeight(new BiomeGenBase.Height(0.3F, 0.5F)); + this.heightVariation = 0.4F; + this.waterColorMultiplier = 0x17290A; + this.rootHeight = -0.25f; //Ground level + + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); + + //Enemies + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySickBlaze.class, 100, 2, 6)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 75, 4, 16)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityStaballoyConstruct.class, 20, 1, 2)); + + //Animals + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 1, 1, 6)); + this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); + + } + + private synchronized boolean setBiomeID() { + BiomeGenBase[] mTempList; + try { + Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); + Field mClone = mInternalBiomeList; + mTempList = (BiomeGenBase[]) mInternalBiomeList.get(null); + if (mTempList != null){ + mTempList[CORE.EVERGLADESBIOME_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mTempList != mInternalBiomeList.get(null)){ + ReflectionUtils.setFinalStatic(mInternalBiomeList, mTempList); + Logger.REFLECTION("Set Biome ID for Dark World Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); + return true; + } + else { + Logger.REFLECTION("Failed to set Biome ID for Dark World 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()+"."); + return false; + } + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor() { + return 0x111f11; + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor() { + return 0x111f11; + } + + @Override + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) { + return 0xF67A14; + } + + @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; + } + + } + +} diff --git a/src/Java/gtPlusPlus/everglades/biome/GenLayerBiomes.java b/src/Java/gtPlusPlus/everglades/biome/GenLayerBiomes.java new file mode 100644 index 0000000000..b69a8ea555 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/biome/GenLayerBiomes.java @@ -0,0 +1,31 @@ +package gtPlusPlus.everglades.biome; + +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; + +public class GenLayerBiomes extends GenLayer { + + protected BiomeGenBase[] allowedBiomes = { Biome_Everglades.biome, }; + + public GenLayerBiomes(long seed) { + super(seed); + } + + public GenLayerBiomes(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 diff --git a/src/Java/gtPlusPlus/everglades/biome/GenLayerEverglades.java b/src/Java/gtPlusPlus/everglades/biome/GenLayerEverglades.java new file mode 100644 index 0000000000..8034921dce --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/biome/GenLayerEverglades.java @@ -0,0 +1,32 @@ +package gtPlusPlus.everglades.biome; + +import net.minecraft.world.WorldType; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.GenLayerVoronoiZoom; +import net.minecraft.world.gen.layer.GenLayerZoom; + +public class GenLayerEverglades extends GenLayer { + + public GenLayerEverglades(long seed) { + super(seed); + } + + public static GenLayer[] makeTheWorld(long seed, WorldType type) { + GenLayer biomes = new GenLayerBiomes(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 diff --git a/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldGround.java b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldGround.java new file mode 100644 index 0000000000..f68c97b3c5 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldGround.java @@ -0,0 +1,25 @@ +package gtPlusPlus.everglades.block; + +import cpw.mods.fml.common.registry.LanguageRegistry; + +import net.minecraft.block.BlockGrass; + +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class BlockDarkWorldGround extends BlockGrass implements ITileTooltip{ + + public BlockDarkWorldGround() { + this.setCreativeTab(AddToCreativeTab.tabBOP); + this.setBlockName("blockDarkWorldGround"); + this.setHardness(1.0F); + this.setBlockTextureName("minecraft" + ":" + "grass"); + LanguageRegistry.addName(this, "Unstable Earth"); + } + + @Override + public int getTooltipID() { + return 2; + } + +} diff --git a/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPollutedDirt.java b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPollutedDirt.java new file mode 100644 index 0000000000..a1fcc588b5 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPollutedDirt.java @@ -0,0 +1,74 @@ +package gtPlusPlus.everglades.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 net.minecraft.world.ColorizerGrass; +import net.minecraft.world.IBlockAccess; + +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class BlockDarkWorldPollutedDirt extends BlockDirt implements ITileTooltip{ + + public BlockDarkWorldPollutedDirt() { + this.setCreativeTab(AddToCreativeTab.tabBOP); + this.setBlockName("blockDarkWorldGround2"); + this.setHardness(0.5F); + this.setBlockTextureName("minecraft" + ":" + "dirt"); + LanguageRegistry.addName(this, "Polluted Soil"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } + + /** + * 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(); + } + + /** + * 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; + + 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; + } + } + + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } + + @Override + public int getTooltipID() { + return 3; + } + +} diff --git a/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPortalFrame.java b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPortalFrame.java new file mode 100644 index 0000000000..09dea46ab1 --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldPortalFrame.java @@ -0,0 +1,30 @@ +package gtPlusPlus.everglades.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; + +public class BlockDarkWorldPortalFrame extends Block implements ITileTooltip{ + + public BlockDarkWorldPortalFrame() { + super(Material.iron); + this.setCreativeTab(AddToCreativeTab.tabBOP); + this.setBlockName("blockDarkWorldPortalFrame"); + 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/Java/gtPlusPlus/everglades/block/BlockDarkWorldSludgeFluid.java b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldSludgeFluid.java new file mode 100644 index 0000000000..3c0445c86d --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/BlockDarkWorldSludgeFluid.java @@ -0,0 +1,101 @@ +package gtPlusPlus.everglades.block; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialLiquid; + +import net.minecraftforge.fluids.Fluid; + +public class BlockDarkWorldSludgeFluid extends Fluid { + + + public static final Material SLUDGE = new MaterialLiquid(MapColor.dirtColor); + + protected static int mapColor = 0xFFFFFFFF; + protected static float overlayAlpha = 0.2F; + //protected static SoundEvent emptySound = SoundEvents.ITEM_BUCKET_EMPTY; + //protected static SoundEvent fillSound = SoundEvents.ITEM_BUCKET_FILL; + protected static Material material = SLUDGE; + + + public BlockDarkWorldSludgeFluid(String fluidName, int rgbColour) { + this(fluidName, rgbColour, null); + } + + public BlockDarkWorldSludgeFluid(String fluidName, int rgbColour, Float overlayAlpha) { + super(fluidName); + setColor(rgbColour); + if (overlayAlpha != null){ + setAlpha(overlayAlpha.floatValue()); + } + else { + setAlpha(0); + } + } + + @Override + public int getColor() + { + return mapColor; + } + + public BlockDarkWorldSludgeFluid setColor(int parColor) + { + mapColor = parColor; + return this; + } + + public float getAlpha() + { + return overlayAlpha; + } + + public BlockDarkWorldSludgeFluid setAlpha(float parOverlayAlpha) + { + overlayAlpha = parOverlayAlpha; + return this; + } + + /*public blockDarkWorldSludgeFluid setEmptySound(SoundEvent parSound) + { + emptySound = parSound; + return this; + } + + public SoundEvent getEmptySound() + { + return emptySound; + } + + @Override + public blockDarkWorldSludgeFluid setFillSound(SoundEvent parSound) + { + fillSound = parSound; + return this; + } + + @Override + public SoundEvent getFillSound() + { + return fillSound; + }*/ + + public BlockDarkWorldSludgeFluid setMaterial(Material parMaterial) + { + material = parMaterial; + return this; + } + + public Material getMaterial() + { + return material; + } + + /*@Override + public boolean doesVaporize(FluidStack fluidStack) + { + if (block == null) + return false; + return block.getDefaultState().getMaterial() == getMaterial(); + }*/ +} diff --git a/src/Java/gtPlusPlus/everglades/block/BlockEvergladesPortal.java b/src/Java/gtPlusPlus/everglades/block/BlockEvergladesPortal.java new file mode 100644 index 0000000000..e64968888d --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/BlockEvergladesPortal.java @@ -0,0 +1,403 @@ +package gtPlusPlus.everglades.block; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockBreakable; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +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.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.everglades.dimension.Dimension_Everglades; +import gtPlusPlus.everglades.world.TeleporterDimensionMod; + +public class BlockEvergladesPortal extends BlockBreakable implements ITileTooltip{ + IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null; + + public BlockEvergladesPortal() { + super("portal", Material.portal, false); + this.setTickRandomly(true); + this.setHardness(-1.0F); + this.setLightLevel(0.75F); + this.setCreativeTab(CreativeTabs.tabBlock); + this.setBlockName("blockDarkWorldPortal"); + + } + + @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_Everglades.blockPortalFrame || b == Dimension_Everglades.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_Everglades.blockPortalFrame + || par1World.getBlock(par2 + 1, par3, par4) == Dimension_Everglades.blockPortalFrame) { + b0 = 1; + } + if (par1World.getBlock(par2, par3, par4 - 1) == Dimension_Everglades.blockPortalFrame + || par1World.getBlock(par2, par3, par4 + 1) == Dimension_Everglades.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_Everglades.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_Everglades.blockPortalFrame || b == Dimension_Everglades.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_Everglades.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_Everglades.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_Everglades.blockPortalFrame || par1World + .getBlock(x - b0, y, z - b1) != this) + && (par1World.getBlock(x - b0, y, z - b1) != Dimension_Everglades.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_Everglades.DIMID) { + thePlayer.timeUntilPortal = 100; + thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, Dimension_Everglades.DIMID, + new TeleporterDimensionMod(thePlayer.mcServer.worldServerForDimension(Dimension_Everglades.DIMID))); + } else { + thePlayer.timeUntilPortal = 100; + thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, + new TeleporterDimensionMod(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/Java/gtPlusPlus/everglades/block/DarkWorldContentLoader.java b/src/Java/gtPlusPlus/everglades/block/DarkWorldContentLoader.java new file mode 100644 index 0000000000..9d0e425e3a --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/block/DarkWorldContentLoader.java @@ -0,0 +1,71 @@ +package gtPlusPlus.everglades.block; + +import static gtPlusPlus.everglades.dimension.Dimension_Everglades.*; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.init.Blocks; + +import gtPlusPlus.core.block.base.BlockBaseFluid; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.everglades.item.ItemBlockToxicEverglades; +import gtPlusPlus.everglades.item.ItemEvergladesPortalTrigger; +import net.minecraftforge.fluids.FluidRegistry; + +public class DarkWorldContentLoader { + + //Static Vars + public static BlockDarkWorldSludgeFluid SLUDGE; + + + public synchronized static void run() { + initMisc(); + initItems(); + initBlocks(); + } + + public synchronized static boolean initMisc(){ + + //Fluids + SLUDGE = (BlockDarkWorldSludgeFluid) new BlockDarkWorldSludgeFluid( + "sludge", + Utils.rgbtoHexValue(30, 130, 30)) + .setDensity(1800) + .setGaseous(false) + .setLuminosity(2) + .setViscosity(25000) + .setTemperature(300); + FluidRegistry.registerFluid(SLUDGE); + + return true; + } + + public synchronized static boolean initItems(){ + portalItem = (ItemEvergladesPortalTrigger) (new ItemEvergladesPortalTrigger().setUnlocalizedName("everglades.trigger")); + GameRegistry.registerItem(portalItem, "everglades.trigger"); + return true; + } + + public synchronized static boolean initBlocks(){ + + //Create Block Instances + blockFluidLakes = new BlockBaseFluid("Sludge", SLUDGE, BlockDarkWorldSludgeFluid.SLUDGE).setLightLevel(2f).setLightOpacity(1).setBlockName("fluidSludge"); + portalBlock = new BlockEvergladesPortal(); + blockTopLayer = new BlockDarkWorldGround(); + blockSecondLayer = new BlockDarkWorldPollutedDirt(); + blockPortalFrame = new BlockDarkWorldPortalFrame(); + + //Registry + GameRegistry.registerBlock(portalBlock, ItemBlockToxicEverglades.class, "dimensionDarkWorld_portal"); + GameRegistry.registerBlock(blockTopLayer, ItemBlockToxicEverglades.class, "blockDarkWorldGround"); + GameRegistry.registerBlock(blockSecondLayer, ItemBlockToxicEverglades.class, "blockDarkWorldGround2"); + GameRegistry.registerBlock(blockPortalFrame, ItemBlockToxicEverglades.class, "blockDarkWorldPortalFrame"); + + //Make Flammable + Blocks.fire.setFireInfo(blockTopLayer, 30, 20); + + return true; + } + + +} diff --git a/src/Java/gtPlusPlus/everglades/chunk/ChunkProviderModded.java b/src/Java/gtPlusPlus/everglades/chunk/ChunkProviderModded.java new file mode 100644 index 0000000000..0ff265a4ae --- /dev/null +++ b/src/Java/gtPlusPlus/everglades/chunk/ChunkProviderModded.java @@ -0,0 +1,510 @@ +package gtPlusPlus.everglades.chunk; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.*; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.*; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraft.world.gen.structure.MapGenMineshaft; +import net.minecraft.world.gen.structure.MapGenScatteredFeature; +import net.minecraft.world.gen.structure.MapGenVillage; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.everglades.dimension.Dimension_Everglades; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.ChunkProviderEvent; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +public class ChunkProviderModded implements IChunkProvider { + private Random rand; + private NoiseGeneratorOctaves field_147431_j; + private NoiseGeneratorOctaves field_147432_k; + private NoiseGeneratorOctaves field_147429_l; + private NoiseGeneratorPerlin field_147430_m; + /** + * A NoiseGeneratorOctaves used in generating terrain + */ + public NoiseGeneratorOctaves noiseGen5; + /** + * A NoiseGeneratorOctaves used in generating terrain + */ + public NoiseGeneratorOctaves noiseGen6; + public NoiseGeneratorOctaves mobSpawnerNoise; + /** + * Reference to the World object. + */ + private World worldObj; + private WorldType field_147435_p; + 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 Village Generator + */ + private MapGenVillage villageGenerator = new MapGenVillage(); + /** + * Holds Mineshaft Generator + */ + private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); + private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + /** + * Holds ravine generator + */ + private MapGenBase ravineGenerator = new MapGenRavine(); + /** + * The biomes that are used to generate the chunk + */ + private BiomeGenBase[] biomesForGeneration; + double[] field_147427_d; + double[] field_147428_e; + double[] field_147425_f; + double[] field_147426_g; + int[][] field_73219_j = new int[32][32]; + { + caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, + net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); + /* + * strongholdGenerator = (MapGenStronghold) + * TerrainGen.getModdedMapGen(strongholdGenerator, + * net.minecraftforge.event.terraingen.InitMapGenEvent.EventType. + * STRONGHOLD); + */ + villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, + net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE); + 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 ChunkProviderModded(World par1World, long par2) { + this.worldObj = par1World; + this.field_147435_p = par1World.getWorldInfo().getTerrainType(); + this.rand = new Random(par2); + this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16); + this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16); + this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8); + this.field_147430_m = 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[825]; + 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 = { field_147431_j, field_147432_k, field_147429_l, field_147430_m, noiseGen5, + noiseGen6, mobSpawnerNoise }; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); + this.field_147431_j = (NoiseGeneratorOctaves) noiseGens[0]; + this.field_147432_k = (NoiseGeneratorOctaves) noiseGens[1]; + this.field_147429_l = (NoiseGeneratorOctaves) noiseGens[2]; + this.field_147430_m = (NoiseGeneratorPerlin) noiseGens[3]; + this.noiseGen5 = (NoiseGeneratorOctaves) noiseGens[4]; + this.noiseGen6 = (NoiseGeneratorOctaves) noiseGens[5]; + this.mobSpawnerNoise = (NoiseGeneratorOctaves) noiseGens[6]; + } + + public void func_147424_a(int