Advertisement
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.EntityAIAttackRangedBow;
- 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.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.MobEffects;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.world.World;
- public class EntityPegasus extends EntityParrot implements IRangedAttackMob{
- private final EntityAIAttackRangedBow2<EntityPegasus> aiArrowAttack = new EntityAIAttackRangedBow2<EntityPegasus>(this, 1.0D, 20, 15.0F);
- public EntityPegasus(World worldIn) {
- super(worldIn);
- }
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(6);
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
- }
- protected void initEntityAI()
- {
- this.tasks.addTask(1, new EntityAIFollowOwnerFlying(this, 2.0D, 5.0F, 1.0F));
- this.tasks.addTask(1, new EntityAISit(this));
- this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 10, 10.0F));
- 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(1, new EntityAIFollow(this, 2.0D, 3.0F, 7.0F));
- this.tasks.addTask(1, aiArrowAttack);
- }
- @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);
- }
- EntityTippedArrow entitytippedarrow2 = new EntityTippedArrow(this.world, this);
- double d4 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
- double d5 = target.posX - this.posX;
- double d6 = d4 - entitytippedarrow2.posY;
- double d7 = target.posZ - this.posZ;
- float f2 = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
- entitytippedarrow2.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(entitytippedarrow2);
- PotionEffect potion2 = new PotionEffect(Potion.getPotionById(2), 100, 2);
- if(target.hitByEntity(entitytippedarrow2)==true)
- {
- target.addPotionEffect(potion2);
- }
- EntityTippedArrow entitytippedarrow3 = new EntityTippedArrow(this.world, this);
- double d8 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
- double d9 = target.posX - this.posX;
- double d10 = d4 - entitytippedarrow3.posY;
- double d11 = target.posZ - this.posZ;
- float f3 = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
- entitytippedarrow3.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(entitytippedarrow3);
- PotionEffect potion3 = new PotionEffect(Potion.getPotionById(2), 100, 2);
- if(target.hitByEntity(entitytippedarrow3)==true)
- {
- target.addPotionEffect(potion3);
- }
- }
- @Override
- public void setSwingingArms(boolean swingingArms) {
- // TODO Auto-generated method stub
- }
- protected void mountTo(EntityPlayer player)
- {
- player.rotationYaw = this.rotationYaw;
- player.rotationPitch = this.rotationPitch;
- if (!this.world.isRemote)
- {
- player.startRiding(this);
- }
- }
- private static final Set<Item> TAME_ITEMS = Sets.newHashSet(ModItems.SAPPHIRE);
- private static final Item DEADLY_ITEM = ModItems.ANTI_PET_CHARM;
- @Override
- public boolean processInteract(EntityPlayer player, EnumHand hand) {
- {
- ItemStack itemstack = player.getHeldItem(hand);
- if (!this.isTamed() && TAME_ITEMS.contains(itemstack.getItem()))
- {
- if (!player.capabilities.isCreativeMode)
- {
- itemstack.shrink(1);
- }
- if (!this.isSilent())
- {
- this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PARROT_EAT, this.getSoundCategory(), 1.0F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
- }
- if (!this.world.isRemote)
- {
- if (this.rand.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player))
- {
- this.setTamedBy(player);
- this.playTameEffect(true);
- this.world.setEntityState(this, (byte)7);
- }
- else
- {
- this.playTameEffect(false);
- this.world.setEntityState(this, (byte)6);
- }
- }
- return true;
- }
- else if (itemstack.getItem() == DEADLY_ITEM)
- {
- if (!player.capabilities.isCreativeMode)
- {
- itemstack.shrink(1);
- }
- this.addPotionEffect(new PotionEffect(MobEffects.POISON, 900));
- if (player.isCreative() || !this.getIsInvulnerable())
- {
- this.attackEntityFrom(DamageSource.causePlayerDamage(player), Float.MAX_VALUE);
- }
- return true;
- }
- else
- {
- return super.processInteract(player, hand);
- }
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement