Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assets.betterdefense.entity;
- import org.lwjgl.Sys;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.EnumCreatureAttribute;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAIAttackOnCollide;
- import net.minecraft.entity.ai.EntityAIBreakDoor;
- import net.minecraft.entity.ai.EntityAIHurtByTarget;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
- import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
- import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
- import net.minecraft.entity.ai.EntityAISwimming;
- import net.minecraft.entity.ai.EntityAIWander;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.monster.EntityMob;
- import net.minecraft.entity.passive.EntityVillager;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.world.World;
- import net.minecraftforge.event.ForgeSubscribe;
- import net.minecraftforge.event.entity.living.LivingHurtEvent;
- import assets.betterdefense.common.BetterDefense;
- import assets.betterdefense.common.EntityAIBreakWood;
- public class EntityRiot_Zombie extends EntityMob
- {
- boolean spawnZombie = true;
- //Time To Wait after spawning to spawn another
- int spawnCooldown = 1;
- //Counter. When 0 its okay to spawn another
- int spawnTimer = 5;
- int stage;
- private float heightOffset = -0.5F;
- /** ticks until heightOffset is randomized */
- private int heightOffsetUpdateTime;
- private int field_70846_g;
- private static final ResourceLocation textureLocation = new ResourceLocation("betterdefense:Riot_Zombie.png");
- public EntityRiot_Zombie(World par1World)
- {
- super(par1World);
- this.isImmuneToFire = true;
- this.canBreatheUnderwater();
- this.stepHeight = 1.2F;
- this.getNavigator().setBreakDoors(true);
- this.tasks.addTask(0, new EntityAISwimming(this));
- this.tasks.addTask(1, new EntityAIBreakDoor(this));
- this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1D, false));
- this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, 1D, true));
- this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, 1D, false));
- this.tasks.addTask(6, new EntityAIWander(this, 1D));
- this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
- this.tasks.addTask(7, new EntityAILookIdle(this));
- this.tasks.addTask(8, new EntityAIBreakWood(this));
- this.tasks.addTask(9, new EntityAIMoveTowardsRestriction(this, 1.0D));
- this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
- }
- protected void func_110147_ax()
- {
- super.func_110147_ax();
- // Max Health - default 20.0D - min 0.0D - max Double.MAX_VALUE
- this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(20.0D);
- // Follow Range - default 32.0D - min 0.0D - max 2048.0D
- this.func_110148_a(SharedMonsterAttributes.field_111265_b).func_111128_a(45.0D);
- // Knockback Resistance - default 0.0D - min 0.0D - max 1.0D
- this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111128_a(0.7D);
- // Movement Speed - default 0.699D - min 0.0D - max Double.MAX_VALUE
- this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.11000000417232513D);
- // Attack Damage - default 2.0D - min 0.0D - max Doubt.MAX_VALUE
- this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111128_a(2.0D);
- }
- protected ResourceLocation func_110775_a(Entity entity) {
- return textureLocation;
- }
- public boolean canBreatheUnderwater()
- {
- return true;
- }
- public int getTotalArmorValue()
- {
- int i = super.getTotalArmorValue() + 2;
- if (i > 20)
- {
- i = 20;
- }
- return i;
- }
- public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
- {
- if (par1DamageSource.isFireDamage())
- {
- par2 = 0;
- }
- if (super.attackEntityFrom(par1DamageSource, par2))
- {
- if (par1DamageSource.getEntity() != null)
- {
- Entity par1Entity = par1DamageSource.getEntity();
- int j = 0;
- if (par1Entity instanceof EntityLiving)
- {
- j += EnchantmentHelper.getKnockbackModifier((EntityLiving) par1Entity, this);
- if (j > 0)
- {
- this.motionX /= 0.6D;
- this.motionZ /= 0.6D;
- this.addVelocity((double) (MathHelper.sin(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), -0.1D,
- (double) (-MathHelper.cos(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F));
- }
- }
- }
- if (this.getHealth() < this.getMaxHealth() * 0.75 && stage == 0)
- {
- stage++;
- System.out.println("Stage advance!");
- } else if (stage == 1 && this.getHealth() < this.getMaxHealth() * 0.5)
- {
- stage++;
- spawnHelp();
- this.setDead();
- System.out.println("Spawned help, set dead!");
- } else if (stage == 2 && this.getHealth() < this.getMaxHealth() * 0.25)
- {
- stage++;
- }
- return true;
- }
- return false;
- }
- private void spawnHelp()
- {
- int numSpawned = 0;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- if (trySpawnHelp((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1))
- {
- numSpawned++;
- }
- if (numSpawned >= 1)
- return;
- }
- public boolean trySpawnHelp(int x, int y, int z)
- {
- EntityZombie HELP = new EntityZombie(worldObj);
- zombie1.setPosition(x, y, z);
- {
- if (!worldObj.isRemote)
- worldObj.spawnEntityInWorld(HELP);
- HELP.spawnExplosionParticle();
- return true;
- }
- }
- protected boolean isAIEnabled()
- {
- return true;
- }
- protected String getDecay()
- {
- return "townaura";
- }
- public void onLivingUpdate()
- {
- for (int i = 0; i < 2; ++i)
- {
- this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- //this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- //this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- //this.worldObj.spawnParticle(getDecay(), this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
- }
- super.onLivingUpdate();
- }
- public boolean attackEntityAsMob(Entity par1Entity)
- {
- boolean flag = super.attackEntityAsMob(par1Entity);
- if (flag && this.getHeldItem() == null && this.isBurning() && this.rand.nextFloat() < (float)this.worldObj.difficultySetting * 0.3F)
- {
- par1Entity.setFire(2 * this.worldObj.difficultySetting);
- }
- return flag;
- }
- /**
- * Returns the sound this mob makes while it's alive.
- */
- protected String getLivingSound()
- {
- return "mob.zombie.say";
- }
- /**
- * Returns the sound this mob makes when it is hurt.
- */
- protected String getHurtSound()
- {
- return "mob.zombie.hurt";
- }
- /**
- * Returns the sound this mob makes on death.
- */
- protected String getDeathSound()
- {
- return "mob.zombie.death";
- }
- /**
- * Plays step sound at given x, y, z for the entity
- */
- protected void playStepSound(int par1, int par2, int par3, int par4)
- {
- this.playSound("mob.zombie.step", 0.15F, 1.0F);
- }
- /**
- * Returns the item ID for the item the mob drops on death.
- */
- protected int getDropItemId()
- {
- return Item.rottenFlesh.itemID;
- }
- /**
- * Get this Entity's EnumCreatureAttribute
- */
- public EnumCreatureAttribute getCreatureAttribute()
- {
- return EnumCreatureAttribute.UNDEAD;
- }
- protected void dropRareDrop(int par1)
- {
- switch (this.rand.nextInt(3))
- {
- case 0:
- this.dropItem(Item.diamond.itemID, 1);
- break;
- case 1:
- this.dropItem(BetterDefense.HISword.itemID, 1);
- break;
- case 2:
- this.dropItem(Item.ingotIron.itemID, 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement