Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ChaoticSoul.MoreArmor.entity;
- import java.util.Set;
- import com.ChaoticSoul.MoreArmor.init.ModItems;
- import com.google.common.collect.Sets;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.IRangedAttackMob;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAIAttackRanged;
- import net.minecraft.entity.ai.EntityAIFollow;
- import net.minecraft.entity.ai.EntityAIFollowOwnerFlying;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
- import net.minecraft.entity.ai.EntityAISit;
- import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.monster.IMob;
- import net.minecraft.entity.passive.EntityParrot;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityTippedArrow;
- import net.minecraft.init.Items;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.item.Item;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.world.World;
- public class EntityPegasus extends EntityParrot implements IRangedAttackMob{
- public EntityPegasus(World worldIn) {
- super(worldIn);
- }
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50.0D);
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(10);
- this.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(0.8D);
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(10);
- }
- private static final Set<Item> TAME_ITEMS = Sets.newHashSet(ModItems.SAPPHIRE);
- protected void initEntityAI()
- {
- this.tasks.addTask(2, new EntityAIFollowOwnerFlying(this, 1.0D, 5.0F, 1.0F));
- this.tasks.addTask(1, new EntityAISit(this));
- this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 20, 10.0F));
- this.tasks.addTask(2, new EntityAIWanderAvoidWater(this, 1.0D, 1.0000001E-5F));
- this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
- this.tasks.addTask(4, new EntityAILookIdle(this));
- this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR));
- this.tasks.addTask(3, new EntityAIFollow(this, 1.0D, 3.0F, 7.0F));
- }
- @Override
- public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
- {
- EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this);
- double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
- double d1 = target.posX - this.posX;
- double d2 = d0 - entitytippedarrow.posY;
- double d3 = target.posZ - this.posZ;
- float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
- entitytippedarrow.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F);
- this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
- this.world.spawnEntity(entitytippedarrow);
- PotionEffect potion = new PotionEffect(Potion.getPotionById(2), 100, 2);
- if(target.hitByEntity(entitytippedarrow)==true)
- {
- target.addPotionEffect(potion);
- }
- }
- private void setHeldItem(EnumHand offHand, Item tippedArrow) {
- // TODO Auto-generated method stub
- }
- @Override
- public void setSwingingArms(boolean swingingArms) {
- // TODO Auto-generated method stub
- }}
Advertisement
Add Comment
Please, Sign In to add comment