Java Code Examples for net.minecraft.entity.projectile.EntityArrow

The following are top voted examples for showing how to use net.minecraft.entity.projectile.EntityArrow. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity picks up an item.
 */
public void onItemPickup(Entity entityIn, int quantity)
{
    if (!entityIn.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (entityIn instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }

        if (entityIn instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }

        if (entityIn instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();
        this.aiSit.setSitting(false);

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 4
Project: DecompiledMinecraft   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
Example 5
Project: DecompiledMinecraft   File: EntityMinecartTNT.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    Entity entity = source.getSourceOfDamage();

    if (entity instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entity;

        if (entityarrow.isBurning())
        {
            this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
        }
    }

    return super.attackEntityFrom(source, amount);
}
 
Example 6
Project: DecompiledMinecraft   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
 
Example 7
Project: DecompiledMinecraft   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();
        this.aiSit.setSitting(false);

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 8
Project: DecompiledMinecraft   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
Example 9
Project: DecompiledMinecraft   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
    int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
    int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
    entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

    if (i > 0)
    {
        entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);
    }

    if (j > 0)
    {
        entityarrow.setKnockbackStrength(j);
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)
    {
        entityarrow.setFire(100);
    }

    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entityarrow);
}
 
Example 10
Project: Never-Enough-Currency   File: ModEventHandler.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent
public static void onLivingDropsEvent(LivingDropsEvent event) {
	if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) {
		if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) {
			CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
			return;
		}

		if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) {
			EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource();
			if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) {
				CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
				return;
			}
		}
	}
}
 
Example 11
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
 
Example 12
Project: BaseClient   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();
        this.aiSit.setSitting(false);

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 13
Project: BaseClient   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
Example 14
Project: BaseClient   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
    int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
    int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
    entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

    if (i > 0)
    {
        entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);
    }

    if (j > 0)
    {
        entityarrow.setKnockbackStrength(j);
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)
    {
        entityarrow.setFire(100);
    }

    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entityarrow);
}
 
Example 15
Project: BaseClient   File: EntityMinecartTNT.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    Entity entity = source.getSourceOfDamage();

    if (entity instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entity;

        if (entityarrow.isBurning())
        {
            this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
        }
    }

    return super.attackEntityFrom(source, amount);
}
 
Example 16
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
 
Example 17
Project: BaseClient   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();
        this.aiSit.setSitting(false);

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 18
Project: BaseClient   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
Example 19
Project: BaseClient   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
    int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
    int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
    entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

    if (i > 0)
    {
        entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);
    }

    if (j > 0)
    {
        entityarrow.setKnockbackStrength(j);
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)
    {
        entityarrow.setFire(100);
    }

    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entityarrow);
}
 
Example 20
Project: CustomWorldGen   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.addStat(AchievementList.SNIPE_SKELETON);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).incrementDroppedSkulls();
        this.entityDropItem(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == SkeletonType.WITHER ? 1 : 0), 0.0F);
    }
}
 
Example 21
Project: CustomWorldGen   File: EntityMinecartTNT.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    Entity entity = source.getSourceOfDamage();

    if (entity instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entity;

        if (entityarrow.isBurning())
        {
            this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
        }
    }

    return super.attackEntityFrom(source, amount);
}
 
Example 22
Project: connor41-etfuturum2   File: EntityTippedArrow.java   Source Code and License 6 votes vote down vote up
@Override
public void onCollideWithPlayer(EntityPlayer player) {
	boolean inGround = false;
	try {
		inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
	} catch (Exception e) {
	}

	if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
		boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;

		ItemStack stack = new ItemStack(ModItems.tipped_arrow);
		TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());

		if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
			flag = false;

		if (flag) {
			playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			player.onItemPickup(this, 1);
			setDead();
		}
	}
}
 
Example 23
Project: Backmemed   File: EntityMinecartTNT.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    Entity entity = source.getSourceOfDamage();

    if (entity instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entity;

        if (entityarrow.isBurning())
        {
            this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
        }
    }

    return super.attackEntityFrom(source, amount);
}
 
