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. --- .../core/entity/monster/EntitySickBlaze.java | 6 +- .../entity/monster/EntityStaballoyConstruct.java | 163 ++++++++++++++++----- 2 files changed, 134 insertions(+), 35 deletions(-) (limited to 'src/Java/gtPlusPlus/core/entity') 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