diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-07-06 23:49:27 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-07-06 23:49:27 +1000 |
commit | 0d30becbc219fc2c86234e84dae306276dafe4c6 (patch) | |
tree | 8761781cdddb6dcc54f37a7fe66311c2e29c88c3 /src/Java/gtPlusPlus/australia | |
parent | c37b091b581a838c49a63911d2cda6324d029e10 (diff) | |
download | GT5-Unofficial-0d30becbc219fc2c86234e84dae306276dafe4c6.tar.gz GT5-Unofficial-0d30becbc219fc2c86234e84dae306276dafe4c6.tar.bz2 GT5-Unofficial-0d30becbc219fc2c86234e84dae306276dafe4c6.zip |
+ Added a new Dimension, Australia.
% Stopped Custom Villagers spawning as professions that aren't custom.
% Trade improvements for some Villagers.
$ Fixed a bug in AutoMap mapping to internal name map.
Diffstat (limited to 'src/Java/gtPlusPlus/australia')
23 files changed, 4310 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/australia/GTplusplus_Australia.java b/src/Java/gtPlusPlus/australia/GTplusplus_Australia.java new file mode 100644 index 0000000000..954c25e897 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/GTplusplus_Australia.java @@ -0,0 +1,111 @@ +package gtPlusPlus.australia; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.australia.biome.Biome_AustralianDesert; +import gtPlusPlus.australia.biome.Biome_AustralianDesert2; +import gtPlusPlus.australia.block.AustraliaContentLoader; +import gtPlusPlus.australia.dimension.Dimension_Australia; +import gtPlusPlus.australia.gen.gt.WorldGen_Australia_Ores; +import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia_Base; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.Australia; +import net.minecraftforge.common.DimensionManager; + +@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;") +public class GTplusplus_Australia implements ActionListener { + + //Mod Instance + @Mod.Instance(Australia.MODID) + public static GTplusplus_Australia instance; + + // Dark World Handler + protected static volatile Biome_AustralianDesert Australian_Desert_Biome_1; + protected static volatile Biome_AustralianDesert2 Australian_Desert_Biome_2; + protected static volatile Dimension_Australia Australia_Dimension; + 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); + + } + + @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(); + + Australia_Dimension.load(); + + } + + public static synchronized void GenerateOreMaterials() { + + } + + protected synchronized void setVars(FMLPreInitializationEvent event){ + if (DimensionManager.isDimensionRegistered(Dimension_Australia.DIMID)){ + Dimension_Australia.DIMID = DimensionManager.getNextFreeDimId(); + } + + /* + * Set World Generation Values + */ + WorldGen_Australia_Ores.generateValidOreVeins(); + WorldGen_GT_Australia_Base.oreveinPercentage = 32; + WorldGen_GT_Australia_Base.oreveinAttempts = 16; + WorldGen_GT_Australia_Base.oreveinMaxPlacementAttempts = 2; + if (CORE.DEBUG || CORE.DEVENV){ + WorldGen_GT_Australia_Base.debugWorldGen = true; + } + AustraliaContentLoader.run(); + } + + @EventHandler + public void serverLoad(FMLServerStartingEvent event) { + Australian_Desert_Biome_1.serverLoad(event); + Australian_Desert_Biome_2.serverLoad(event); + } + + @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 + + } + +} diff --git a/src/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert.java b/src/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert.java new file mode 100644 index 0000000000..e012fa8590 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert.java @@ -0,0 +1,343 @@ +package gtPlusPlus.australia.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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeManager; + +public class Biome_AustralianDesert { + + public static BiomeGenAustralianDesert biome = new BiomeGenAustralianDesert(); + + 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 Biome_AustralianDesert() { + } + + 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 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 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.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)); + + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + + } + + 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.AUSTRALIA_BIOME_DESERT_1_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mTempList != mInternalBiomeList.get(null)){ + ReflectionUtils.setFinalStatic(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()+"."); + return false; + } + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor() { + return 6697728; + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor() { + return 6697728; + } + + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) { + return 13421772; + } + + @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; + } + + //TODO - DOES THIS WORK? + public WorldGenerator getRandomWorldGenForTrees(Random par1Random) + { + return new Tree(); + } + + class Tree + extends WorldGenerator + { + private final int minTreeHeight; + private final boolean vinesGrow; + private final int metaWood; + private final int metaLeaves; + + public Tree() + { + super(); + 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/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert2.java b/src/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert2.java new file mode 100644 index 0000000000..6f38fe5cd8 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/biome/Biome_AustralianDesert2.java @@ -0,0 +1,343 @@ +package gtPlusPlus.australia.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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeManager; + +public class Biome_AustralianDesert2 { + + public static BiomeGenAustralianDesert2 biome = new BiomeGenAustralianDesert2(); + + 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 Biome_AustralianDesert2() { + } + + 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 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 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.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)); + + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 5, 1, 5)); + + } + + 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.AUSTRALIA_BIOME_DESERT_1_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mTempList != mInternalBiomeList.get(null)){ + ReflectionUtils.setFinalStatic(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()+"."); + return false; + } + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor() { + return 6697728; + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor() { + return 6697728; + } + + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) { + return 13421772; + } + + @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; + } + + //TODO - DOES THIS WORK? + public WorldGenerator getRandomWorldGenForTrees(Random par1Random) + { + return new Tree(); + } + + class Tree + extends WorldGenerator + { + private final int minTreeHeight; + private final boolean vinesGrow; + private final int metaWood; + private final int metaLeaves; + + public Tree() + { + super(); + 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/Java/gtPlusPlus/australia/biome/GenLayerAustralia.java b/src/Java/gtPlusPlus/australia/biome/GenLayerAustralia.java new file mode 100644 index 0000000000..d9c328d756 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/biome/GenLayerAustralia.java @@ -0,0 +1,32 @@ +package gtPlusPlus.australia.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 GenLayerAustralia extends GenLayer { + + 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 }; + } + + @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/australia/biome/GenLayerBiomesAustraliaDimension.java b/src/Java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java new file mode 100644 index 0000000000..c8ceaa3ed3 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/biome/GenLayerBiomesAustraliaDimension.java @@ -0,0 +1,32 @@ +package gtPlusPlus.australia.biome; + +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; + +public class GenLayerBiomesAustraliaDimension extends GenLayer { + + protected BiomeGenBase[] allowedBiomes = { Biome_AustralianDesert.biome, Biome_AustralianDesert2.biome}; + + public GenLayerBiomesAustraliaDimension(long seed) { + super(seed); + } + + 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 diff --git a/src/Java/gtPlusPlus/australia/block/AustraliaContentLoader.java b/src/Java/gtPlusPlus/australia/block/AustraliaContentLoader.java new file mode 100644 index 0000000000..8571bf5477 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/block/AustraliaContentLoader.java @@ -0,0 +1,52 @@ +package gtPlusPlus.australia.block; + +import static gtPlusPlus.australia.dimension.Dimension_Australia.*; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.init.Blocks; +import gtPlusPlus.australia.biome.Biome_AustralianDesert; +import gtPlusPlus.australia.item.ItemAustraliaPortalTrigger; +import gtPlusPlus.australia.item.ItemBlockAustralia; + +public class AustraliaContentLoader { + + public synchronized static void run() { + initMisc(); + initItems(); + initBlocks(); + } + + public synchronized static boolean initMisc(){ + return true; + } + + public synchronized static boolean initItems(){ + portalItem = (ItemAustraliaPortalTrigger) (new ItemAustraliaPortalTrigger().setUnlocalizedName("australia.trigger")); + GameRegistry.registerItem(portalItem, "australia.trigger"); + return true; + } + + public synchronized static boolean initBlocks(){ + + //Create Block Instances + portalBlock = new BlockAustraliaPortal(); + blockPortalFrame = new BlockDarkWorldPortalFrame(); + + Biome_AustralianDesert.blockFluidLakes = Blocks.water; + Biome_AustralianDesert.blockTopLayer = new BlockAustraliaSand(); + Biome_AustralianDesert.blockSecondLayer = new BlockAustraliaTopSoil(); + + + //Registry + GameRegistry.registerBlock(portalBlock, ItemBlockAustralia.class, "dimensionAustraliaPortalBlock"); + GameRegistry.registerBlock(blockPortalFrame, ItemBlockAustralia.class, "blockAustraliaPortalFrame"); + + GameRegistry.registerBlock(Biome_AustralianDesert.blockTopLayer, ItemBlockAustralia.class, "blockAustralianTopSoil"); + GameRegistry.registerBlock(Biome_AustralianDesert.blockSecondLayer, ItemBlockAustralia.class, "blockAustralianSand"); + + return true; + } + + +} diff --git a/src/Java/gtPlusPlus/australia/block/BlockAustraliaPortal.java b/src/Java/gtPlusPlus/australia/block/BlockAustraliaPortal.java new file mode 100644 index 0000000000..3b8c9e577e --- /dev/null +++ b/src/Java/gtPlusPlus/australia/block/BlockAustraliaPortal.java @@ -0,0 +1,403 @@ +package gtPlusPlus.australia.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.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; + } +} + + diff --git a/src/Java/gtPlusPlus/australia/block/BlockAustraliaSand.java b/src/Java/gtPlusPlus/australia/block/BlockAustraliaSand.java new file mode 100644 index 0000000000..0eae16f6a0 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/block/BlockAustraliaSand.java @@ -0,0 +1,25 @@ +package gtPlusPlus.australia.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 BlockAustraliaSand extends BlockGrass implements ITileTooltip{ + + public BlockAustraliaSand() { + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockAustralianSand"); + this.setHardness(0.1F); + this.setBlockTextureName("minecraft" + ":" + "grass"); + LanguageRegistry.addName(this, "Sandy Soil"); + } + + @Override + public int getTooltipID() { + return 2; + } + +} diff --git a/src/Java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java b/src/Java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java new file mode 100644 index 0000000000..22f63d48d5 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/block/BlockAustraliaTopSoil.java @@ -0,0 +1,75 @@ +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 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 BlockDirt implements ITileTooltip{ + + public BlockAustraliaTopSoil() { + this.setHardness(0.5F); + this.setBlockTextureName("minecraft" + ":" + "dirt"); + this.setCreativeTab(CreativeTabs.tabBlock); + this.setBlockName("blockAustralianTopSoil"); + LanguageRegistry.addName(this, "Desert 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/australia/block/BlockDarkWorldPortalFrame.java b/src/Java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java new file mode 100644 index 0000000000..1de7425f6a --- /dev/null +++ b/src/Java/gtPlusPlus/australia/block/BlockDarkWorldPortalFrame.java @@ -0,0 +1,30 @@ +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; + +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/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java b/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java new file mode 100644 index 0000000000..f4d49203cd --- /dev/null +++ b/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java @@ -0,0 +1,464 @@ +package gtPlusPlus.australia.chunk; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import net.minecraft.block.Block; +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 net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.ChunkProviderEvent; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +public class ChunkProviderAustralia 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); + 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 ChunkProviderAustralia(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['?']; + 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.field_147431_j, this.field_147432_k, this.field_147429_l, this.field_147430_m, this.noiseGen5, this.noiseGen6, this.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 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.field_147430_m.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 par1, int par2) { + this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L); + Block[] ablock = new Block[65536]; + byte[] abyte = new byte[65536]; + func_147424_a(par1, par2, ablock); + this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); + + replaceBlocksForBiome(par1, par2, ablock, abyte, this.biomesForGeneration); + + Chunk chunk = new Chunk(this.worldObj, ablock, abyte, par1, par2); + byte[] abyte1 = chunk.getBiomeArray(); + for (int k = 0; k < abyte1.length; k++) { + abyte1[k] = ((byte)this.biomesForGeneration[k].biomeID); + } + chunk.generateSkylightMap(); + return chunk; + } + + 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.field_147426_g = this.noiseGen6.generateNoiseOctaves(this.field_147426_g, p_147423_1_, p_147423_3_, 5, 5, 200.0D, 200.0D, 0.5D); + this.field_147427_d = this.field_147429_l.generateNoiseOctaves(this.field_147427_d, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); + + this.field_147428_e = this.field_147431_j.generateNoiseOctaves(this.field_147428_e, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + + this.field_147425_f = this.field_147432_k.generateNoiseOctaves(this.field_147425_f, 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.field_147435_p == 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.field_147426_g[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.field_147428_e[l] / 512.0D; + double d8 = this.field_147425_f[l] / 512.0D; + double d9 = (this.field_147427_d[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 true; + } + + /** + * Populates chunk with ores etc etc + */ + @Override + public void populate(IChunkProvider par1IChunkProvider, int par2, int 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)); + 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); + 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 true; + } + + /** + * Save extra data not associated with any Chunk. Not saved during + * autosave, only during world unload. Currently unimplemented. + */ + @Override + public void saveExtraData() { + } + + /** + * Unloads chunks that are marked to be unloaded. This is not guaranteed + * to unload every such chunk. + */ + @Override + public boolean unloadQueuedChunks() { + return false; + } + + /** + * Returns if the IChunkProvider supports saving. + */ + @Override + public boolean canSave() { + return true; + } + + /** + * 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_) { + return + "Village".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 0; + } + + @Override + public void recreateStructures(int par1, int par2) { + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/australia/dimension/Dimension_Australia.java b/src/Java/gtPlusPlus/australia/dimension/Dimension_Australia.java new file mode 100644 index 0000000000..ff9e81085d --- /dev/null +++ b/src/Java/gtPlusPlus/australia/dimension/Dimension_Australia.java @@ -0,0 +1,23 @@ +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.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); + } + +} diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java new file mode 100644 index 0000000000..3f35758491 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_Australia_Ores.java @@ -0,0 +1,327 @@ +package gtPlusPlus.australia.gen.gt; + +import java.util.Hashtable; + +import net.minecraft.block.Block; + +import gregtech.api.enums.Materials; + +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.everglades.object.BoxedQuad; + +public class WorldGen_Australia_Ores { + + /** + * Set Ore Types on by one. + */ + + public static volatile Pair<Block, Integer> Geikielite; // MgTiO3 + public static volatile Pair<Block, Integer> Zimbabweite; // (Na,K)2PbAs4(Nb,Ta,Ti)4O18 + public static volatile Pair<Block, Integer> Titanite; // CaTiSiO5 + public static volatile Pair<Block, Integer> Zirconolite; // CaZrTi2O7 + public static volatile Pair<Block, Integer> Crocoite; // PbCrO4 + public static volatile Pair<Block, Integer> Nichromite; // (Ni,Co,Fe)(Cr,Fe,Al)2O4 + public static volatile Pair<Block, Integer> Yttriaite; // Y2O3 + public static volatile Pair<Block, Integer> Samarskite_Y; // (YFe3+Fe2+U,Th,Ca)2(Nb,Ta)2O8 + public static volatile Pair<Block, Integer> Samarskite_Yb; // (YbFe3+)2(Nb,Ta)2O8 + public static volatile Pair<Block, Integer> Zircon; // ZrSiO4 + public static volatile Pair<Block, Integer> Gadolinite_Ce; // (Ce2,La,Nd,Y)2FeBe2Si1O14 + public static volatile Pair<Block, Integer> Gadolinite_Y; // (Ce,La,Nd,Y2)2FeBe2Si4O9 + public static volatile Pair<Block, Integer> Lepersonnite; // Ca(Gd,Dy)2(UO2)24(SiO4)4(CO3)8(OH)24·48H2O + public static volatile Pair<Block, Integer> Xenotime; // YPO4 + public static volatile Pair<Block, Integer> Yttrialite; // Y2Th2Si2O7 + public static volatile Pair<Block, Integer> Yttrocerite; // CaF5YCe + public static volatile Pair<Block, Integer> Polycrase; // YCaCeUThTi2Nb2Ta2O6 + public static volatile Pair<Block, Integer> Zircophyllite; // (K,Na)3(Mn,Fe)7(Zr,Ti,Nb)2Si8O24(OH,F)7 + public static volatile Pair<Block, Integer> Zirkelite; // (Ca,Th,Ce)Zr(Ti,Nb)2O7 + public static volatile Pair<Block, Integer> Lanthanite_La; // (La)2(CO3)3·8(H2O). + public static volatile Pair<Block, Integer> Lanthanite_Ce; // (Ce)2(CO3)3·8(H2O). + public static volatile Pair<Block, Integer> Lanthanite_Nd; // (Nd)2(CO3)3·8(H2O). + public static volatile Pair<Block, Integer> Hibonite; // ((Ca,Ce)(Al,Ti,Mg)12O19) + public static volatile Pair<Block, Integer> Cerite; // (Ce,La,Ca)9(Mg,Fe+3)(SiO4)6(SiO3OH)(OH)3 + public static volatile Pair<Block, Integer> Agardite_Y; // (YCa)Cu5(As2O4)3(OH)6·3H2O + public static volatile Pair<Block, Integer> Agardite_Cd; // (CdCa)Cu7(AsO2)4(O2H)5·3H2O + public static volatile Pair<Block, Integer> Agardite_La; // (LaCa)Cu5(AsO6)2(OH)4·3H2O + public static volatile Pair<Block, Integer> Agardite_Nd; // (NdCa)Cu6(As3O3)2(O2H)6·3H2O + public static volatile Pair<Block, Integer> Fluorcaphite; // (Ca,Sr,Ce,Na)5(PO4)3F + public static volatile Pair<Block, Integer> Florencite; // SmAl3(PO4)2(OH)6 + public static volatile Pair<Block, Integer> Cryolite; // Na3AlF6 + //public static volatile Pair<Block, Integer> Pyroxene; // + + 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 PLATINUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Platinum); + 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 BAUXITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Bauxite); + + private static final Material NAQPLUS = MaterialUtils.generateMaterialFromGtENUM(Materials.NaquadahEnriched); + private static final Material NAQUADRIA = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadria); + private static final Material OSMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmium); + private static final Material AMETHYST = MaterialUtils.generateMaterialFromGtENUM(Materials.Amethyst); + private static final Material BISMUTH = MaterialUtils.generateMaterialFromGtENUM(Materials.Bismuth); + private static final Material PLUTONIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); + private static final Material URNAIUM235 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium235); + private static final Material INFUSEDGOLD = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedGold); + + + + public static WorldGen_GT_Australia_Ore_Layer BaseVein = new WorldGen_GT_Australia_Ore_Layer( + "veinA", + 20, 40, + 1, + 8, + 128, + ELEMENT.getInstance().ALUMINIUM, + ELEMENT.getInstance().SILICON, + ELEMENT.getInstance().COPPER, + ELEMENT.getInstance().LEAD); + + + + /** + * Custom ore Veins + */ + + public static WorldGen_GT_Australia_Ore_Layer Vein1 = new WorldGen_GT_Australia_Ore_Layer( + "vein1", + 0, 60, + 30, + 16, + 16, + ORES.AGARDITE_CD, + ORES.AGARDITE_LA, + ELEMENT.getInstance().SILICON, + ELEMENT.getInstance().BERYLLIUM); + + public static WorldGen_GT_Australia_Ore_Layer Vein2 = new WorldGen_GT_Australia_Ore_Layer( + "vein2", + 0, 60, + 30, + 16, + 16, + ORES.AGARDITE_ND, + ORES.AGARDITE_Y, + PYRITE, + ORES.CERITE); + + public static WorldGen_GT_Australia_Ore_Layer Vein3 = new WorldGen_GT_Australia_Ore_Layer( + "vein3", + 0, 60, + 30, + 16, + 32, + ORES.CERITE, + ORES.NICHROMITE, + PYROPE, + ORES.HIBONITE); + + public static WorldGen_GT_Australia_Ore_Layer Vein4 = new WorldGen_GT_Australia_Ore_Layer( + "vein4", + 0, 60, + 40, + 16, + 32, + ORES.GEIKIELITE, + ORES.CRYOLITE, + ORES.GADOLINITE_CE, + RUBY); + + + + public static WorldGen_GT_Australia_Ore_Layer Vein5 = new WorldGen_GT_Australia_Ore_Layer( + "vein5", + 30, 128, + 20, + 8, + 64, + ORES.HIBONITE, + ORES.YTTRIALITE, + ORES.ZIRCONILITE, + ORES.CERITE); + public static WorldGen_GT_Australia_Ore_Layer Vein6 = new WorldGen_GT_Australia_Ore_Layer( + "vein6", + 0, 40, + 20, + 8, + 64, + ORES.XENOTIME, + ORES.ZIRKELITE, + ORES.CROCROITE, + ALMANDINE); + public static WorldGen_GT_Australia_Ore_Layer Vein7 = new WorldGen_GT_Australia_Ore_Layer( + "vein7", + 40, 128, + 20, + 8, + 64, + RUBY, + TOPAZ, + ORES.SAMARSKITE_Y, + ORES.SAMARSKITE_YB); + public static WorldGen_GT_Australia_Ore_Layer Vein8 = new WorldGen_GT_Australia_Ore_Layer( + "vein8", + 0, 40, + 20, + 8, + 64, + ORES.TITANITE, + ORES.ZIMBABWEITE, + ORES.ZIRCON, + ORES.FLORENCITE); + + + + + 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 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); + + + public static volatile BoxedQuad<Integer, Integer, Integer, Integer> OreVein1 = new BoxedQuad(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); + } + +} diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java new file mode 100644 index 0000000000..8d8769fa87 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia.java @@ -0,0 +1,49 @@ +package gtPlusPlus.australia.gen.gt; + +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.xmod.gregtech.HANDLER_GT; + +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 = HANDLER_GT.sCustomWorldgenFile.get("worldgen-aus", 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 = HANDLER_GT.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 diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java new file mode 100644 index 0000000000..41c1816481 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Base.java @@ -0,0 +1,471 @@ +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; + +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().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM); + + 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.WORLD("Trying to Generate Dimension."); + synchronized (listLock) { + Logger.WORLD("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.WORLD("Locked List addition. Success."); + } + else { + Logger.WORLD("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.WORLD("Is not generating."); + this.mIsGenerating = true; + Logger.WORLD("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.WORLD("Locked List Removal."); + WorldGen_GT_Australia_Base.mList.remove(0); + } + toRun.run(); + } + this.mIsGenerating = false; + Logger.WORLD("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.INFO("[World Generation Debug] !validOreveins.containsKey(oreveinSeed) | oreveinSeed: "+oreveinSeed); + // Search for a valid orevein for this dimension + if (!validOreveins.containsKey(oreveinSeed)) { + + + Logger.INFO("[World Generation Debug] oreveinPercentageRoll < oreveinPercentage? "+((oreveinPercentageRoll < oreveinPercentage))); + Logger.INFO("[World Generation Debug] WorldGen_GT_Ore_Layer.sWeight > 0? "+(WorldGen_GT_Australia_Ore_Layer.sWeight > 0)); + Logger.INFO("[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.INFO("[World Generation Debug] i: "+i); + Logger.INFO("[World Generation Debug] placementAttempts: "+placementAttempts); + Logger.INFO("[World Generation Debug] oreveinAttempts: "+oreveinAttempts); + Logger.INFO("[World Generation Debug] (placementAttempts < oreveinMaxPlacementAttempts): "+(placementAttempts < oreveinMaxPlacementAttempts)); + Logger.INFO("[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.INFO("[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.INFO("[World Generation Debug] ORE_PLACED"); + break; + case WorldGen_GT_Australia_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: + placementAttempts++; + Logger.INFO("[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.INFO("[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.INFO("[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/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java new file mode 100644 index 0000000000..db6bac6e60 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java @@ -0,0 +1,511 @@ +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.dimension.Dimension_Australia; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; + +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 (NoSuchFieldException | 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.WORLD("Creating Ore Layer Object"); + this.mOverworld = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mNether = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); + this.mEnd = HANDLER_GT.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) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, HANDLER_GT.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 = HANDLER_GT.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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[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.WORLD("[World Generation Debug] Set "+tOreBlock.getLocalizedName()+" at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + return false; + } + + + private boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int mMetaItemSubID, boolean useless){ + + //Get Class and Methods + Method setOres = null; + boolean is08 = !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; + + //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) { + + } + return false; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java b/src/Java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java new file mode 100644 index 0000000000..5100ed31c5 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/item/ItemAustraliaPortalTrigger.java @@ -0,0 +1,100 @@ +package gtPlusPlus.australia.item; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +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"); + } + + @Override + public Item setMaxStackSize(int int1) { + return super.setMaxStackSize(1); + } + + @Override + public EnumRarity getRarity(ItemStack thisItem) { + return EnumRarity.rare; + } + + @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+"]"; + } + + @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 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 diff --git a/src/Java/gtPlusPlus/australia/item/ItemBlockAustralia.java b/src/Java/gtPlusPlus/australia/item/ItemBlockAustralia.java new file mode 100644 index 0000000000..9854f9fa6a --- /dev/null +++ b/src/Java/gtPlusPlus/australia/item/ItemBlockAustralia.java @@ -0,0 +1,39 @@ +package gtPlusPlus.australia.item; + +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?."); + } + } + + +} diff --git a/src/Java/gtPlusPlus/australia/world/AustraliaPortalPosition.java b/src/Java/gtPlusPlus/australia/world/AustraliaPortalPosition.java new file mode 100644 index 0000000000..865c0c3bb2 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/world/AustraliaPortalPosition.java @@ -0,0 +1,14 @@ +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 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 diff --git a/src/Java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java b/src/Java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java new file mode 100644 index 0000000000..4ad693263e --- /dev/null +++ b/src/Java/gtPlusPlus/australia/world/AustraliaTeleporterDimensionMod.java @@ -0,0 +1,470 @@ +package gtPlusPlus.australia.world; + +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 diff --git a/src/Java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java b/src/Java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java new file mode 100644 index 0000000000..f0bd35a8b9 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/world/AustraliaWorldChunkManager.java @@ -0,0 +1,257 @@ +package gtPlusPlus.australia.world; + +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; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeCache; +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 diff --git a/src/Java/gtPlusPlus/australia/world/AustraliaWorldProvider.java b/src/Java/gtPlusPlus/australia/world/AustraliaWorldProvider.java new file mode 100644 index 0000000000..af1ca90cc9 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/world/AustraliaWorldProvider.java @@ -0,0 +1,80 @@ +package gtPlusPlus.australia.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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 float getSunBrightness(float par1) { + return (par1*2F); + } + + @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); + } + + public boolean isSurfaceWorld() + { + return true; + } + + public boolean canCoordinateBeSpawn(int par1, int par2) + { + return false; + } + + public boolean canRespawnHere() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean doesXZShowFog(int par1, int par2) + { + return false; + } + + public String getDimensionName() + { + return "Australia"; + } + + 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); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/australia/world/AustraliaWorldType.java b/src/Java/gtPlusPlus/australia/world/AustraliaWorldType.java new file mode 100644 index 0000000000..e8c8af4f76 --- /dev/null +++ b/src/Java/gtPlusPlus/australia/world/AustraliaWorldType.java @@ -0,0 +1,59 @@ +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; + } +} + |