aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/entity/monster
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-12-21 19:16:36 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-12-21 19:16:36 +1000
commitcf044120cad3ff1aa2fd40b4ae8989f7e898546e (patch)
treeef065acc1fe184adc512676f44f34a7f3b8626a2 /src/Java/gtPlusPlus/core/entity/monster
parentecc60485f31011bf9cc6a02edb985fb683793bb7 (diff)
downloadGT5-Unofficial-cf044120cad3ff1aa2fd40b4ae8989f7e898546e.tar.gz
GT5-Unofficial-cf044120cad3ff1aa2fd40b4ae8989f7e898546e.tar.bz2
GT5-Unofficial-cf044120cad3ff1aa2fd40b4ae8989f7e898546e.zip
+ Added a better Ai and combat mechanics to the Staballoy Constructs.
+ Tried to implement new World generation for my dimension. % Small tweak to gitignore.
Diffstat (limited to 'src/Java/gtPlusPlus/core/entity/monster')
-rw-r--r--src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java6
-rw-r--r--src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java163
2 files changed, 134 insertions, 35 deletions
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<r2;o++){
+ if (r <= 0.3){
+ this.worldObj.spawnParticle("smoke", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.6){
+ this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ if (r <= 0.3){
+ this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.7){
+ this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ if (r <= 0.2){
+ this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.5){
+ this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.7){
+ this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 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);
+ try {
+ if (ReflectionUtils.getField(Class.forName("net.minecraft.entity.Entity"), "firstUpdate") != null && mReflectFirstUpdate == true){
+ Field x = ReflectionUtils.getField(Class.forName("net.minecraft.entity.Entity"), "firstUpdate");
+ try {
+ this.mReflectFirstUpdate = (boolean) x.get(this);
+ Logger.REFLECTION("Successfully got 'firstUpdate' variable state via reflection.");
+ }
+ catch (IllegalArgumentException | IllegalAccessException e) {}
}
- catch (IllegalArgumentException | IllegalAccessException e) {}
}
+ catch (NoSuchFieldException | ClassNotFoundException e) {}
super.onEntityUpdate();
}
@@ -419,18 +478,54 @@ public class EntityStaballoyConstruct extends EntityIronGolem {
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);
- }
+ /* float f = 12.0F;
+ this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);*/
+
+ final float f = 16F;
+ ExplosionHandler explode = new ExplosionHandler();
+ explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, true, true);
+
+ float r = MathUtils.randFloat(0, 1);
+ int r2 = MathUtils.randInt(20, 40);
+ for (int o=0;o<r2;o++){
+ if (r <= 0.3){
+ this.worldObj.spawnParticle("smoke", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(0, 3), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.6){
+ this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ if (r <= 0.3){
+ this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.7){
+ this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ if (r <= 0.2){
+ this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.5){
+ this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ else if (r <= 0.7){
+ this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(-4, 4), this.posY+MathUtils.randDouble(-4, 4), this.posZ+MathUtils.randDouble(-4, 4), 0.0D, 0.0D, 0.0D);
+
+ }
+ }
+
+ }
@Override
public boolean canAttackWithItem() {