Example 24
Project: Backmemed   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();

        if (this.aiSit != null)
        {
            this.aiSit.setSitting(false);
        }

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 25
Project: Backmemed   File: EntitySkeleton.java   Source Code and License 6 votes vote down vote up
protected EntityArrow func_190726_a(float p_190726_1_)
{
    ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);

    if (itemstack.getItem() == Items.SPECTRAL_ARROW)
    {
        EntitySpectralArrow entityspectralarrow = new EntitySpectralArrow(this.world, this);
        entityspectralarrow.func_190547_a(this, p_190726_1_);
        return entityspectralarrow;
    }
    else
    {
        EntityArrow entityarrow = super.func_190726_a(p_190726_1_);

        if (itemstack.getItem() == Items.TIPPED_ARROW && entityarrow instanceof EntityTippedArrow)
        {
            ((EntityTippedArrow)entityarrow).setPotionEffect(itemstack);
        }

        return entityarrow;
    }
}
 
Example 26
Project: Backmemed   File: AbstractSkeleton.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.addStat(AchievementList.SNIPE_SKELETON);
        }
    }
}
 
Example 27
Project: CustomWorldGen   File: EntityWolf.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        Entity entity = source.getEntity();

        if (this.aiSit != null)
        {
            this.aiSit.setSitting(false);
        }

        if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
        {
            amount = (amount + 1.0F) / 2.0F;
        }

        return super.attackEntityFrom(source, amount);
    }
}
 
Example 28
Project: HeroUtils   File: PlasmaArrow.java   Source Code and License 5 votes vote down vote up
public PlasmaArrow(World worldIn, EntityLivingBase shooter)
{
    this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ);
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
    }
}
 
Example 29
Project: MobBlocker   File: TileEntityChunkProtector.java   Source Code and License 5 votes vote down vote up
/**
 * Destroys skeleton arrows in the protected area
 * Checks whether the arrow was shot by a class deriving from IRangedAttackMob
 * Sets the arrow on fire for visual effect by default
 * An arrow already on fire is killed
 * The effect of this is that the arrow, for one tick, is engulfed in flame, as it looks strange to have the arrow disappear for no reason
 * @param chunkBounds AxisAlignedBB in which block should act
 */
private void killArrows(AxisAlignedBB chunkBounds) {
	List<EntityArrow> list =  world.getEntitiesWithinAABB(EntityArrow.class, chunkBounds);
	for (EntityArrow arrow : list) {
		if (arrow.shootingEntity instanceof IRangedAttackMob) {
			if (arrow.isBurning()) {
				arrow.setDead();
			} else {
				arrow.setFire(1);
				arrow.addVelocity(-arrow.motionX, 0, -arrow.motionZ);
			}
		}
	}
}
 
Example 30
Project: MobBlocker   File: TileEntityAreaProtector.java   Source Code and License 5 votes vote down vote up
/**
 * Destroys skeleton arrows in the protected area
 * Checks whether the arrow was shot by a class deriving from IRangedAttackMob
 * Sets the arrow on fire for visual effect by default
 * An arrow already on fire is killed
 * The effect of this is that the arrow, for one tick, is engulfed in flame, as it looks strange to have the arrow disappear for no reason
 * @param areaBounds AxisAlignedBB in which block should act
 */
private void killArrows(AxisAlignedBB areaBounds) {
	List<EntityArrow> list =  world.getEntitiesWithinAABB(EntityArrow.class, areaBounds);
	for (EntityArrow arrow : list) {
		if (arrow.shootingEntity instanceof IRangedAttackMob) {
			if (arrow.isBurning()) {
				arrow.setDead();
			} else {
				arrow.setFire(1);
				arrow.addVelocity(-arrow.motionX, 0, -arrow.motionZ);
			}
		}
	}
}
 
Example 31
Project: Bewitchment   File: ArrowDeflectionBrew.java   Source Code and License 5 votes vote down vote up
private boolean isInGround(EntityArrow a) {
	try {
		return (boolean) inground.get(a);
	} catch (IllegalArgumentException | IllegalAccessException e) {
		e.printStackTrace();
		return false;
	}
}
 
Example 32
Project: DecompiledMinecraft   File: BlockTNT.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote && entityIn instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entityIn;

        if (entityarrow.isBurning())
        {
            this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 33
Project: DecompiledMinecraft   File: BlockButton.java   Source Code and License 5 votes vote down vote up
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 34
Project: CustomWorldGen   File: EntityShulker.java   Source Code and License 5 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isClosed())
    {
        Entity entity = source.getSourceOfDamage();

        if (entity instanceof EntityArrow)
        {
            return false;
        }
    }

    if (super.attackEntityFrom(source, amount))
    {
        if ((double)this.getHealth() < (double)this.getMaxHealth() * 0.5D && this.rand.nextInt(4) == 0)
        {
            this.tryTeleportToNewPosition();
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 35
Project: CustomWorldGen   File: BlockButton.java   Source Code and License 5 votes vote down vote up
private void checkPressed(IBlockState p_185616_1_, World p_185616_2_, BlockPos p_185616_3_)
{
    List <? extends Entity > list = p_185616_2_.<Entity>getEntitiesWithinAABB(EntityArrow.class, p_185616_1_.getBoundingBox(p_185616_2_, p_185616_3_).offset(p_185616_3_));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)p_185616_1_.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING));
        p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_);
        this.playClickSound((EntityPlayer)null, p_185616_2_, p_185616_3_);
    }

    if (!flag && flag1)
    {
        p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING));
        p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_);
        this.playReleaseSound(p_185616_2_, p_185616_3_);
    }

    if (flag)
    {
        p_185616_2_.scheduleUpdate(new BlockPos(p_185616_3_), this, this.tickRate(p_185616_2_));
    }
}
 
Example 36
Project: CustomWorldGen   File: BlockTNT.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote && entityIn instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entityIn;

        if (entityarrow.isBurning())
        {
            this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 37
Project: DecompiledMinecraft   File: BlockTNT.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote && entityIn instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entityIn;

        if (entityarrow.isBurning())
        {
            this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 38
Project: DecompiledMinecraft   File: BlockButton.java   Source Code and License 5 votes vote down vote up
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 39
Project: BaseClient   File: BlockButton.java   Source Code and License 5 votes vote down vote up
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 40
Project: BaseClient   File: BlockTNT.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote && entityIn instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entityIn;

        if (entityarrow.isBurning())
        {
            this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 41
Project: Halloween   File: EntityFakeStray.java   Source Code and License 5 votes vote down vote up
@Override
protected EntityArrow getArrow(float distanceFactor)
{
	EntityFakeTippedArrow entitytippedarrow = new EntityFakeTippedArrow(this.world, this);
	entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
	return entitytippedarrow;
}
 
Example 42
Project: uniquecrops   File: EmblemDefense.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void autoShield(LivingAttackEvent event) {
	
	if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
	if (!(event.getSource().getSourceOfDamage() instanceof EntityArrow)) return;
	
	ItemStack shield = ((EntityPlayer)event.getEntityLiving()).getHeldItemOffhand();
	ItemStack emblem = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityLiving()).getStackInSlot(6);
	if (shield == null || emblem == null) return;
	if (emblem.getItem() != this || !(shield.getItem() instanceof ItemShield)) return;
	
	shield.attemptDamageItem(1, event.getEntityLiving().worldObj.rand);
	event.setCanceled(true);
}
 
Example 43
Project: minecraft-quiverbow   File: EnderBow.java   Source Code and License 5 votes vote down vote up
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) 
{
    int chargeTime = this.getMaxItemUseDuration(stack) - par4;

    ArrowLooseEvent event = new ArrowLooseEvent(player, stack, chargeTime);
    MinecraftForge.EVENT_BUS.post(event);
    
    if (event.isCanceled()) { return; }	// Not having it
    
    chargeTime = event.charge;

    // Either creative mode or infinity enchantment is higher than 0. Not using arrows
    boolean freeShot = player.capabilities.isCreativeMode;

    if (freeShot || player.inventory.hasItemStack(new ItemStack(Items.arrow)) ) 
    {
        float f = (float) chargeTime / 20.0F;
        f = (f * f + f * 2.0F) / 3.0F;

        if ((double)f < 0.1D) { return; }
        if (f > 1.0F) { f = 1.0F; }

        EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F);

        if (f == 1.0F) { entityarrow.setIsCritical(true); }

        stack.damageItem(1, player);
        world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

        if (freeShot) { entityarrow.canBePickedUp = 2; }
        else { player.inventory.consumeInventoryItem(Items.arrow); }

        if (!world.isRemote) { world.spawnEntityInWorld(entityarrow); }	// pew.
    }
}
 
Example 44
Project: minecraft-quiverbow   File: QuiverBow.java   Source Code and License 5 votes vote down vote up
@Override
public void onPlayerStoppedUsing(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
	if (!par2World.isRemote)
	{
		int j = this.getMaxItemUseDuration(stack) - par4;		// Reduces the durability by the ItemInUseCount (probably 1 for anything that isn't a tool)

		ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, stack, j);
		MinecraftForge.EVENT_BUS.post(event);
		if (event.isCanceled()) { return; }
		j = event.charge;

		if (this.getDamage(stack) == this.getMaxDamage()) {	return; }		// No arrows in the quiver? Getting out of here early

		float f = j / 20.0F;
		f = (f * f + f * 2.0F) / 3.0F;

		if (f < 0.1D) { return; }
		if (f > 1.0F) { f = 1.0F; }

		EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
		if (f == 1.0F) { entityarrow.setIsCritical(true); }

		par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

		if (par3EntityPlayer.capabilities.isCreativeMode) { entityarrow.canBePickedUp = 0; }
		else
		{
			entityarrow.canBePickedUp = 1;
			stack.setItemDamage(this.getDamage(stack) + 1);		// Reversed. MORE Damage for a shorter durability bar
		}

		par2World.spawnEntityInWorld(entityarrow);

	}
}
 
Example 45
Project: CustomWorldGen   File: PhaseSittingBase.java   Source Code and License 5 votes vote down vote up
/**
 * Normally, just returns damage. If dragon is sitting and src is an arrow, arrow is enflamed and zero damage
 * returned.
 */
public float getAdjustedDamage(EntityDragonPart pt, DamageSource src, float damage)
{
    if (src.getSourceOfDamage() instanceof EntityArrow)
    {
        src.getSourceOfDamage().setFire(1);
        return 0.0F;
    }
    else
    {
        return super.getAdjustedDamage(pt, src, damage);
    }
}
 
Example 46
Project: Backmemed   File: EntityShulker.java   Source Code and License 5 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isClosed())
    {
        Entity entity = source.getSourceOfDamage();

        if (entity instanceof EntityArrow)
        {
            return false;
        }
    }

    if (super.attackEntityFrom(source, amount))
    {
        if ((double)this.getHealth() < (double)this.getMaxHealth() * 0.5D && this.rand.nextInt(4) == 0)
        {
            this.tryTeleportToNewPosition();
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 47
Project: Backmemed   File: EntityStray.java   Source Code and License 5 votes vote down vote up
protected EntityArrow func_190726_a(float p_190726_1_)
{
    EntityArrow entityarrow = super.func_190726_a(p_190726_1_);

    if (entityarrow instanceof EntityTippedArrow)
    {
        ((EntityTippedArrow)entityarrow).addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
    }

    return entityarrow;
}
 
Example 48
Project: Backmemed   File: AbstractSkeleton.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    EntityArrow entityarrow = this.func_190726_a(distanceFactor);
    double d0 = target.posX - this.posX;
    double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entityarrow.posY;
    double d2 = target.posZ - this.posZ;
    double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
    entityarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4));
    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntityInWorld(entityarrow);
}
 
