From 5715a32d2901922503fd850f3a68503fb77467c3 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 20 Dec 2017 23:39:49 +1000 Subject: - Disabled some logging. % Minor Project Clean-up, added missing Override annotations to 100+ methods & removed pointless casts. % Moved Logging to it's own class. $ Fixed Multi-block handling of Pollution. $ Fixed the GT 5.09 material enabler system. (From My Side, it's still borked on GTs). + Added a Dynamic Proxy invocation for IMaterialHandler. + Added an AutoMap data type, which is a Auto-incremental ID'd Hashmap wrapper. --- src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java | 4 ++-- .../core/entity/monster/EntityStaballoyConstruct.java | 12 ++++++++---- .../core/entity/projectile/EntityHydrofluoricAcidPotion.java | 5 ++--- .../core/entity/projectile/EntitySulfuricAcidPotion.java | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/Java/gtPlusPlus/core/entity') diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 5eb6e91812..5233c876e9 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -2,19 +2,19 @@ package gtPlusPlus.core.entity; import cpw.mods.fml.common.registry.EntityRegistry; import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; -import gtPlusPlus.core.util.Utils; public class InternalEntityRegistry { static int mEntityID = 0; public static void registerEntities(){ - Utils.LOG_INFO("Registering GT++ Entities."); + Logger.INFO("Registering GT++ Entities."); //EntityRegistry.registerModEntity(EntityMiningChargePrimed.class, "MiningCharge", 3, Main.modInstance, 64, 20, true); EntityRegistry.registerModEntity(EntityPrimedMiningExplosive.class, "MiningCharge", mEntityID++, GTplusplus.instance, 64, 20, true); EntityRegistry.registerModEntity(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", mEntityID++, GTplusplus.instance, 64, 20, true); diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index 2cbd00bf2c..e95ee5caf0 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -11,11 +11,9 @@ import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; import net.minecraft.village.Village; import net.minecraft.world.World; @@ -188,15 +186,18 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } } + @Override public Village getVillage() { return null; } + @Override @SideOnly(Side.CLIENT) public int getAttackTimer() { return this.attackTimer; } + @Override public void setHoldingRose(boolean p_70851_1_) { this.holdRoseTick = p_70851_1_ ? 400 : 0; this.worldObj.setEntityState(this, (byte) 11); @@ -248,14 +249,17 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } } + @Override public int getHoldRoseTick() { return this.holdRoseTick; } + @Override public boolean isPlayerCreated() { return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; } + @Override public void setPlayerCreated(boolean p_70849_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java index 8b86d456b7..c935409650 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java @@ -5,10 +5,8 @@ import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; @@ -34,6 +32,7 @@ public class EntityHydrofluoricAcidPotion extends EntityThrowable { /** * Called when this EntityThrowable hits a block or entity. */ + @Override protected void onImpact(MovingObjectPosition object) { int xBlock = object.blockX; int yBlock = object.blockY; @@ -41,7 +40,7 @@ public class EntityHydrofluoricAcidPotion extends EntityThrowable { if (object.entityHit != null) { byte b0 = 6; if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ - object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) b0); + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); EntityUtils.setEntityOnFire(object.entityHit, 5); if (object.entityHit instanceof EntityPlayer){ diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java index 38bcb42791..cd4bec52bf 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java @@ -29,6 +29,7 @@ public class EntitySulfuricAcidPotion extends EntityThrowable { /** * Called when this EntityThrowable hits a block or entity. */ + @Override protected void onImpact(MovingObjectPosition object) { int xBlock = object.blockX; int yBlock = object.blockY; @@ -36,7 +37,7 @@ public class EntitySulfuricAcidPotion extends EntityThrowable { if (object.entityHit != null) { byte b0 = 6; if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ - object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) b0); + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); EntityUtils.setEntityOnFire(object.entityHit, 10); object.entityHit.fireResistance = 0; ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); -- cgit From ecc60485f31011bf9cc6a02edb985fb683793bb7 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Thu, 21 Dec 2017 15:48:47 +1000 Subject: + Added a dimension ID config option which it now will try use if available. % More work on the Dimension again. $ Fixed NPE caused by disabled material handler. $ Fixed bad fluid used in world generation. # Fixed spawn rate of mobs in custom dimension. --- src/Java/gtPlusPlus/GTplusplus_Secondary.java | 37 +-- .../gtPlusPlus/core/block/base/BlockBaseFluid.java | 102 +++++++++ src/Java/gtPlusPlus/core/config/ConfigHandler.java | 4 +- .../entity/monster/EntityStaballoyConstruct.java | 252 +++++++++++++++++---- src/Java/gtPlusPlus/core/lib/CORE.java | 1 + .../core/world/darkworld/Dimension_DarkWorld.java | 11 +- .../world/darkworld/biome/Biome_DarkWorld.java | 84 +++---- .../darkworld/block/DarkWorldContentLoader.java | 68 ++++++ .../darkworld/block/blockDarkWorldSludgeFluid.java | 98 ++++++++ .../world/darkworld/chunk/ChunkProviderModded.java | 7 +- .../xmod/forestry/bees/custom/GTPP_Bees.java | 8 +- .../xmod/forestry/trees/TreefarmManager.java | 4 +- .../xmod/thermalfoundation/HANDLER_TF.java | 5 +- 13 files changed, 554 insertions(+), 127 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java create mode 100644 src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java create mode 100644 src/Java/gtPlusPlus/core/world/darkworld/block/blockDarkWorldSludgeFluid.java (limited to 'src/Java/gtPlusPlus/core/entity') diff --git a/src/Java/gtPlusPlus/GTplusplus_Secondary.java b/src/Java/gtPlusPlus/GTplusplus_Secondary.java index e3bdb89c3a..670f6d0fc8 100644 --- a/src/Java/gtPlusPlus/GTplusplus_Secondary.java +++ b/src/Java/gtPlusPlus/GTplusplus_Secondary.java @@ -14,15 +14,9 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.core.world.darkworld.biome.Biome_DarkWorld; -import gtPlusPlus.core.world.darkworld.block.blockDarkWorldGround; -import gtPlusPlus.core.world.darkworld.block.blockDarkWorldPollutedDirt; -import gtPlusPlus.core.world.darkworld.block.blockDarkWorldPortal; -import gtPlusPlus.core.world.darkworld.block.blockDarkWorldPortalFrame; -import gtPlusPlus.core.world.darkworld.item.itemDarkWorldPortalTrigger; +import gtPlusPlus.core.world.darkworld.block.DarkWorldContentLoader; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; @@ -80,17 +74,10 @@ public class GTplusplus_Secondary implements IFuelHandler, IWorldGenerator{ } void setVars(){ - Dimension_DarkWorld.DIMID = DimensionManager.getNextFreeDimId(); - Dimension_DarkWorld.portalBlock = new blockDarkWorldPortal(); - Dimension_DarkWorld.portalItem = (itemDarkWorldPortalTrigger) (new itemDarkWorldPortalTrigger().setUnlocalizedName("dimensionDarkWorld_trigger")); - Item.itemRegistry.addObject(423, "dimensionDarkWorld_trigger", Dimension_DarkWorld.portalItem); - Dimension_DarkWorld.blockTopLayer = new blockDarkWorldGround(); - Dimension_DarkWorld.blockSecondLayer = new blockDarkWorldPollutedDirt(); - GameRegistry.registerBlock(Dimension_DarkWorld.blockTopLayer, "blockDarkWorldGround"); - GameRegistry.registerBlock(Dimension_DarkWorld.blockSecondLayer, "blockDarkWorldGround2"); - Blocks.fire.setFireInfo(Dimension_DarkWorld.blockTopLayer, 30, 20); - Dimension_DarkWorld.blockPortalFrame = new blockDarkWorldPortalFrame(); - GameRegistry.registerBlock(Dimension_DarkWorld.blockPortalFrame, "blockDarkWorldPortalFrame"); + if (DimensionManager.isDimensionRegistered(Dimension_DarkWorld.DIMID)){ + Dimension_DarkWorld.DIMID = DimensionManager.getNextFreeDimId(); + } + DarkWorldContentLoader.run(); } @EventHandler @@ -111,19 +98,19 @@ public class GTplusplus_Secondary implements IFuelHandler, IWorldGenerator{ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { chunkX = chunkX * 16; - chunkZ = chunkZ * 16; + chunkZ = chunkZ * 16; + + /*if (world.provider.dimensionId == Dimension_DarkWorld.DIMID) { + DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); + }*/ + + //What does this even do? if (world.provider.dimensionId == -1) { DarkWorld_Biome.generateNether(world, random, chunkX, chunkZ); } if (world.provider.dimensionId == 0) { DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); } - if (world.provider.dimensionId == -1) { - DarkWorld_Dimension.generateNether(world, random, chunkX, chunkZ); - } - if (world.provider.dimensionId == 0) { - - } } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java new file mode 100644 index 0000000000..6f837e8709 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java @@ -0,0 +1,102 @@ +package gtPlusPlus.core.block.base; + +import java.util.Random; + +import cofh.lib.render.particle.EntityDropParticleFX; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +public class BlockBaseFluid extends BlockFluidClassic { + + private final String name; + private final IIcon textureArray[] = new IIcon[6]; + + protected float particleRed = 1.0F; + protected float particleGreen = 1.0F; + protected float particleBlue = 1.0F; + + public BlockBaseFluid(String materialName, Fluid fluid, Material material) { + super(fluid, material); + this.setLightOpacity(2); + this.name = Utils.sanitizeString(materialName); + this.setBlockName("fluid"+this.name); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "fluid"+this.name); + } + + public BlockFluidClassic setParticleColor(int arg0) { + return this.setParticleColor((arg0 >> 16 & 255) / 255.0F, (arg0 >> 8 & 255) / 255.0F, + (arg0 >> 0 & 255) / 255.0F); + } + + public BlockFluidClassic setParticleColor(float arg0, float arg1, float arg2) { + this.particleRed = arg0; + this.particleGreen = arg1; + this.particleBlue = arg2; + return this; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4) { + return false; + } + + public boolean preInit() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side <= 1 ? this.textureArray[0] : this.textureArray[1]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Still"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Flow"); + //IconRegistry.addIcon("Fluid" + this.name, this.modName + ":fluid/Fluid_" + this.name + "_Still", arg0); + //IconRegistry.addIcon("Fluid" + this.name + "1", this.modName + ":fluid/Fluid_" + this.name + "_Flow", arg0); + } + + @Override + @Optional.Method(modid = "CoFHCore") + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World arg0, int arg1, int arg2, int arg3, Random arg4) { + super.randomDisplayTick(arg0, arg1, arg2, arg3, arg4); + double arg5 = arg1 + arg4.nextFloat(); + double arg7 = arg2 - 1.05D; + double arg9 = arg3 + arg4.nextFloat(); + if (super.density < 0) { + arg7 = arg2 + 2.1D; + } + + if (arg4.nextInt(20) == 0 + && arg0.isSideSolid(arg1, arg2 + super.densityDir, arg3, + super.densityDir == -1 ? ForgeDirection.UP : ForgeDirection.DOWN) + && !arg0.getBlock(arg1, arg2 + 2 * super.densityDir, arg3).getMaterial().blocksMovement()) { + EntityDropParticleFX arg11 = new EntityDropParticleFX(arg0, arg5, arg7, arg9, this.particleRed, + this.particleGreen, this.particleBlue, super.densityDir); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(arg11); + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index c86b12b51b..641a4c0956 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -1,8 +1,7 @@ package gtPlusPlus.core.config; import static gtPlusPlus.core.item.general.RF2EU_Battery.rfPerEU; -import static gtPlusPlus.core.lib.CORE.DARKBIOME_ID; -import static gtPlusPlus.core.lib.CORE.DEBUG; +import static gtPlusPlus.core.lib.CORE.*; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.*; import static gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames; @@ -151,6 +150,7 @@ public class ConfigHandler { "Disables Zombie Reinforcement on hard difficutly."); //Biomes + DARKWORLD_ID = config.getInt("darkworld_ID", "worldgen", 227, 1, 254, "The ID of the Dark Dimension."); DARKBIOME_ID = config.getInt("darkbiome_ID", "worldgen", 238, 1, 254, "The biome within the Dark Dimension."); //Blacklisted Accelerator TileEntities diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index e95ee5caf0..5a3e0348fe 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -1,13 +1,17 @@ package gtPlusPlus.core.entity.monster; +import java.lang.reflect.Field; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.*; import net.minecraft.entity.ai.*; +import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; @@ -18,26 +22,30 @@ import net.minecraft.village.Village; import net.minecraft.world.World; public class EntityStaballoyConstruct extends EntityIronGolem { - /** deincrements, and a distance-to-home check is done at 0 */ - private int homeCheckTimer; - Village villageObj; - private int attackTimer; - private int holdRoseTick; + + /* + * Determines whether or not the entity is in a fluid at all. + */ + private volatile boolean inFluid = false; + private volatile boolean mReflectFirstUpdate = true; + private volatile int attackTimer; public EntityStaballoyConstruct(World world) { super(world); this.setSize(1.4F, 2.9F); this.getNavigator().setAvoidsWater(true); + this.getNavigator().setBreakDoors(true); + this.getNavigator().setCanSwim(false); + this.getNavigator().setAvoidSun(false); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); - //this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); //this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); - this.tasks.addTask(2, new EntityAIMoveTowardsRestriction(this, 1.0D)); - this.tasks.addTask(3, new EntityAIWander(this, 0.6D)); - this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - this.tasks.addTask(5, new EntityAILookIdle(this)); + this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(4, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(6, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - //this.targetTasks.addTask(2, - //new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); } @Override @@ -59,11 +67,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { */ @Override protected void updateAITick() { - if (--this.homeCheckTimer <= 0) { - this.homeCheckTimer = 70 + this.rand.nextInt(50); - this.detachHome(); - } - super.updateAITick(); } @@ -79,7 +82,7 @@ public class EntityStaballoyConstruct extends EntityIronGolem { */ @Override protected int decreaseAirSupply(int p_70682_1_) { - return p_70682_1_; + return 0; } @Override @@ -104,10 +107,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { --this.attackTimer; } - if (this.holdRoseTick > 0) { - --this.holdRoseTick; - } - if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0) { int i = MathHelper.floor_double(this.posX); @@ -115,8 +114,8 @@ public class EntityStaballoyConstruct extends EntityIronGolem { int k = MathHelper.floor_double(this.posZ); Block block = this.worldObj.getBlock(i, j, k); - - + + if (block.getMaterial() != Material.air) { this.worldObj.spawnParticle( "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), @@ -133,9 +132,8 @@ public class EntityStaballoyConstruct extends EntityIronGolem { * Returns true if this entity can attack entities of the specified class. */ @Override - public boolean canAttackClass(Class p_70686_1_) { - return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(p_70686_1_) ? false - : super.canAttackClass(p_70686_1_); + public boolean canAttackClass(Class clazz) { + return clazz.equals(this.getClass()) ? false : true; } /** @@ -178,9 +176,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { this.attackTimer = 10; this.playSound("mob.irongolem.throw", 1.0F, 1.0F); } - else if (p_70103_1_ == 11) { - this.holdRoseTick = 400; - } else { super.handleHealthUpdate(p_70103_1_); } @@ -197,12 +192,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { return this.attackTimer; } - @Override - public void setHoldingRose(boolean p_70851_1_) { - this.holdRoseTick = p_70851_1_ ? 400 : 0; - this.worldObj.setEntityState(this, (byte) 11); - } - /** * Returns the sound this mob makes when it is hurt. */ @@ -221,7 +210,7 @@ public class EntityStaballoyConstruct extends EntityIronGolem { @Override protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { - //this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); } /** @@ -249,11 +238,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } } - @Override - public int getHoldRoseTick() { - return this.holdRoseTick; - } - @Override public boolean isPlayerCreated() { return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; @@ -278,4 +262,188 @@ public class EntityStaballoyConstruct extends EntityIronGolem { public void onDeath(DamageSource p_70645_1_) { super.onDeath(p_70645_1_); } + + @Override + protected String getLivingSound() { //TODO + return super.getLivingSound(); + } + + @Override + public int getTalkInterval() { + return 0; + } + + @Override + protected boolean canDespawn() { + return true; + } + + @Override + public void onEntityUpdate() { + //Set Fire Immunity + if (!this.isImmuneToFire){ + this.isImmuneToFire = true; + } + + //Handle Exploding + if (isReadyToExplode){ + if (this.fuse-- <= 0){ + this.setDead(); + + if (!this.worldObj.isRemote) + { + this.explode(); + } + } + else + { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + } + } + + //Get a private field from a super class if it exists. + if (ReflectionUtils.getField(this, "firstUpdate") != null && mReflectFirstUpdate == true){ + Field x = ReflectionUtils.getField(this, "firstUpdate"); + try { + this.mReflectFirstUpdate = (boolean) x.get(this); + } + catch (IllegalArgumentException | IllegalAccessException e) {} + } + super.onEntityUpdate(); + } + + @Override + public int getMaxSpawnedInChunk() { + return 1; + } + + @Override + public boolean canBreatheUnderwater() { + return true; + } + + @Override + public void knockBack(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_) { + // Do Nothing because he weighs metric shittonnes. + } + + @Override + protected void setOnFireFromLava() { + extinguish(); + } + + @Override + public void setFire(int p_70015_1_) { + extinguish(); + } + + @Override + protected void dealFireDamage(int p_70081_1_) { + + } + + @Override + public boolean isInWater() { + if (super.isInWater()){ + return true; + } + else { + this.moveForward *= 0.98F; + return false; + } + } + + @Override + public boolean handleWaterMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.water); + } + + @Override + public boolean handleLavaMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.lava); + } + + /** + * Returns if this entity is in water and will end up adding the waters velocity to the entity + */ + public boolean handleFluidMovement(Material fluid){ + + + + if (this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), fluid, this)) + { + if (!this.inFluid && !this.mReflectFirstUpdate) + { + float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F; + + if (f > 1.0F) + { + f = 1.0F; + } + + this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + float f1 = MathHelper.floor_double(this.boundingBox.minY); + int i; + float f2; + float f3; + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) + { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("bubble", this.posX + f2, f1 + 1.0F, this.posZ + f3, this.motionX, this.motionY - this.rand.nextFloat() * 0.2F, this.motionZ); + } + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) + { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("splash", this.posX + f2, f1 + 1.0F, this.posZ + f3, this.motionX, this.motionY, this.motionZ); + } + } + this.fallDistance = 0.0F; + this.inFluid = true; + } + else + { + this.inFluid = false; + } + return this.inFluid; + } + + @Override + public void onChunkLoad() { + // TODO Auto-generated method stub + super.onChunkLoad(); + } + + private int fuse = 60; + private boolean isReadyToExplode = false; + @Override + public void onStruckByLightning(EntityLightningBolt p_70077_1_) { + this.isReadyToExplode = true; + this.fuse = 20; + } + + private void explode(){ + float f = 12.0F; + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); + } + + @Override + public boolean canAttackWithItem() { + return true; + } + + @Override + public boolean canRenderOnFire() { + return false; + } + + @Override + public boolean isPushedByWater() { + return false; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index cc6fade7ce..5de70b467a 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -53,6 +53,7 @@ public class CORE { //Tweakables public static int DARKBIOME_ID = 238; + public static int DARKWORLD_ID = 227; //GT Vars; public static final int GREG_FIRST_ID = 760; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/Dimension_DarkWorld.java b/src/Java/gtPlusPlus/core/world/darkworld/Dimension_DarkWorld.java index 71d0e59492..22b8973cdb 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/Dimension_DarkWorld.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/Dimension_DarkWorld.java @@ -5,23 +5,20 @@ import java.util.Random; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.world.darkworld.block.*; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.world.darkworld.block.blockDarkWorldPortal; import gtPlusPlus.core.world.darkworld.item.itemDarkWorldPortalTrigger; import gtPlusPlus.core.world.darkworld.world.WorldProviderMod; import net.minecraft.block.Block; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; -@SuppressWarnings("unchecked") public class Dimension_DarkWorld { public Object instance; - public static int DIMID = 227; + public static int DIMID = CORE.DARKWORLD_ID; public static blockDarkWorldPortal portalBlock; public static itemDarkWorldPortalTrigger portalItem; @@ -29,7 +26,7 @@ public class Dimension_DarkWorld { public static Block blockSecondLayer; public static Block blockMainFiller = Blocks.stone; public static Block blockSecondaryFiller; - public static Block blockFluidLakes = ModBlocks.blockFluidSludge; + public static Block blockFluidLakes; public static Block blockPortalFrame; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java b/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java index f90966714e..2970a2c3de 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.world.darkworld.biome; +import java.lang.reflect.Field; import java.util.Random; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -10,16 +11,10 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; -import net.minecraft.entity.monster.EntityBlaze; -import net.minecraft.entity.monster.EntityCaveSpider; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.EntitySpider; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.passive.*; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntitySquid; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -28,7 +23,7 @@ import net.minecraftforge.common.BiomeManager; public class Biome_DarkWorld { - public static BiomeGenbiomeDarkWorld biome = new BiomeGenbiomeDarkWorld(); + public static BiomeGenDarkWorld biome = new BiomeGenDarkWorld(); public Object instance; @@ -38,8 +33,6 @@ public class Biome_DarkWorld { public void load() { BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DEAD); BiomeManager.addSpawnBiome(biome); - // BiomeManager.desertBiomes.add(new BiomeManager.BiomeEntry(biome, - // 10)); } public void generateNether(World world, Random random, int chunkX, int chunkZ) { @@ -61,10 +54,11 @@ public class Biome_DarkWorld { public void preInit(FMLPreInitializationEvent event) { } - static class BiomeGenbiomeDarkWorld extends BiomeGenBase { + static class BiomeGenDarkWorld extends BiomeGenBase { @SuppressWarnings("unchecked") - public BiomeGenbiomeDarkWorld() { + public BiomeGenDarkWorld() { super(CORE.DARKBIOME_ID); + this.setBiomeID(); this.theBiomeDecorator = new BiomeGenerator_Custom(); Logger.INFO("Dark World Temperature Category: "+getTempCategory()); this.setBiomeName("Dark World"); @@ -82,29 +76,41 @@ public class Biome_DarkWorld { this.spawnableCreatureList.clear(); this.spawnableWaterCreatureList.clear(); this.spawnableCaveCreatureList.clear(); - - //Enemies - this.spawnableMonsterList.add(new SpawnListEntry(EntitySickBlaze.class, 10, 4, 10)); - this.spawnableMonsterList.add(new SpawnListEntry(EntitySickBlaze.class, 60, 1, 2)); - this.spawnableMonsterList.add(new SpawnListEntry(EntityStaballoyConstruct.class, 30, 1, 2)); - //this.spawnableMonsterList.add(new SpawnListEntry(EntityStaballoyConstruct.class, 5, 1, 5)); - - addToMonsterSpawnLists(EntityBlaze.class, 5, 1, 5); - addToMonsterSpawnLists(EntityCaveSpider.class, 5, 1, 5); - addToMonsterSpawnLists(EntityCreeper.class, 4, 1, 2); - addToMonsterSpawnLists(EntityEnderman.class, 5, 1, 5); - addToMonsterSpawnLists(EntitySkeleton.class, 5, 1, 5); - addToMonsterSpawnLists(EntitySpider.class, 5, 1, 5); - addToMonsterSpawnLists(EntityZombie.class, 5, 1, 5); - - //Passive - this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 5, 5, 10)); - this.spawnableCreatureList.add(new SpawnListEntry(EntityBat.class, 4, 4, 8)); - this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 5, 4, 10)); - - //Water - this.spawnableWaterCreatureList.add(new SpawnListEntry(EntitySquid.class, 5, 1, 10)); - + + //Enemies + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySickBlaze.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityStaballoyConstruct.class, 80, 1, 2)); + + //Animals + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); + this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); + + } + + private synchronized boolean setBiomeID() { + BiomeGenBase[] mTempList; + try { + Field mInternalBiomeList = ReflectionUtils.getField(BiomeGenBase.class, "biomeList"); + Field mClone = mInternalBiomeList; + mTempList = (BiomeGenBase[]) mInternalBiomeList.get(null); + if (mTempList != null){ + mTempList[CORE.DARKBIOME_ID] = this; + mInternalBiomeList.set(null, mTempList); + if (mClone != mInternalBiomeList && mClone.hashCode() != mInternalBiomeList.hashCode()){ + ReflectionUtils.setFinalStatic(mInternalBiomeList, mTempList); + Logger.REFLECTION("Set Biome ID for Dark World Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); + return true; + } + else { + Logger.REFLECTION("Failed to set Biome ID for Dark World Biome internally in 'biomeList' field from "+BiomeGenBase.class.getCanonicalName()+"."); + } + } + return false; + } + catch (Exception e) { + Logger.REFLECTION("Could not access 'biomeList' field in "+BiomeGenBase.class.getCanonicalName()+"."); + return false; + } } @SideOnly(Side.CLIENT) @@ -122,8 +128,8 @@ public class Biome_DarkWorld { public int getSkyColorByTemp(float par1) { return 0xF67A14; } - - @SuppressWarnings("unchecked") + + @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)); diff --git a/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java b/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java new file mode 100644 index 0000000000..1af92c0d3f --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.world.darkworld.block; + +import static gtPlusPlus.core.world.darkworld.Dimension_DarkWorld.*; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.block.base.BlockBaseFluid; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.world.darkworld.item.itemDarkWorldPortalTrigger; +import net.minecraft.init.Blocks; +import net.minecraftforge.fluids.FluidRegistry; + +public class DarkWorldContentLoader { + + //Static Vars + public static blockDarkWorldSludgeFluid SLUDGE; + + + public synchronized static void run() { + initMisc(); + initItems(); + initBlocks(); + } + + public synchronized static boolean initMisc(){ + + //Fluids + SLUDGE = (blockDarkWorldSludgeFluid) new blockDarkWorldSludgeFluid( + "sludge", + Utils.rgbtoHexValue(30, 130, 30)) + .setDensity(1800) + .setGaseous(false) + .setLuminosity(2) + .setViscosity(25000) + .setTemperature(300); + FluidRegistry.registerFluid(SLUDGE); + + return true; + } + + public synchronized static boolean initItems(){ + portalItem = (itemDarkWorldPortalTrigger) (new itemDarkWorldPortalTrigger().setUnlocalizedName("dimensionDarkWorld_trigger")); + GameRegistry.registerItem(portalItem, "dimensionDarkWorld_trigger"); + + return true; + } + + public synchronized static boolean initBlocks(){ + + //Create Block Instances + blockFluidLakes = new BlockBaseFluid("Sludge", SLUDGE, blockDarkWorldSludgeFluid.SLUDGE).setLightLevel(2f).setLightOpacity(1); + portalBlock = new blockDarkWorldPortal(); + blockTopLayer = new blockDarkWorldGround(); + blockSecondLayer = new blockDarkWorldPollutedDirt(); + blockPortalFrame = new blockDarkWorldPortalFrame(); + + //Registry + GameRegistry.registerBlock(blockTopLayer, "blockDarkWorldGround"); + GameRegistry.registerBlock(blockSecondLayer, "blockDarkWorldGround2"); + GameRegistry.registerBlock(blockPortalFrame, "blockDarkWorldPortalFrame"); + + //Make Flammable + Blocks.fire.setFireInfo(blockTopLayer, 30, 20); + + return true; + } + + +} diff --git a/src/Java/gtPlusPlus/core/world/darkworld/block/blockDarkWorldSludgeFluid.java b/src/Java/gtPlusPlus/core/world/darkworld/block/blockDarkWorldSludgeFluid.java new file mode 100644 index 0000000000..c3c9beddc8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/darkworld/block/blockDarkWorldSludgeFluid.java @@ -0,0 +1,98 @@ +package gtPlusPlus.core.world.darkworld.block; + +import net.minecraft.block.material.*; +import net.minecraftforge.fluids.Fluid; + +public class blockDarkWorldSludgeFluid extends Fluid { + + + public static final Material SLUDGE = new MaterialLiquid(MapColor.dirtColor); + + protected static int mapColor = 0xFFFFFFFF; + protected static float overlayAlpha = 0.2F; + //protected static SoundEvent emptySound = SoundEvents.ITEM_BUCKET_EMPTY; + //protected static SoundEvent fillSound = SoundEvents.ITEM_BUCKET_FILL; + protected static Material material = SLUDGE; + + + public blockDarkWorldSludgeFluid(String fluidName, int rgbColour) { + this(fluidName, rgbColour, null); + } + + public blockDarkWorldSludgeFluid(String fluidName, int rgbColour, Float overlayAlpha) { + super(fluidName); + setColor(rgbColour); + if (overlayAlpha != null){ + setAlpha(overlayAlpha.floatValue()); + } + else { + setAlpha(0); + } + } + + @Override + public int getColor() + { + return mapColor; + } + + public blockDarkWorldSludgeFluid setColor(int parColor) + { + mapColor = parColor; + return this; + } + + public float getAlpha() + { + return overlayAlpha; + } + + public blockDarkWorldSludgeFluid setAlpha(float parOverlayAlpha) + { + overlayAlpha = parOverlayAlpha; + return this; + } + + /*public blockDarkWorldSludgeFluid setEmptySound(SoundEvent parSound) + { + emptySound = parSound; + return this; + } + + public SoundEvent getEmptySound() + { + return emptySound; + } + + @Override + public blockDarkWorldSludgeFluid setFillSound(SoundEvent parSound) + { + fillSound = parSound; + return this; + } + + @Override + public SoundEvent getFillSound() + { + return fillSound; + }*/ + + public blockDarkWorldSludgeFluid setMaterial(Material parMaterial) + { + material = parMaterial; + return this; + } + + public Material getMaterial() + { + return material; + } + + /*@Override + public boolean doesVaporize(FluidStack fluidStack) + { + if (block == null) + return false; + return block.getDefaultState().getMaterial() == getMaterial(); + }*/ +} diff --git a/src/Java/gtPlusPlus/core/world/darkworld/chunk/ChunkProviderModded.java b/src/Java/gtPlusPlus/core/world/darkworld/chunk/ChunkProviderModded.java index 1695714eff..82b21d7c0d 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/chunk/ChunkProviderModded.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/chunk/ChunkProviderModded.java @@ -171,7 +171,12 @@ public class ChunkProviderModded implements IChunkProvider { p_147424_3_[j3 += short1] = Dimension_DarkWorld.blockMainFiller; } else if (k2 * 8 + l2 < b0) { - p_147424_3_[j3 += short1] = Blocks.water; //River Fluid + try { + p_147424_3_[j3 += short1] = Dimension_DarkWorld.blockFluidLakes; //River Fluid . + } + catch (Throwable t){ + p_147424_3_[j3 += short1] = Blocks.water; //River Fluid Fallback + } } else { p_147424_3_[j3 += short1] = null; diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 9e24eb5a53..37e479efd2 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.forestry.bees.custom; -import static gtPlusPlus.GTplusplus.mGregMatLoader; - import java.lang.reflect.*; import org.apache.commons.lang3.reflect.FieldUtils; @@ -76,7 +74,7 @@ public class GTPP_Bees { private void setCustomItems() { dropForceGem = new BaseItemMisc("Force", new short[]{250, 250, 20}, 64, MiscTypes.GEM, null); - mGregMatLoader.enableMaterial(Materials.Force); + //mGregMatLoader.enableMaterial(Materials.Force); //MaterialUtils.tryEnableMaterial(Materials.Force); //MaterialUtils.tryEnableMaterialPart(OrePrefixes.dust, Materials.Force); //MaterialUtils.tryEnableMaterialPart(OrePrefixes.ingot, Materials.Force); @@ -85,8 +83,8 @@ public class GTPP_Bees { //Nikolite may not exist, so lets make it. dropNikoliteDust = ItemUtils.generateSpecialUseDusts("Nikolite", "Nikolite", Utils.rgbtoHexValue(60, 180, 200))[2]; - mGregMatLoader.enableMaterial(Materials.BlueAlloy); - mGregMatLoader.enableMaterial(Materials.Nikolite); + //mGregMatLoader.enableMaterial(Materials.BlueAlloy); + //mGregMatLoader.enableMaterial(Materials.Nikolite); //MaterialUtils.tryEnableMaterial(Materials.Nikolite); //MaterialUtils.tryEnableMaterialPart(OrePrefixes.dust, Materials.Nikolite); //MaterialUtils.tryEnableMaterialPart(OrePrefixes.ingot, Materials.Nikolite); diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java index 9aea37e0d4..155feae83c 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java +++ b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java @@ -100,10 +100,10 @@ public class TreefarmManager { public static boolean isSapling(final Block log){ if (log != null){ if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ - Logger.INFO(""+log.getLocalizedName()); + Logger.WARNING(""+log.getLocalizedName()); } if (log.getLocalizedName().toLowerCase().contains("sapling")){ - Logger.INFO(""+log.getLocalizedName()); + Logger.WARNING(""+log.getLocalizedName()); return true; } } diff --git a/src/Java/gtPlusPlus/xmod/thermalfoundation/HANDLER_TF.java b/src/Java/gtPlusPlus/xmod/thermalfoundation/HANDLER_TF.java index 0480641e32..fe9a82c6b5 100644 --- a/src/Java/gtPlusPlus/xmod/thermalfoundation/HANDLER_TF.java +++ b/src/Java/gtPlusPlus/xmod/thermalfoundation/HANDLER_TF.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.thermalfoundation; -import static gtPlusPlus.GTplusplus.mGregMatLoader; - -import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.thermalfoundation.block.TF_Blocks; @@ -19,7 +16,7 @@ public class HANDLER_TF{ TF_Blocks.preInit(); if (LoadedMods.Gregtech){ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - mGregMatLoader.enableMaterial(Materials.Enderium); + //mGregMatLoader.enableMaterial(Materials.Enderium); } } } -- cgit From cf044120cad3ff1aa2fd40b4ae8989f7e898546e Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Thu, 21 Dec 2017 19:16:36 +1000 Subject: + Added a better Ai and combat mechanics to the Staballoy Constructs. + Tried to implement new World generation for my dimension. % Small tweak to gitignore. --- .gitignore | 2 +- src/Java/gtPlusPlus/GTplusplus_Secondary.java | 77 +- src/Java/gtPlusPlus/api/objects/Logger.java | 8 + .../core/entity/monster/EntitySickBlaze.java | 6 +- .../entity/monster/EntityStaballoyConstruct.java | 163 ++++- .../core/util/reflect/ReflectionUtils.java | 2 +- .../darkworld/biome/BiomeGenerator_Custom.java | 803 +++++++++++---------- .../world/darkworld/biome/Biome_DarkWorld.java | 9 +- .../darkworld/block/DarkWorldContentLoader.java | 2 +- .../darkworld/gen/WorldGenMinable_Custom.java | 142 ++-- .../world/darkworld/gen/gt/WorldGen_GT_Base.java | 412 +++++++++++ .../darkworld/gen/gt/WorldGen_GT_Ore_Layer.java | 272 +++++++ 12 files changed, 1363 insertions(+), 535 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java create mode 100644 src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Ore_Layer.java (limited to 'src/Java/gtPlusPlus/core/entity') diff --git a/.gitignore b/.gitignore index fdea5382ff..565c28d3ca 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ mods/ resourcepacks/ saves/ VillageWiper/ -world/ # Windows shortcuts *.lnk @@ -111,3 +110,4 @@ local.properties # STS (Spring Tool Suite) .springBeans /screenshots +/world diff --git a/src/Java/gtPlusPlus/GTplusplus_Secondary.java b/src/Java/gtPlusPlus/GTplusplus_Secondary.java index 670f6d0fc8..329d3fdb1d 100644 --- a/src/Java/gtPlusPlus/GTplusplus_Secondary.java +++ b/src/Java/gtPlusPlus/GTplusplus_Secondary.java @@ -1,10 +1,9 @@ package gtPlusPlus; import java.io.File; -import java.util.Random; import cofh.mod.ChildMod; -import cpw.mods.fml.common.*; +import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.CustomProperty; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.*; @@ -15,11 +14,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.core.world.darkworld.biome.Biome_DarkWorld; import gtPlusPlus.core.world.darkworld.block.DarkWorldContentLoader; +import gtPlusPlus.core.world.darkworld.gen.gt.WorldGen_GT_Base; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.Configuration; @@ -29,28 +26,16 @@ name = "GT++ Dark World", version = CORE.VERSION, dependencies = "after:Miscutils;after:Gregtech", customProperties = @CustomProperty(k = "cofhversion", v = "true"))) -public class GTplusplus_Secondary implements IFuelHandler, IWorldGenerator{ +public class GTplusplus_Secondary { public static final String MODID2 = "GT++ Dark World"; public static final String VERSION2 = "0.1"; // Dark World Handler - Biome_DarkWorld DarkWorld_Biome; - Dimension_DarkWorld DarkWorld_Dimension; + protected static volatile Biome_DarkWorld DarkWorld_Biome; + protected static volatile Dimension_DarkWorld DarkWorld_Dimension; public static int globalDarkWorldPortalSpawnTimer = 0; - @EventHandler - public void load(final FMLInitializationEvent e) { - Logger.INFO("Begin resource allocation for " + MODID2 + " V" + VERSION2); - - //Load Dark World and Biome - GameRegistry.registerFuelHandler(this); - GameRegistry.registerWorldGenerator(this, 1); - DarkWorld_Biome.load(); - DarkWorld_Dimension.load(); - - } - // Pre-Init @Mod.EventHandler public void preInit(final FMLPreInitializationEvent event) { @@ -59,50 +44,74 @@ public class GTplusplus_Secondary implements IFuelHandler, IWorldGenerator{ //Setup setVars(); - DarkWorld_Biome = new Biome_DarkWorld(); + setDarkBiome(new Biome_DarkWorld()); DarkWorld_Dimension = new Dimension_DarkWorld(); // Load Dark World - DarkWorld_Biome.instance = GTplusplus.instance; + getDarkBiome().instance = GTplusplus.instance; DarkWorld_Dimension.instance = GTplusplus.instance; - DarkWorld_Biome.preInit(event); + getDarkBiome().preInit(event); DarkWorld_Dimension.preInit(event); //Load/Set Custom Ore Gen HANDLER_GT.sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "WorldGeneration.cfg"))); } + + @EventHandler + public void load(final FMLInitializationEvent e) { + Logger.INFO("Begin resource allocation for " + MODID2 + " V" + VERSION2); + + //Load Dark World and Biome + //GameRegistry.registerFuelHandler(this); + GameRegistry.registerWorldGenerator(new WorldGen_GT_Base(), 50); + getDarkBiome().load(); + DarkWorld_Dimension.load(); + + } void setVars(){ if (DimensionManager.isDimensionRegistered(Dimension_DarkWorld.DIMID)){ Dimension_DarkWorld.DIMID = DimensionManager.getNextFreeDimId(); } + + /* + * Set World Generation Values + */ + + WorldGen_GT_Base.oreveinPercentage = 75; + WorldGen_GT_Base.oreveinAttempts = 64; + WorldGen_GT_Base.oreveinMaxPlacementAttempts = 8; + if (CORE.DEBUG || CORE.DEVENV){ + WorldGen_GT_Base.debugWorldGen = true; + } + DarkWorldContentLoader.run(); } @EventHandler public void serverLoad(FMLServerStartingEvent event) { - DarkWorld_Biome.serverLoad(event); + getDarkBiome().serverLoad(event); DarkWorld_Dimension.serverLoad(event); } - @Override + /*@Override public int getBurnTime(ItemStack fuel) { if (DarkWorld_Biome.addFuel(fuel) != 0) return DarkWorld_Biome.addFuel(fuel); if (DarkWorld_Dimension.addFuel(fuel) != 0) return DarkWorld_Dimension.addFuel(fuel); return 0; - } + }*/ - @Override + /*@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { chunkX = chunkX * 16; chunkZ = chunkZ * 16; - /*if (world.provider.dimensionId == Dimension_DarkWorld.DIMID) { + if (world.provider.dimensionId == Dimension_DarkWorld.DIMID) { DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); - }*/ + } //What does this even do? if (world.provider.dimensionId == -1) { @@ -112,11 +121,19 @@ public class GTplusplus_Secondary implements IFuelHandler, IWorldGenerator{ DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); } - } + }*/ @EventHandler public static void postInit(final FMLPostInitializationEvent e) { Logger.INFO("Finished loading Dark World plugin for GT++."); } + public static synchronized Biome_DarkWorld getDarkBiome() { + return DarkWorld_Biome; + } + + public static synchronized void setDarkBiome(Biome_DarkWorld darkWorld_Biome) { + DarkWorld_Biome = darkWorld_Biome; + } + } diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java index 44657d337a..7ed5dbde3a 100644 --- a/src/Java/gtPlusPlus/api/objects/Logger.java +++ b/src/Java/gtPlusPlus/api/objects/Logger.java @@ -124,7 +124,15 @@ public class Logger { if (CORE.DEVENV || CORE.DEBUG) modLogger.info("[Reflection] "+s); } + + /** + * Special Logger for Darkworld related content + */ + public static void WORLD(final String s) { + if (CORE.DEVENV || CORE.DEBUG) + modLogger.info("[WorldGen] "+s); + } diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java b/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java index 13ecf99bc1..4e2a4c4439 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java @@ -5,7 +5,6 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -216,4 +215,9 @@ public class EntitySickBlaze extends EntityMob { protected boolean isValidLightLevel() { return true; } + + @Override + public int getMaxSpawnedInChunk() { + return 8; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index 5a3e0348fe..cd7878273f 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -4,9 +4,11 @@ import java.lang.reflect.Field; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.core.world.explosions.ExplosionHandler; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.*; @@ -22,16 +24,19 @@ import net.minecraft.village.Village; import net.minecraft.world.World; public class EntityStaballoyConstruct extends EntityIronGolem { - + /* * Determines whether or not the entity is in a fluid at all. */ private volatile boolean inFluid = false; private volatile boolean mReflectFirstUpdate = true; + private volatile boolean isReadyToExplode = false; + private volatile int fuse = 60; private volatile int attackTimer; public EntityStaballoyConstruct(World world) { super(world); + this.experienceValue = 250; this.setSize(1.4F, 2.9F); this.getNavigator().setAvoidsWater(true); this.getNavigator().setBreakDoors(true); @@ -48,6 +53,28 @@ public class EntityStaballoyConstruct extends EntityIronGolem { this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); } + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setBoolean("inFluid", this.inFluid); + p_70014_1_.setBoolean("isReadyToExplode", this.isReadyToExplode); + p_70014_1_.setInteger("fuse", this.fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + this.inFluid = p_70037_1_.getBoolean("inFluid"); + this.isReadyToExplode = p_70037_1_.getBoolean("isReadyToExplode"); + this.fuse = p_70037_1_.getInteger("fuse"); + } + @Override protected void entityInit() { super.entityInit(); @@ -136,24 +163,6 @@ public class EntityStaballoyConstruct extends EntityIronGolem { return clazz.equals(this.getClass()) ? false : true; } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setBoolean("PlayerCreated", this.isPlayerCreated()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - this.setPlayerCreated(p_70037_1_.getBoolean("PlayerCreated")); - } - @Override public boolean attackEntityAsMob(Entity p_70652_1_) { this.attackTimer = 10; @@ -285,8 +294,15 @@ public class EntityStaballoyConstruct extends EntityIronGolem { this.isImmuneToFire = true; } + if (this.getHealth() <= (this.getMaxHealth()*MathUtils.randDouble(0.02, 0.15))){ + float r = MathUtils.randFloat(0, 1); + if (r <= 0.1){ + this.isReadyToExplode = true; + } + } + //Handle Exploding - if (isReadyToExplode){ + if (isReadyToExplode){ if (this.fuse-- <= 0){ this.setDead(); @@ -295,20 +311,63 @@ public class EntityStaballoyConstruct extends EntityIronGolem { this.explode(); } } - else - { - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + else { + + int maxFuse = 60; + int fuseUsed = maxFuse-this.fuse; + float var2 = (float) (fuseUsed * 0.1); + + this.setSize(1.4F+(var2/2), 2.9F+(var2/2)); + + float r = MathUtils.randFloat(0, 1); + int r2 = MathUtils.randInt(5, 15); + for (int o=0;o clazz, final String fieldName) throws NoSuchFieldException { + public static Field getField(final Class clazz, final String fieldName) throws NoSuchFieldException { try { return clazz.getDeclaredField(fieldName); } catch (final NoSuchFieldException e) { diff --git a/src/Java/gtPlusPlus/core/world/darkworld/biome/BiomeGenerator_Custom.java b/src/Java/gtPlusPlus/core/world/darkworld/biome/BiomeGenerator_Custom.java index 0dc84b8aa3..e6425ca4cb 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/biome/BiomeGenerator_Custom.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/biome/BiomeGenerator_Custom.java @@ -5,11 +5,9 @@ import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.Ev import java.util.Random; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.world.darkworld.gen.WorldGenDeadLilly; import gtPlusPlus.core.world.darkworld.gen.WorldGenMinable_Custom; -import net.minecraft.block.BlockFlower; -import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; @@ -19,406 +17,429 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.*; public class BiomeGenerator_Custom extends BiomeDecorator { - /** The world the BiomeDecorator is currently decorating */ - public World currentWorld; - /** The Biome Decorator's random number generator. */ - public Random randomGenerator; - /** The X-coordinate of the chunk currently being decorated */ - public int chunk_X; - /** The Z-coordinate of the chunk currently being decorated */ - public int chunk_Z; - /** The clay generator. */ - public WorldGenerator clayGen = new WorldGenClay(4); - /** The sand generator. */ - public WorldGenerator sandGen; - /** The gravel generator. */ - public WorldGenerator gravelAsSandGen; - /** The dirt generator. */ - public WorldGenerator dirtGen; - public WorldGenerator gravelGen; - public WorldGenerator coalGen; - public WorldGenerator ironGen; - /** Field that holds gold WorldGenMinable */ - public WorldGenerator goldGen; - /** Field that holds redstone WorldGenMinable */ - public WorldGenerator redstoneGen; - /** Field that holds diamond WorldGenMinable */ - public WorldGenerator diamondGen; - /** Field that holds Lapis WorldGenMinable */ - public WorldGenerator lapisGen; - public WorldGenFlowers yellowFlowerGen; - /** Field that holds mushroomBrown WorldGenFlowers */ - public WorldGenerator mushroomBrownGen; - /** Field that holds mushroomRed WorldGenFlowers */ - public WorldGenerator mushroomRedGen; - /** Field that holds big mushroom generator */ - public WorldGenerator bigMushroomGen; - /** Field that holds WorldGenReed */ - public WorldGenerator reedGen; - /** Field that holds WorldGenCactus */ - public WorldGenerator cactusGen; - /** The water lily generation! */ - public WorldGenerator waterlilyGen; - /** Amount of waterlilys per chunk. */ - public int waterlilyPerChunk; - /** The number of trees to attempt to generate per chunk. Up to 10 in forests, none in deserts. */ - public int treesPerChunk; - /** - * The number of yellow flower patches to generate per chunk. The game generates much less than this number, since - * it attempts to generate them at a random altitude. - */ - public int flowersPerChunk; - /** The amount of tall grass to generate per chunk. */ - public int grassPerChunk; - /** The number of dead bushes to generate per chunk. Used in deserts and swamps. */ - public int deadBushPerChunk; - /** - * The number of extra mushroom patches per chunk. It generates 1/4 this number in brown mushroom patches, and 1/8 - * this number in red mushroom patches. These mushrooms go beyond the default base number of mushrooms. - */ - public int mushroomsPerChunk; - /** The number of reeds to generate per chunk. Reeds won't generate if the randomly selected placement is unsuitable. */ - public int reedsPerChunk; - /** The number of cactus plants to generate per chunk. Cacti only work on sand. */ - public int cactiPerChunk; - /** The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater. */ - public int sandPerChunk; - /** - * The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater. There - * appear to be two separate fields for this. - */ - public int sandPerChunk2; - /** The number of clay patches to generate per chunk. Only generates when part of it is underwater. */ - public int clayPerChunk; - /** Amount of big mushrooms per chunk */ - public int bigMushroomsPerChunk; - /** True if decorator should generate surface lava & water */ - public boolean generateLakes; - - public WorldGenerator fluoriteGen; - - public BiomeGenerator_Custom(){ - //Basic Blocks - this.sandGen = new WorldGenMinable_Custom(Blocks.sand, 12); - this.gravelAsSandGen = new WorldGenMinable_Custom(Blocks.gravel, 8); - this.dirtGen = new WorldGenMinable_Custom(Blocks.dirt, 32); - this.gravelGen = new WorldGenMinable_Custom(Blocks.gravel, 12); - - - //Oregen - this.coalGen = new WorldGenMinable_Custom(Blocks.coal_ore, 16); - this.ironGen = new WorldGenMinable_Custom(Blocks.iron_ore, 12); - this.goldGen = new WorldGenMinable_Custom(Blocks.gold_ore, 12); - this.redstoneGen = new WorldGenMinable_Custom(Blocks.redstone_ore, 10); - this.diamondGen = new WorldGenMinable_Custom(Blocks.diamond_ore, 12); - this.lapisGen = new WorldGenMinable_Custom(Blocks.lapis_ore, 8); - this.fluoriteGen = new WorldGenMinable_Custom(ModBlocks.blockOreFluorite, 20); - - //Nature - this.yellowFlowerGen = new WorldGenFlowers(Blocks.yellow_flower); - this.mushroomBrownGen = new WorldGenFlowers(Blocks.brown_mushroom); - this.mushroomRedGen = new WorldGenFlowers(Blocks.red_mushroom); - this.bigMushroomGen = new WorldGenBigMushroom(); - this.reedGen = new WorldGenReed(); - this.cactusGen = new WorldGenCactus(); - this.waterlilyGen = new WorldGenDeadLilly(); - - this.flowersPerChunk = 1; - this.grassPerChunk = 5; - this.sandPerChunk = 3; - this.sandPerChunk2 = 5; - this.clayPerChunk = 7; - - this.generateLakes = true; - } - - @Override - public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_, int p_150512_5_) - { - if (this.currentWorld != null) - { - throw new RuntimeException("Already decorating!!"); - } - else - { - this.currentWorld = p_150512_1_; - this.randomGenerator = p_150512_2_; - this.chunk_X = p_150512_4_; - this.chunk_Z = p_150512_5_; - this.genDecorations(p_150512_3_); - this.currentWorld = null; - this.randomGenerator = null; - } - } - - @Override - protected void genDecorations(BiomeGenBase p_150513_1_) - { - MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); - this.generateOres(); - int i; - int j; - int k; - - boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND); - for (i = 0; doGen && i < this.sandPerChunk2; ++i) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.sandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY); - for (i = 0; doGen && i < this.clayPerChunk; ++i) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.clayGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2); - for (i = 0; doGen && i < this.sandPerChunk; ++i) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); - } - - i = this.treesPerChunk; - - if (this.randomGenerator.nextInt(10) == 0) - { - ++i; - } - - int l; - int i1; + /** The world the BiomeDecorator is currently decorating */ + public World currentWorld; + /** The Biome Decorator's random number generator. */ + public Random randomGenerator; + /** The X-coordinate of the chunk currently being decorated */ + public int chunk_X; + /** The Z-coordinate of the chunk currently being decorated */ + public int chunk_Z; + /** The clay generator. */ + public WorldGenerator clayGen = new WorldGenClay(4); + /** The sand generator. */ + public WorldGenerator sandGen; + /** The gravel generator. */ + public WorldGenerator gravelAsSandGen; + /** The dirt generator. */ + public WorldGenerator dirtGen; + public WorldGenerator gravelGen; + public WorldGenerator coalGen; + public WorldGenerator ironGen; + /** Field that holds gold WorldGenMinable */ + public WorldGenerator goldGen; + /** Field that holds redstone WorldGenMinable */ + public WorldGenerator redstoneGen; + /** Field that holds diamond WorldGenMinable */ + public WorldGenerator diamondGen; + /** Field that holds Lapis WorldGenMinable */ + public WorldGenerator lapisGen; + public WorldGenFlowers yellowFlowerGen; + /** Field that holds mushroomBrown WorldGenFlowers */ + public WorldGenerator mushroomBrownGen; + /** Field that holds mushroomRed WorldGenFlowers */ + public WorldGenerator mushroomRedGen; + /** Field that holds big mushroom generator */ + public WorldGenerator bigMushroomGen; + /** Field that holds WorldGenReed */ + public WorldGenerator reedGen; + /** Field that holds WorldGenCactus */ + public WorldGenerator cactusGen; + /** The water lily generation! */ + public WorldGenerator waterlilyGen; + /** Amount of waterlilys per chunk. */ + public int waterlilyPerChunk; + /** The number of trees to attempt to generate per chunk. Up to 10 in forests, none in deserts. */ + public int treesPerChunk; + /** + * The number of yellow flower patches to generate per chunk. The game generates much less than this number, since + * it attempts to generate them at a random altitude. + */ + public int flowersPerChunk; + /** The amount of tall grass to generate per chunk. */ + public int grassPerChunk; + /** The number of dead bushes to generate per chunk. Used in deserts and swamps. */ + public int deadBushPerChunk; + /** + * The number of extra mushroom patches per chunk. It generates 1/4 this number in brown mushroom patches, and 1/8 + * this number in red mushroom patches. These mushrooms go beyond the default base number of mushrooms. + */ + public int mushroomsPerChunk; + /** The number of reeds to generate per chunk. Reeds won't generate if the randomly selected placement is unsuitable. */ + public int reedsPerChunk; + /** The number of cactus plants to generate per chunk. Cacti only work on sand. */ + public int cactiPerChunk; + /** The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater. */ + public int sandPerChunk; + /** + * The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater. There + * appear to be two separate fields for this. + */ + public int sandPerChunk2; + /** The number of clay patches to generate per chunk. Only generates when part of it is underwater. */ + public int clayPerChunk; + /** Amount of big mushrooms per chunk */ + public int bigMushroomsPerChunk; + /** True if decorator should generate surface lava & water */ + public boolean generateLakes; + + public WorldGenerator fluoriteGen; + + public BiomeGenerator_Custom(){ + //Basic Blocks + this.sandGen = new WorldGenMinable(Blocks.sand, 12); + this.gravelAsSandGen = new WorldGenMinable(Blocks.gravel, 8); + this.dirtGen = new WorldGenMinable(Blocks.dirt, 32); + this.gravelGen = new WorldGenMinable(Blocks.gravel, 12); + + + //Oregen + this.coalGen = new WorldGenMinable_Custom(Blocks.coal_ore, 32); + this.ironGen = new WorldGenMinable_Custom(Blocks.iron_ore, 16); + this.goldGen = new WorldGenMinable_Custom(Blocks.gold_ore, 16); + this.redstoneGen = new WorldGenMinable_Custom(Blocks.redstone_ore, 16); + this.diamondGen = new WorldGenMinable_Custom(Blocks.diamond_ore, 24); + this.lapisGen = new WorldGenMinable_Custom(Blocks.lapis_ore, 24); + this.fluoriteGen = new WorldGenMinable_Custom(ModBlocks.blockOreFluorite, 24); + +/* //Nature + this.yellowFlowerGen = new WorldGenFlowers(Blocks.yellow_flower); + this.mushroomBrownGen = new WorldGenFlowers(Blocks.brown_mushroom); + this.mushroomRedGen = new WorldGenFlowers(Blocks.red_mushroom); + this.bigMushroomGen = new WorldGenBigMushroom(); + this.reedGen = new WorldGenReed(); + this.cactusGen = new WorldGenCactus(); + this.waterlilyGen = new WorldGenDeadLilly(); +*/ + + this.grassPerChunk = 1; + this.sandPerChunk = 6; + this.sandPerChunk2 = 8; + this.clayPerChunk = 4; + this.treesPerChunk = 12; + + this.generateLakes = true; + } - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE); - for (j = 0; doGen && j < i; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = this.currentWorld.getHeightValue(k, l); - WorldGenAbstractTree worldgenabstracttree = p_150513_1_.func_150567_a(this.randomGenerator); - worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); - - if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) - { - worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM); - for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l); - } + @Override + public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_, int p_150512_5_) + { + Logger.WORLD("Trying to decorate world, using BBS randomization."); + if (this.currentWorld != null) + { + //throw new RuntimeException("Already decorating!!"); + } + else + { + this.currentWorld = p_150512_1_; + //this.randomGenerator = CSPRNG.generate(); + this.randomGenerator = p_150512_2_; + this.chunk_X = p_150512_4_; + this.chunk_Z = p_150512_5_; + this.genDecorations(p_150512_3_); + this.currentWorld = null; + this.randomGenerator = null; + } + } - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS); - for (j = 0; doGen && j < this.flowersPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) + 32); - String s = p_150513_1_.func_150572_a(this.randomGenerator, k, i1, l); - BlockFlower blockflower = BlockFlower.func_149857_e(s); - - if (blockflower.getMaterial() != Material.air) - { - this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s)); - this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS); + @Override + protected void genDecorations(BiomeGenBase p_150513_1_) + { + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + this.generateOres(); + Logger.WORLD("Just Tried to generate ores."); + int i; + int j; + int k; + + boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND); + for (i = 0; doGen && i < this.sandPerChunk2; ++i) + { + Logger.WORLD("Sand generation."); + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.sandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY); + for (i = 0; doGen && i < this.clayPerChunk; ++i) + { + Logger.WORLD("Clay generation."); + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.clayGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2); + for (i = 0; doGen && i < this.sandPerChunk; ++i) + { + Logger.WORLD("Sand generation 2."); + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + i = this.treesPerChunk; + + if (this.randomGenerator.nextInt(10) == 0) + { + ++i; + } + + int l; + int i1; + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE); + for (j = 0; doGen && j < i; ++j) + { + Logger.WORLD("Tree generation."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + WorldGenAbstractTree worldgenabstracttree = p_150513_1_.func_150567_a(this.randomGenerator); + worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); + + if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) + { + worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM); + for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l); + }*/ + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS); + for (j = 0; doGen && j < this.flowersPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) + 32); + String s = p_150513_1_.func_150572_a(this.randomGenerator, k, i1, l); + BlockFlower blockflower = BlockFlower.func_149857_e(s); + + if (blockflower.getMaterial() != Material.air) + { + this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s)); + this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + }*/ + + /* doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS); for (j = 0; doGen && j < this.grassPerChunk; ++j) { + Logger.WORLD("Grass generation."); k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); WorldGenerator worldgenerator = p_150513_1_.getRandomWorldGenForGrass(this.randomGenerator); worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH); - for (j = 0; doGen && j < this.deadBushPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - (new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD); - for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - - for (i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0 && this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) - { - ; - } - - this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM); - for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) - { - if (this.randomGenerator.nextInt(4) == 0) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = this.currentWorld.getHeightValue(k, l); - this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - if (this.randomGenerator.nextInt(8) == 0) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - } - - if (doGen && this.randomGenerator.nextInt(4) == 0) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - if (doGen && this.randomGenerator.nextInt(8) == 0) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED); - for (j = 0; doGen && j < this.reedsPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } - - for (j = 0; doGen && j < 10; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } + }*/ + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH); + for (j = 0; doGen && j < this.deadBushPerChunk; ++j) + { + Logger.WORLD("Dead Bush generation."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + (new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD); + for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) + { + Logger.WORLD("WaterLilly generation."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + + for (i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0 && this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) + { + ; + } + + this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + }*/ + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM); + for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) + { + if (this.randomGenerator.nextInt(4) == 0) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + if (this.randomGenerator.nextInt(8) == 0) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + }*/ + + /*if (doGen && this.randomGenerator.nextInt(4) == 0) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + if (doGen && this.randomGenerator.nextInt(8) == 0) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + }*/ + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED); + for (j = 0; doGen && j < this.reedsPerChunk; ++j) + { + Logger.WORLD("Reed generation."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + for (j = 0; doGen && j < 10; ++j) + { + Logger.WORLD("Reed generation 2."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + }*/ + + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN); + if (doGen && this.randomGenerator.nextInt(32) == 0) + { + Logger.WORLD("Pumpkin generation."); + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); + (new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k); + } +*/ + /*doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS); + for (j = 0; doGen && j < this.cactiPerChunk; ++j) + { + Logger.WORLD("Cactus generation."); + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + }*/ + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE); + if (doGen && this.generateLakes) + { + Logger.WORLD("Lake generation."); + for (j = 0; j < 50; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + + for (j = 0; j < 20; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN); - if (doGen && this.randomGenerator.nextInt(32) == 0) - { - j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - l = nextInt(this.currentWorld.getHeightValue(j, k) * 2); - (new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k); - } - - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS); - for (j = 0; doGen && j < this.cactiPerChunk; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - i1 = nextInt(this.currentWorld.getHeightValue(k, l) * 2); - this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); - } + /** + * Standard ore generation helper. Generates most ores. + */ + @Override + protected void genStandardOre1(int passes, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_) + { + for (int l = 0; l < passes; ++l) + { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(p_76795_4_ - p_76795_3_) + p_76795_3_; + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + p_76795_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } - doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE); - if (doGen && this.generateLakes) - { - for (j = 0; j < 50; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8); - i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - (new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1); - } - - for (j = 0; j < 20; ++j) - { - k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; - l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8); - i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; - (new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1); - } - } - - MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); - } - - /** - * Standard ore generation helper. Generates most ores. - */ - @Override - protected void genStandardOre1(int p_76795_1_, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_) - { - for (int l = 0; l < p_76795_1_; ++l) - { - int i1 = this.chunk_X + this.randomGenerator.nextInt(16); - int j1 = this.randomGenerator.nextInt(p_76795_4_ - p_76795_3_) + p_76795_3_; - int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); - p_76795_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); - } - } - - /** - * Standard ore generation helper. Generates Lapis Lazuli. - */ - @Override + /** + * Standard ore generation helper. Generates Lapis Lazuli. + */ + @Override protected void genStandardOre2(int p_76793_1_, WorldGenerator p_76793_2_, int p_76793_3_, int p_76793_4_) - { - for (int l = 0; l < p_76793_1_; ++l) - { - int i1 = this.chunk_X + this.randomGenerator.nextInt(16); - int j1 = this.randomGenerator.nextInt(p_76793_4_) + this.randomGenerator.nextInt(p_76793_4_) + (p_76793_3_ - p_76793_4_); - int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); - p_76793_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); - } - } - - /** - * Generates ores in the current chunk - */ - @Override + { + for (int l = 0; l < p_76793_1_; ++l) + { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(p_76793_4_) + this.randomGenerator.nextInt(p_76793_4_) + (p_76793_3_ - p_76793_4_); + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + p_76793_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + /** + * Generates ores in the current chunk + */ + @Override protected void generateOres() - { - MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); - if (TerrainGen.generateOre(currentWorld, randomGenerator, dirtGen, chunk_X, chunk_Z, DIRT)) - this.genStandardOre1(20, this.dirtGen, 0, 256); - if (TerrainGen.generateOre(currentWorld, randomGenerator, gravelGen, chunk_X, chunk_Z, GRAVEL)) - this.genStandardOre1(10, this.gravelGen, 0, 256); - if (TerrainGen.generateOre(currentWorld, randomGenerator, coalGen, chunk_X, chunk_Z, COAL)) - this.genStandardOre1(20, this.coalGen, 0, 128); - if (TerrainGen.generateOre(currentWorld, randomGenerator, ironGen, chunk_X, chunk_Z, IRON)) - this.genStandardOre1(20, this.ironGen, 0, 64); - if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) - this.genStandardOre1(2, this.goldGen, 0, 32); - if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) - this.genStandardOre1(8, this.redstoneGen, 0, 16); - if (TerrainGen.generateOre(currentWorld, randomGenerator, diamondGen, chunk_X, chunk_Z, DIAMOND)) - this.genStandardOre1(1, this.diamondGen, 0, 16); - if (TerrainGen.generateOre(currentWorld, randomGenerator, lapisGen, chunk_X, chunk_Z, LAPIS)) - this.genStandardOre2(1, this.lapisGen, 16, 16); - MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); - } - - private int nextInt(int i) { - if (i <= 1) - return 0; - return this.randomGenerator.nextInt(i); + { + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + if (TerrainGen.generateOre(currentWorld, randomGenerator, dirtGen, chunk_X, chunk_Z, DIRT)) + this.genStandardOre1(20, this.dirtGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, gravelGen, chunk_X, chunk_Z, GRAVEL)) + this.genStandardOre1(10, this.gravelGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, coalGen, chunk_X, chunk_Z, COAL)) + this.genStandardOre1(20, this.coalGen, 0, 128); + if (TerrainGen.generateOre(currentWorld, randomGenerator, ironGen, chunk_X, chunk_Z, IRON)) + this.genStandardOre1(20, this.ironGen, 0, 64); + if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) + this.genStandardOre1(2, this.goldGen, 0, 32); + if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) + this.genStandardOre1(8, this.redstoneGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, diamondGen, chunk_X, chunk_Z, DIAMOND)) + this.genStandardOre1(1, this.diamondGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, lapisGen, chunk_X, chunk_Z, LAPIS)) + this.genStandardOre2(1, this.lapisGen, 16, 16); + + //Try generate Fluorite + /*if (TerrainGen.generateOre(currentWorld, randomGenerator, fluoriteGen, chunk_X, chunk_Z, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.CUSTOM)) + this.genStandardOre1(16, this.fluoriteGen, 0, 128); + if (TerrainGen.generateOre(currentWorld, randomGenerator, fluoriteGen, chunk_X, chunk_Z, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.CUSTOM)) + this.genStandardOre2(16, this.fluoriteGen, 16, 48);*/ + + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } + + private int nextInt(int i) { + if (i <= 1) + return 0; + return this.randomGenerator.nextInt(i); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java b/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java index 2970a2c3de..92f3f43d95 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/biome/Biome_DarkWorld.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; +import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.passive.EntitySquid; import net.minecraft.item.ItemStack; @@ -60,6 +61,7 @@ public class Biome_DarkWorld { super(CORE.DARKBIOME_ID); this.setBiomeID(); this.theBiomeDecorator = new BiomeGenerator_Custom(); + this.theBiomeDecorator.treesPerChunk = 10; Logger.INFO("Dark World Temperature Category: "+getTempCategory()); this.setBiomeName("Dark World"); this.topBlock = Dimension_DarkWorld.blockTopLayer; @@ -78,11 +80,12 @@ public class Biome_DarkWorld { this.spawnableCaveCreatureList.clear(); //Enemies - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySickBlaze.class, 100, 4, 4)); - this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityStaballoyConstruct.class, 80, 1, 2)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySickBlaze.class, 100, 2, 6)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 75, 4, 16)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityStaballoyConstruct.class, 20, 1, 2)); //Animals - this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 1, 1, 6)); this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); } diff --git a/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java b/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java index 1af92c0d3f..0eab691720 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/block/DarkWorldContentLoader.java @@ -47,7 +47,7 @@ public class DarkWorldContentLoader { public synchronized static boolean initBlocks(){ //Create Block Instances - blockFluidLakes = new BlockBaseFluid("Sludge", SLUDGE, blockDarkWorldSludgeFluid.SLUDGE).setLightLevel(2f).setLightOpacity(1); + blockFluidLakes = new BlockBaseFluid("Sludge", SLUDGE, blockDarkWorldSludgeFluid.SLUDGE).setLightLevel(2f).setLightOpacity(1).setBlockName("blockDarkWorldSludgeFluid"); portalBlock = new blockDarkWorldPortal(); blockTopLayer = new blockDarkWorldGround(); blockSecondLayer = new blockDarkWorldPollutedDirt(); diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/WorldGenMinable_Custom.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/WorldGenMinable_Custom.java index f78ace8a16..58937c8a40 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/WorldGenMinable_Custom.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/WorldGenMinable_Custom.java @@ -1,7 +1,10 @@ package gtPlusPlus.core.world.darkworld.gen; +import static gtPlusPlus.core.lib.CORE.PI; + import java.util.Random; +import gtPlusPlus.api.objects.Logger; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; @@ -10,84 +13,77 @@ import net.minecraft.world.gen.feature.WorldGenMinable; public class WorldGenMinable_Custom extends WorldGenMinable { - /** The block to generate. */ - private Block oreToGenerate; - /** The number of blocks to generate. */ - private int numberOfBlocks; - /** The block to replace. */ - private Block blockToReplace; - /** The meta of the block. */ - private int mineableBlockMeta; - - public WorldGenMinable_Custom(Block block, int count){ - super(block, count, Blocks.stone); - } - - public WorldGenMinable_Custom(Block block, int count, Block target){ - super(block, count, target); - this.oreToGenerate = block; - this.numberOfBlocks = count; - this.blockToReplace = target; - } - - public WorldGenMinable_Custom(Block block, int meta, int number, Block target){ - this(block, number, target); - this.mineableBlockMeta = meta; - } + /** The block to generate. */ + private Block oreToGenerate; + /** The number of blocks to generate. */ + private int numberOfBlocks; + /** The block to replace. */ + private Block blockToReplace; + /** The meta of the block. */ + private int mineableBlockMeta; - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - float f = rand.nextFloat() * (float)Math.PI; - double d0 = x + 16 + MathHelper.sin(f) * this.numberOfBlocks / 4.0F; - double d1 = x + 16 - MathHelper.sin(f) * this.numberOfBlocks / 4.0F; - double d2 = z + 16 + MathHelper.cos(f) * this.numberOfBlocks / 4.0F; - double d3 = z + 16 - MathHelper.cos(f) * this.numberOfBlocks / 4.0F; - double d4 = y + rand.nextInt(5) - 2; - double d5 = y + rand.nextInt(5) - 2; + public WorldGenMinable_Custom(final Block block, final int count){ + super(block, count, Blocks.stone); + } - for (int l = 0; l <= this.numberOfBlocks; ++l) - { - double d6 = d0 + (d1 - d0) * l / this.numberOfBlocks; - double d7 = d4 + (d5 - d4) * l / this.numberOfBlocks; - double d8 = d2 + (d3 - d2) * l / this.numberOfBlocks; - double d9 = rand.nextDouble() * this.numberOfBlocks / 8.0D; - double d10 = (MathHelper.sin(l * (float)Math.PI / this.numberOfBlocks) + 1.0F) * d9 + 1.0D; - double d11 = (MathHelper.sin(l * (float)Math.PI / this.numberOfBlocks) + 1.0F) * d9 + 1.0D; - int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); - int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); - int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); - int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); - int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); - int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); + public WorldGenMinable_Custom(final Block block, final int count, final Block target){ + super(block, count, target); + this.oreToGenerate = block; + this.numberOfBlocks = count; + this.blockToReplace = target; + } - for (int k2 = i1; k2 <= l1; ++k2) - { - double d12 = (k2 + 0.5D - d6) / (d10 / 2.0D); + public WorldGenMinable_Custom(final Block block, final int meta, final int number, final Block target){ + this(block, number, target); + this.mineableBlockMeta = meta; + } - if (d12 * d12 < 1.0D) - { - for (int l2 = j1; l2 <= i2; ++l2) - { - double d13 = (l2 + 0.5D - d7) / (d11 / 2.0D); + @Override + public boolean generate(final World world, final Random rand, final int x, final int y, final int z) + { + final float f = rand.nextFloat() * PI; + final double d0 = x + 16 + ((MathHelper.sin(f) * this.numberOfBlocks) / 4.0F); + final double d1 = (x + 16) - ((MathHelper.sin(f) * this.numberOfBlocks) / 4.0F); + final double d2 = z + 16 + ((MathHelper.cos(f) * this.numberOfBlocks) / 4.0F); + final double d3 = (z + 16) - ((MathHelper.cos(f) * this.numberOfBlocks) / 4.0F); + final double d4 = (y + rand.nextInt(8)) - 1; + final double d5 = (y + rand.nextInt(8)) - 1; - if (d12 * d12 + d13 * d13 < 1.0D) - { - for (int i3 = k1; i3 <= j2; ++i3) - { - double d14 = (i3 + 0.5D - d8) / (d10 / 2.0D); + for (int l = 0; l <= this.numberOfBlocks; ++l) + { + final double d6 = d0 + (((d1 - d0) * l) / this.numberOfBlocks); + final double d7 = d4 + (((d5 - d4) * l) / this.numberOfBlocks); + final double d8 = d2 + (((d3 - d2) * l) / this.numberOfBlocks); + final double d9 = (rand.nextDouble() * this.numberOfBlocks) / 8.0D; + final double d10 = ((MathHelper.sin((l * PI) / this.numberOfBlocks) + 1.0F) * d9) + 1.0D; + final double d11 = ((MathHelper.sin((l * PI) / this.numberOfBlocks) + 1.0F) * d9) + 1.0D; + final int i1 = MathHelper.floor_double(d6 - (d10 / 2.0D)); + final int j1 = MathHelper.floor_double(d7 - (d11 / 2.0D)); + final int k1 = MathHelper.floor_double(d8 - (d10 / 2.0D)); + final int l1 = MathHelper.floor_double(d6 + (d10 / 2.0D)); + final int i2 = MathHelper.floor_double(d7 + (d11 / 2.0D)); + final int j2 = MathHelper.floor_double(d8 + (d10 / 2.0D)); - if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, blockToReplace)) - { - world.setBlock(k2, l2, i3, this.oreToGenerate, mineableBlockMeta, 2); - } - } - } - } - } - } - } + for (int k2 = i1; k2 <= l1; ++k2){ + final double d12 = ((k2 + 0.5D) - d6) / (d10 / 2.0D); + if ((d12 * d12) < 1.0D){ + for (int l2 = j1; l2 <= i2; ++l2){ + final double d13 = ((l2 + 0.5D) - d7) / (d11 / 2.0D); + if (((d12 * d12) + (d13 * d13)) < 1.0D){ + for (int i3 = k1; i3 <= j2; ++i3){ + final double d14 = ((i3 + 0.5D) - d8) / (d10 / 2.0D); + if ((((d12 * d12) + (d13 * d13) + (d14 * d14)) < 1.0D) && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, this.blockToReplace)) + { + world.setBlock(k2, l2, i3, this.oreToGenerate, this.mineableBlockMeta, 3); + Logger.INFO("Generated a "+this.oreToGenerate.getLocalizedName()+" at x: "+k2+" | y: "+l2+" | z: "+i3); + } + } + } + } + } + } + } - return true; - } + return true; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java new file mode 100644 index 0000000000..3685c5d96a --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java @@ -0,0 +1,412 @@ +package gtPlusPlus.core.world.darkworld.gen.gt; + +import java.util.*; + +import cpw.mods.fml.common.IWorldGenerator; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.api.world.GT_Worldgen; +import gtPlusPlus.api.objects.CSPRNG; +import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; +import gtPlusPlus.xmod.gregtech.api.objects.XSTR; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderEnd; +import net.minecraft.world.gen.ChunkProviderHell; +import net.minecraft.world.gen.feature.WorldGenMinable; + +public class WorldGen_GT_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 mList = new ArrayList(); + public static HashSet ProcChunks = new HashSet(); + // 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_Ore_Layer noOresInVein = new WorldGen_GT_Ore_Layer( "NoOresInVein", false, 0, 255, 0, 255, 16, false, false, false, false, false, false, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium); + public static Hashtable validOreveins = new Hashtable(1024); + public boolean mIsGenerating = false; + public static final Object listLock = new Object(); + //private static boolean gcAsteroids = true; + + + public WorldGen_GT_Base(){ + GameRegistry.registerWorldGenerator(this, 7735); + 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_DarkWorld.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_DarkWorld.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 { + generateDarkWorld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); + break; + } + } + } + + private void generateEnd(World world, Random random, int x, int z) + { + //... + } + + private void generateSurface(World world, Random random, int x, int z) + { + //... + } + + private void generateNether(World world, Random random, int x, int z) + { + //... + } + + private void generateDarkWorld(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider){ + synchronized (listLock) + { + WorldGen_GT_Base.mList.add(new WorldGenContainer(CSPRNG.generate(Math.abs(aRandom.nextInt()) +1), aX, aZ, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName)); + if (debugWorldGen) GT_Log.out.println( + "ADD WorldSeed:"+aWorld.getSeed() + + " DimId" + aWorld.provider.dimensionId + + " chunk x:" + aX + + " z:" + aZ + + " SIZE: " + WorldGen_GT_Base.mList.size() + ); + } + + if (!this.mIsGenerating) { + this.mIsGenerating = true; + int mList_sS=WorldGen_GT_Base.mList.size(); + mList_sS = Math.min(mList_sS, 5); // Run a maximum of 5 chunks at a time through worldgen. Extra chunks get done later. + for (int i = 0; i < mList_sS; i++) { + WorldGenContainer toRun = (WorldGenContainer) WorldGen_GT_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_Base.mList.size() + + " i: " + i + ); + synchronized (listLock) + { + WorldGen_GT_Base.mList.remove(0); + } + toRun.run(); + } + this.mIsGenerating = 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 seedList = new ArrayList(); + + // 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. + CSPRNG oreveinRNG = CSPRNG.generate(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() + ); + + // Search for a valid orevein for this dimension + if( !validOreveins.containsKey(oreveinSeed) ) { + if ( (oreveinPercentageRoll 0) && (WorldGen_GT_Ore_Layer.sList.size() > 0)) { + int placementAttempts = 0; + boolean oreveinFound = false; + int i; + for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts sList = new ArrayList(); + 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 final short mPrimaryMeta; + public final short mSecondaryMeta; + public final short mBetweenMeta; + public final short mSporadicMeta; + //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 final boolean mMoon; + //public final boolean mMars; + //public final boolean mAsteroid; + public final String aTextWorldgen = "worldgen."; + + public WorldGen_GT_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, Materials aPrimary, Materials aSecondary, Materials aBetween, Materials aSporadic) { + super(aName, sList, aDefault); + this.mOverworld = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mNether = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); + this.mEnd = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); + //this.mMoon = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); + //this.mMars = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); + //this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); + this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + short mMaxY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY)); + 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) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimaryMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + this.mRestrictBiome = GregTech_API.sWorldgenFile.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) { + if( mWorldGenName.equals("NoOresInVein") ) { + if (debugWorldGen) GT_Log.out.println( + " NoOresInVein" + ); + // This is a special empty orevein + return ORE_PLACED; + } + if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { + /* // Debug code, but spams log + if (debugWorldGen) { + GT_Log.out.println( + "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 + /* + if (debugWorldGen) { + GT_Log.out.println( + "No X overlap" + ); + } + */ + return NO_OVERLAP; + } + // 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 + /* + if (debugWorldGen) { + GT_Log.out.println( + "No Z overlap" + ); + } + */ + return NO_OVERLAP; + } + // 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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 + } + 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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + placeCount[2]++; + } + } + else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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; + } +} \ No newline at end of file -- cgit