/******************************************************************************* * AbyssalCraft * Copyright (c) 2012 - 2017 Shinoow. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt * * Contributors: * Shinoow - implementation ******************************************************************************/ package com.shinoow.abyssalcraft.common.entity.demon; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackMelee; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; 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.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import com.shinoow.abyssalcraft.common.entity.EntityLesserShoggoth; import com.shinoow.abyssalcraft.lib.ACConfig; import com.shinoow.abyssalcraft.lib.ACLoot; public class EntityEvilCow extends EntityMob implements IShearable { public EntityEvilCow(World par1World) { super(par1World); setSize(0.9F, 1.3F); isImmuneToFire = true; double var2 = 0.35D; tasks.addTask(0, new EntityAISwimming(this)); tasks.addTask(2, new EntityAIAttackMelee(this, var2, true)); tasks.addTask(3, new EntityAIWander(this, var2)); tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); tasks.addTask(4, new EntityAILookIdle(this)); targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); if(ACConfig.hardcoreMode){ getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D); } else getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(15.0D); } @Override public boolean attackEntityAsMob(Entity par1Entity) { if(ACConfig.hardcoreMode && par1Entity instanceof EntityPlayer) par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this).setDamageBypassesArmor().setDamageIsAbsolute(), 1.5F * (float)(ACConfig.damageAmpl > 1.0D ? ACConfig.damageAmpl : 1)); return super.attackEntityAsMob(par1Entity); } @Override public String getName() { return I18n.translateToLocal("entity.Cow.name"); } @Override protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_COW_AMBIENT; } @Override protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_GHAST_HURT; } @Override protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_COW_DEATH; } @Override protected void playStepSound(BlockPos pos, Block p_145780_4_) { playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); } @Override protected float getSoundVolume() { return 0.4F; } @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); if(!world.isRemote) if(!(par1DamageSource.getEntity() instanceof EntityLesserShoggoth)) { EntityDemonCow demoncow = new EntityDemonCow(world); demoncow.copyLocationAndAnglesFrom(this); world.removeEntity(this); demoncow.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(posX, posY, posZ)), (IEntityLivingData)null); world.spawnEntity(demoncow); } } @Override protected ResourceLocation getLootTable(){ return ACLoot.ENTITY_EVIL_COW; } @Override public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos){ return true; } @Override public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess w, BlockPos pos, int fortune) { int i = 1 + rand.nextInt(3); java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>(); for (int j = 0; j < i; ++j) ret.add(new ItemStack(Items.LEATHER)); playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F); playSound(SoundEvents.ENTITY_GHAST_HURT, 1.0F, 0.2F); if(!world.isRemote){ EntityDemonCow demoncow = new EntityDemonCow(world); demoncow.copyLocationAndAnglesFrom(this); world.removeEntity(this); demoncow.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(posX, posY, posZ)), (IEntityLivingData)null); world.spawnEntity(demoncow); } return ret; } }