Example 49
Project: Backmemed   File: BlockButton.java   Source Code and License 5 votes vote down vote up
private void checkPressed(IBlockState p_185616_1_, World p_185616_2_, BlockPos p_185616_3_)
{
    List <? extends Entity > list = p_185616_2_.<Entity>getEntitiesWithinAABB(EntityArrow.class, p_185616_1_.getBoundingBox(p_185616_2_, p_185616_3_).offset(p_185616_3_));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)p_185616_1_.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING));
        p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_);
        this.playClickSound((EntityPlayer)null, p_185616_2_, p_185616_3_);
    }

    if (!flag && flag1)
    {
        p_185616_2_.setBlockState(p_185616_3_, p_185616_1_.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(p_185616_2_, p_185616_3_, (EnumFacing)p_185616_1_.getValue(FACING));
        p_185616_2_.markBlockRangeForRenderUpdate(p_185616_3_, p_185616_3_);
        this.playReleaseSound(p_185616_2_, p_185616_3_);
    }

    if (flag)
    {
        p_185616_2_.scheduleUpdate(new BlockPos(p_185616_3_), this, this.tickRate(p_185616_2_));
    }
}
 
Example 50
Project: HeroUtils   File: PlasmaArrow.java   Source Code and License 4 votes vote down vote up
public PlasmaArrow(World worldIn)
{
    super(worldIn);
    this.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
    this.setSize(0.5F, 0.5F);
}
 
Example 51
Project: Uranium   File: CraftArrow.java   Source Code and License 4 votes vote down vote up
public CraftArrow(CraftServer server, EntityArrow entity) {
    super(server, entity);
}
 
Example 52
Project: Uranium   File: CraftArrow.java   Source Code and License 4 votes vote down vote up
@Override
public EntityArrow getHandle() {
    return (EntityArrow) entity;
}
 
Example 53
Project: Uranium   File: ActivationRange.java   Source Code and License 4 votes vote down vote up
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity)
{
    // quick checks.
    if ( entity.inWater /* isInWater */ || entity.fire > 0 )
    {
        return true;
    }
    if ( !( entity instanceof EntityArrow ) )
    {
        if ( !entity.onGround || entity.riddenByEntity != null
                || entity.ridingEntity != null )
        {
            return true;
        }
    } else if ( !( (EntityArrow) entity ).inGround )
    {
        return true;
    }
    // special cases.
    if ( entity instanceof EntityLiving )
    {
        EntityLiving living = (EntityLiving) entity;
        if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
        {
            return true;
        }
        if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
        {
            return true;
        }
        if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
        {
            return true;
        }
        if ( entity instanceof EntityAnimal )
        {
            EntityAnimal animal = (EntityAnimal) entity;
            if ( animal.isChild() || animal.isInLove() /*love*/ )
            {
                return true;
            }
            if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
            {
                return true;
            }
        }
    }
    return false;
}
 
Example 54
Project: harshencastle   File: HarshenArrow.java   Source Code and License 4 votes vote down vote up
public HarshenArrow(EntityArrow arrow, EnumHarshenArrowTypes arrowType) {
	super(arrow.world, (EntityLivingBase) arrow.shootingEntity);
	this.arrowType = arrowType;
	setPotionEffect(new ItemStack(Items.ARROW));
}
 
Example 55
Project: CustomWorldGen   File: DataFixesManager.java   Source Code and License 4 votes vote down vote up
public static DataFixer createFixer()
{
    DataFixer datafixer = new DataFixer(512);
    WorldInfo.registerFixes(datafixer);
    EntityPlayer.registerFixesPlayer(datafixer);
    AnvilChunkLoader.registerFixes(datafixer);
    ItemStack.registerFixes(datafixer);
    EntityArmorStand.registerFixesArmorStand(datafixer);
    EntityArrow.registerFixesArrow(datafixer);
    EntityBat.registerFixesBat(datafixer);
    EntityBlaze.registerFixesBlaze(datafixer);
    EntityCaveSpider.registerFixesCaveSpider(datafixer);
    EntityChicken.registerFixesChicken(datafixer);
    EntityCow.registerFixesCow(datafixer);
    EntityCreeper.registerFixesCreeper(datafixer);
    EntityDragonFireball.registerFixesDragonFireball(datafixer);
    EntityDragon.registerFixesDragon(datafixer);
    EntityEnderman.registerFixesEnderman(datafixer);
    EntityEndermite.registerFixesEndermite(datafixer);
    EntityFallingBlock.registerFixesFallingBlock(datafixer);
    EntityLargeFireball.registerFixesLargeFireball(datafixer);
    EntityFireworkRocket.registerFixesFireworkRocket(datafixer);
    EntityGhast.registerFixesGhast(datafixer);
    EntityGiantZombie.registerFixesGiantZombie(datafixer);
    EntityGuardian.registerFixesGuardian(datafixer);
    EntityHorse.registerFixesHorse(datafixer);
    EntityItem.registerFixesItem(datafixer);
    EntityItemFrame.registerFixesItemFrame(datafixer);
    EntityMagmaCube.registerFixesMagmaCube(datafixer);
    EntityMinecartChest.registerFixesMinecartChest(datafixer);
    EntityMinecartCommandBlock.registerFixesMinecartCommand(datafixer);
    EntityMinecartFurnace.registerFixesMinecartFurnace(datafixer);
    EntityMinecartHopper.registerFixesMinecartHopper(datafixer);
    EntityMinecartEmpty.registerFixesMinecartEmpty(datafixer);
    EntityMinecartMobSpawner.registerFixesMinecartMobSpawner(datafixer);
    EntityMinecartTNT.registerFixesMinecartTNT(datafixer);
    EntityLiving.registerFixesMob(datafixer);
    EntityMob.registerFixesMonster(datafixer);
    EntityMooshroom.registerFixesMooshroom(datafixer);
    EntityOcelot.registerFixesOcelot(datafixer);
    EntityPig.registerFixesPig(datafixer);
    EntityPigZombie.registerFixesPigZombie(datafixer);
    EntityRabbit.registerFixesRabbit(datafixer);
    EntitySheep.registerFixesSheep(datafixer);
    EntityShulker.registerFixesShulker(datafixer);
    EntitySilverfish.registerFixesSilverfish(datafixer);
    EntitySkeleton.registerFixesSkeleton(datafixer);
    EntitySlime.registerFixesSlime(datafixer);
    EntitySmallFireball.registerFixesSmallFireball(datafixer);
    EntitySnowman.registerFixesSnowman(datafixer);
    EntitySnowball.registerFixesSnowball(datafixer);
    EntitySpectralArrow.registerFixesSpectralArrow(datafixer);
    EntitySpider.registerFixesSpider(datafixer);
    EntitySquid.registerFixesSquid(datafixer);
    EntityEgg.registerFixesEgg(datafixer);
    EntityEnderPearl.registerFixesEnderPearl(datafixer);
    EntityExpBottle.registerFixesExpBottle(datafixer);
    EntityPotion.registerFixesPotion(datafixer);
    EntityTippedArrow.registerFixesTippedArrow(datafixer);
    EntityVillager.registerFixesVillager(datafixer);
    EntityIronGolem.registerFixesIronGolem(datafixer);
    EntityWitch.registerFixesWitch(datafixer);
    EntityWither.registerFixesWither(datafixer);
    EntityWitherSkull.registerFixesWitherSkull(datafixer);
    EntityWolf.registerFixesWolf(datafixer);
    EntityZombie.registerFixesZombie(datafixer);
    TileEntityPiston.registerFixesPiston(datafixer);
    TileEntityFlowerPot.registerFixesFlowerPot(datafixer);
    TileEntityFurnace.registerFixesFurnace(datafixer);
    TileEntityChest.registerFixesChest(datafixer);
    TileEntityDispenser.registerFixes(datafixer);
    TileEntityDropper.registerFixesDropper(datafixer);
    TileEntityBrewingStand.registerFixesBrewingStand(datafixer);
    TileEntityHopper.registerFixesHopper(datafixer);
    BlockJukebox.registerFixesJukebox(datafixer);
    TileEntityMobSpawner.registerFixesMobSpawner(datafixer);
    registerFixes(datafixer);
    return datafixer;
}
 
Example 56
Project: DecompiledMinecraft   File: EntityPlayerMP.java   Source Code and License 4 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        boolean flag = this.mcServer.isDedicatedServer() && this.canPlayersAttack() && "fall".equals(source.damageType);

        if (!flag && this.respawnInvulnerabilityTicks > 0 && source != DamageSource.outOfWorld)
        {
            return false;
        }
        else
        {
            if (source instanceof EntityDamageSource)
            {
                Entity entity = source.getEntity();

                if (entity instanceof EntityPlayer && !this.canAttackPlayer((EntityPlayer)entity))
                {
                    return false;
                }

                if (entity instanceof EntityArrow)
                {
                    EntityArrow entityarrow = (EntityArrow)entity;

                    if (entityarrow.shootingEntity instanceof EntityPlayer && !this.canAttackPlayer((EntityPlayer)entityarrow.shootingEntity))
                    {
                        return false;
                    }
                }
            }

            return super.attackEntityFrom(source, amount);
        }
    }
}
 
Example 57
Project: DecompiledMinecraft   File: EntityPlayer.java   Source Code and License 4 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !source.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.worldObj.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (source.isDifficultyScaled())
            {
                if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
                {
                    amount = 0.0F;
                }

                if (this.worldObj.getDifficulty() == EnumDifficulty.EASY)
                {
                    amount = amount / 2.0F + 1.0F;
                }

                if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
                {
                    amount = amount * 3.0F / 2.0F;
                }
            }

            if (amount == 0.0F)
            {
                return false;
            }
            else
            {
                Entity entity = source.getEntity();

                if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null)
                {
                    entity = ((EntityArrow)entity).shootingEntity;
                }

                return super.attackEntityFrom(source, amount);
            }
        }
    }
}
 
Example 58
Project: CustomWorldGen   File: ItemTippedArrow.java   Source Code and License 4 votes vote down vote up
public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter)
{
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(worldIn, shooter);
    entitytippedarrow.setPotionEffect(stack);
    return entitytippedarrow;
}
 
Example 59
Project: DecompiledMinecraft   File: EntityWither.java   Source Code and License 4 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (source != DamageSource.drown && !(source.getEntity() instanceof EntityWither))
    {
        if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld)
        {
            return false;
        }
        else
        {
            if (this.isArmored())
            {
                Entity entity = source.getSourceOfDamage();

                if (entity instanceof EntityArrow)
                {
                    return false;
                }
            }

            Entity entity1 = source.getEntity();

            if (entity1 != null && !(entity1 instanceof EntityPlayer) && entity1 instanceof EntityLivingBase && ((EntityLivingBase)entity1).getCreatureAttribute() == this.getCreatureAttribute())
            {
                return false;
            }
            else
            {
                if (this.blockBreakCounter <= 0)
                {
                    this.blockBreakCounter = 20;
                }

                for (int i = 0; i < this.field_82224_i.length; ++i)
                {
                    this.field_82224_i[i] += 3;
                }

                return super.attackEntityFrom(source, amount);
            }
        }
    }
    else
    {
        return false;
    }
}
 
Example 60
Project: DecompiledMinecraft   File: NetHandlerPlayServer.java   Source Code and License 4 votes vote down vote up
/**
 * Processes interactions ((un)leashing, opening command block GUI) and attacks on an entity with players currently
 * equipped item
 */
public void processUseEntity(C02PacketUseEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    Entity entity = packetIn.getEntityFromWorld(worldserver);
    this.playerEntity.markPlayerActive();

    if (entity != null)
    {
        boolean flag = this.playerEntity.canEntityBeSeen(entity);
        double d0 = 36.0D;

        if (!flag)
        {
            d0 = 9.0D;
        }

        if (this.playerEntity.getDistanceSqToEntity(entity) < d0)
        {
            if (packetIn.getAction() == C02PacketUseEntity.Action.INTERACT)
            {
                this.playerEntity.interactWith(entity);
            }
            else if (packetIn.getAction() == C02PacketUseEntity.Action.INTERACT_AT)
            {
                entity.interactAt(this.playerEntity, packetIn.getHitVec());
            }
            else if (packetIn.getAction() == C02PacketUseEntity.Action.ATTACK)
            {
                if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity)
                {
                    this.kickPlayerFromServer("Attempting to attack an invalid entity");
                    this.serverController.logWarning("Player " + this.playerEntity.getName() + " tried to attack an invalid entity");
                    return;
                }

                this.playerEntity.attackTargetEntityWithCurrentItem(entity);
            }
        }
    }
}