net.minecraft.entity.projectile.EntityArrow Java Examples

The following examples show how to use net.minecraft.entity.projectile.EntityArrow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTofuGandlem.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
    if (this.isEntityInvulnerable(source)) {
        return false;
    } else if (source.getImmediateSource() instanceof EntityFukumame) {
        return false;
    } else {
        if (isSleep()) {
            setSleep(false);

           /* if(source.getImmediateSource() instanceof EntityPlayerMP) {
                this.bossInfo.addPlayer((EntityPlayerMP) source.getImmediateSource());
            }*/
        }
        if (source.getImmediateSource() instanceof EntityArrow) {
            return super.attackEntityFrom(source, amount * 0.8F);
        } else {
            return super.attackEntityFrom(source, amount);
        }
    }
}
 
Example #2
Source File: EntityArcher.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) {
    EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
    int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
    int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
    entityarrow.setDamage((double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting.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) {
        entityarrow.setFire(100);
    }

    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entityarrow);
}
 
Example #3
Source File: EventBarrage.java    From Levels with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("static-access")
@SubscribeEvent
public void onBowFire(ArrowLooseEvent event)
{
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = event.getBow();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (player != null && stack != null && nbt != null && !player.getEntityWorld().isRemote)
	{
		if (BowAttribute.BARRAGE.hasAttribute(nbt))
		{
			for (int i = 0; i < (int) BowAttribute.BARRAGE.getCalculatedValue(nbt, 3, 1.5); i++)
			{
				EntityArrow entityarrow = new EntityTippedArrow(player.getEntityWorld(), player);
				entityarrow.setAim(player, player.rotationPitch, player.rotationYaw, 0, ((ItemBow) event.getBow().getItem()).getArrowVelocity(event.getCharge()) * 3, 20F);
				entityarrow.pickupStatus = PickupStatus.DISALLOWED;
				player.getEntityWorld().spawnEntity(entityarrow);
			}
		}
	}
}
 
Example #4
Source File: EntityTippedArrow.java    From Et-Futurum with The Unlicense 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 #5
Source File: ItemESP.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onRender2D(final Render2DEvent event) {
    if (modeValue.get().equalsIgnoreCase("ShaderOutline")) {
        OutlineShader.OUTLINE_SHADER.startDraw(event.getPartialTicks());

        try {
            for (final Entity entity : mc.theWorld.loadedEntityList) {
                if (!(entity instanceof EntityItem || entity instanceof EntityArrow))
                    continue;

                mc.getRenderManager().renderEntityStatic(entity, event.getPartialTicks(), true);
            }
        } catch (final Exception ex) {
            ClientUtils.getLogger().error("An error occurred while rendering all item entities for shader esp", ex);
        }

        OutlineShader.OUTLINE_SHADER.stopDraw(colorRainbow.get() ? ColorUtils.rainbow() : new Color(colorRedValue.get(), colorGreenValue.get(), colorBlueValue.get()), 1F, 1F);
    }
}
 
Example #6
Source File: GTUtility.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Pushes entities away from target within an area, code adapted from
 * EE/ProjectE.
 */
public static void repelEntitiesInAABBFromPoint(World world, AxisAlignedBB boundingbox, double x, double y,
		double z) {
	List<Entity> list = world.getEntitiesWithinAABB(Entity.class, boundingbox);
	if (list.isEmpty()) {
		return;
	}
	for (Entity entity : list) {
		if ((entity instanceof EntityLiving) || (entity instanceof IProjectile)) {
			if (entity instanceof EntityArrow && ((EntityArrow) entity).onGround) {
				continue;
			}
			if (entity instanceof EntityArmorStand) {
				continue;
			}
			Vec3d p = new Vec3d(x, y, z);
			Vec3d t = new Vec3d(entity.posX, entity.posY, entity.posZ);
			double distance = p.distanceTo(t) + 0.1D;
			Vec3d r = new Vec3d(t.x - p.x, t.y - p.y, t.z - p.z);
			entity.motionX += r.x / 1.5D / distance;
			entity.motionY += r.y / 1.5D / distance;
			entity.motionZ += r.z / 1.5D / distance;
		}
	}
}
 
Example #7
Source File: BlockTrap.java    From Artifacts with MIT License 5 votes vote down vote up
/**
 * Ticks the block if it's been scheduled
 */
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
	if (!par1World.isRemote)
	{
		TileEntity te = par1World.getTileEntity(par2, par3, par4);
		TileEntityDispenser dis;
		if(te instanceof TileEntityDispenser) {
			dis = ((TileEntityDispenser) te);
 		AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(par2-0.2, par3-0.2, par4-0.2, par2+1.2, par3+1.2, par4+1.2);
 		List<EntitySpecialArrow> arrs = par1World.getEntitiesWithinAABB(EntitySpecialArrow.class, aabb);
 		for(int a = arrs.size()-1; a>=0; a--) {
 			EntityArrow arr = arrs.get(a);
 			for(int s=0; s<9; s++) {
 				ItemStack is = dis.getStackInSlot(s);
 				if(is == null) {
 					dis.setInventorySlotContents(s, new ItemStack(Items.arrow, 1));
 					arr.setDead();
 					break;
 				}
 				else if(is != null && is.getItem() == Items.arrow) {
 					if(is.stackSize < 64) {
 						is.stackSize++;
 						arr.setDead();
 						break;
 					}
 				}
 			}
 		}
 		
 		this.dispense(par1World, par2, par3, par4, par5Random.nextInt(4)+1);
 		this.dispense(par1World, par2, par3, par4, par5Random.nextInt(4)+1);
		}
	}
}
 
Example #8
Source File: MoCEntityRat.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i))
    {
        Entity entity = damagesource.getEntity();
        if (entity instanceof EntityPlayer)
        {
            entityToAttack = entity;
        }
        if ((entity instanceof EntityArrow) && (((EntityArrow) entity).shootingEntity != null))
        {
            entity = ((EntityArrow) entity).shootingEntity;
        }
        if (entity instanceof EntityLiving)
        {
            //TODO 4FIX TEST
            List list = worldObj.getEntitiesWithinAABB(MoCEntityRat.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1.0D, posY + 1.0D, posZ + 1.0D).expand(16D, 4D, 16D));
            Iterator iterator = list.iterator();
            do
            {
                if (!iterator.hasNext())
                {
                    break;
                }
                Entity entity1 = (Entity) iterator.next();
                MoCEntityRat entityrat = (MoCEntityRat) entity1;
                if ((entityrat != null) && (entityrat.entityToAttack == null))
                {
                    entityrat.entityToAttack = entity;
                }
            } while (true);
        }
        return true;
    }
    else
    {
        return false;
    }
}
 
Example #9
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void attackWithArrow(EntityLivingBase target) {

		int charge = 2 + rand.nextInt(10);

		EntityArrow entityarrow = new EntityTippedArrow(this.world, this);
		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.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F,
				(float) (14 - this.world.getDifficulty().getDifficultyId() * 4));
		int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
		int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
		entityarrow.setDamage((double) (charge * 2.0F) + this.rand.nextGaussian() * 0.25D
				+ (double) ((float) this.world.getDifficulty().getDifficultyId() * 0.11F));

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

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

		if (rand.nextBoolean()) {
			entityarrow.setFire(100);
		}

		this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
		this.world.spawnEntity(entityarrow);
	}
 
Example #10
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void attackWithArrow(EntityLivingBase target) {

		int charge = 2 + rand.nextInt(10);

		EntityArrow entityarrow = new EntityTippedArrow(this.world, this);
		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.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F,
				(float) (14 - this.world.getDifficulty().getDifficultyId() * 4));
		int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
		int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
		entityarrow.setDamage((double) (charge * 2.0F) + this.rand.nextGaussian() * 0.25D
				+ (double) ((float) this.world.getDifficulty().getDifficultyId() * 0.11F));

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

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

		if (rand.nextBoolean()) {
			entityarrow.setFire(100);
		}

		this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
		this.world.spawnEntity(entityarrow);
	}
 
Example #11
Source File: BlockButton.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private void checkPressed(IBlockState state, World worldIn, BlockPos pos)
{
    List<? extends Entity> list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, state.getBoundingBox(worldIn, pos).offset(pos));
    boolean flag = !list.isEmpty();
    boolean flag1 = state.getValue(POWERED);

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, true));
        this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        this.playClickSound(null, worldIn, pos);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, false));
        this.notifyNeighbors(worldIn, pos, state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        this.playReleaseSound(worldIn, pos);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
    }
}
 
Example #12
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 5 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 || entity.fire > 0) {
        return true;
    }
    if (!(entity instanceof EntityArrow)) {
        if (!entity.onGround || !entity.riddenByEntities.isEmpty() || entity.isRiding()) {
            return true;
        }
    } else if (!((EntityArrow) entity).inGround) {
        return true;
    }
    // special cases.
    if (entity instanceof EntityLiving) {
        EntityLiving living = (EntityLiving) entity;
        if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTime > 0 || living.activePotionsMap.size() > 0) {
            return true;
        }
        if (entity instanceof EntityCreature && ((EntityCreature) entity).getAttackTarget() != null) {
            return true;
        }
        if (entity instanceof EntityVillager && ((EntityVillager) entity).isMating()) {
            return true;
        }
        if (entity instanceof EntityAnimal) {
            EntityAnimal animal = (EntityAnimal) entity;
            if (animal.isChild() || animal.isInLove()) {
                return true;
            }
            if (entity instanceof EntitySheep && ((EntitySheep) entity).getSheared()) {
                return true;
            }
        }
        if (entity instanceof EntityCreeper && ((EntityCreeper) entity).hasIgnited()) { // isExplosive
            return true;
        }
    }
    return false;
}
 
Example #13
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * EntityShootBowEvent
 */
public static EntityShootBowEvent callEntityShootBowEvent(EntityLivingBase who, ItemStack itemstack, EntityArrow entityArrow, float force) {
    LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
    Arrow arrow = (Arrow) entityArrow.getBukkitEntity();

    if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
        itemInHand = null;
    }

    EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force);
    Bukkit.getPluginManager().callEvent(event);

    return event;
}
 
Example #14
Source File: ArrowShootEvent.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ArrowShootEvent(@NotNull EntityArrow arrow, int charge, @NotNull ItemStack bow) {
    Preconditions.checkNotNull(arrow, "arrow");
    Preconditions.checkNotNull(bow, "bow");

    this.arrow = arrow;
    this.charge = charge;
    this.bow = bow;
}
 
Example #15
Source File: ItemESP.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onRender3D(final Render3DEvent event) {
    if (modeValue.get().equalsIgnoreCase("Box")) {
        final Color color = colorRainbow.get() ? ColorUtils.rainbow() : new Color(colorRedValue.get(), colorGreenValue.get(), colorBlueValue.get());

        for (final Entity entity : mc.theWorld.loadedEntityList) {
            if (!(entity instanceof EntityItem || entity instanceof EntityArrow))
                continue;

            RenderUtils.drawEntityBox(entity, color, true);
        }
    }
}
 
Example #16
Source File: CraftArrow.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Block getAttachedBlock() {
    if (!isInBlock()) {
        return null;
    }

    EntityArrow handle = getHandle();
    return getWorld().getBlockAt(handle.xTile, handle.yTile, handle.zTile);
}
 
Example #17
Source File: CraftArrow.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftArrow(CraftServer server, EntityArrow entity) {
    super(server, entity);
}
 
Example #18
Source File: PlayerListener.java    From SkyblockAddons with MIT License 4 votes vote down vote up
@SubscribeEvent()
    public void onTickMagmaBossChecker(EntityEvent.EnteringChunk e) {
        Entity entity = e.entity;

        if (main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.ZEALOT_COUNTER_EXPLOSIVE_BOW_SUPPORT) && entity instanceof EntityArrow) {
            EntityArrow arrow = (EntityArrow)entity;

            EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
            ItemStack heldItem = p.getHeldItem();
            if (heldItem != null && "EXPLOSIVE_BOW".equals(ItemUtils.getSkyBlockItemID(heldItem))) {

                AxisAlignedBB playerRadius = new AxisAlignedBB(p.posX - 3, p.posY - 3, p.posZ - 3, p.posX + 3, p.posY + 3, p.posZ + 3);
                if (playerRadius.isVecInside(arrow.getPositionVector())) {

//                    System.out.println("Spawned explosive arrow!");
                    main.getNewScheduler().scheduleRepeatingTask(new SkyblockRunnable() {
                        @Override
                        public void run() {
                            if (arrow.isDead || arrow.isCollided || arrow.inGround) {
                                cancel();

//                                System.out.println("Arrow is done, added an explosion!");
                                Vec3 explosionLocation = new Vec3(arrow.posX, arrow.posY, arrow.posZ);
                                explosiveBowExplosions.put(System.currentTimeMillis(), explosionLocation);

                                recentlyKilledZealots.keySet().removeIf((killedTime) -> System.currentTimeMillis() - killedTime > 150);
                                Set<Vec3> filteredRecentlyKilledZealots = new HashSet<>();
                                for (Map.Entry<Long, Set<Vec3>> recentlyKilledZealotEntry : recentlyKilledZealots.entrySet()) {
                                    filteredRecentlyKilledZealots.addAll(recentlyKilledZealotEntry.getValue());
                                }
                                if (filteredRecentlyKilledZealots.isEmpty()) return;

//                                int possibleZealotsKilled = filteredRecentlyKilledZealots.size();
//                                System.out.println("This means "+possibleZealotsKilled+" may have been killed...");
//                                int originalPossibleZealotsKilled = possibleZealotsKilled;

                                for (Vec3 zealotDeathLocation : filteredRecentlyKilledZealots) {
                                    double distance = explosionLocation.distanceTo(zealotDeathLocation);
                                    System.out.println("Distance was "+distance+"!");
                                    if (distance < 4.6) {
//                                        possibleZealotsKilled--;

                                        main.getPersistentValues().addKill();
                                        EndstoneProtectorManager.onKill();
                                    }
                                }

//                                System.out.println((originalPossibleZealotsKilled-possibleZealotsKilled)+" zealots were actually killed...");
                            }
                        }
                    }, 0, 1);
                }
            }
        }

        if (main.getUtils().getLocation() == Location.BLAZING_FORTRESS) {
            if (magmaBossSpawnArea.isVecInside(new Vec3(entity.posX, entity.posY, entity.posZ))) { // timers will trigger if 15 magmas/8 blazes spawn in the box within a 4 second time period
                long currentTime = System.currentTimeMillis();
                if (e.entity instanceof EntityMagmaCube) {
                    if (!recentlyLoadedChunks.contains(new IntPair(e.newChunkX, e.newChunkZ)) && entity.ticksExisted == 0) {
                        recentMagmaCubes++;
                        main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_MAGMA_COUNT, 4);
                        if (recentMagmaCubes >= 17) {
                            magmaTime = 600;
                            magmaAccuracy = EnumUtils.MagmaTimerAccuracy.EXACTLY;
                            if (currentTime - lastMagmaWavePost > 300000) {
                                lastMagmaWavePost = currentTime;
                                main.getUtils().sendInventiveTalentPingRequest(EnumUtils.MagmaEvent.MAGMA_WAVE);
                            }
                        }
                    }
                } else if (e.entity instanceof EntityBlaze) {
                    if (!recentlyLoadedChunks.contains(new IntPair(e.newChunkX, e.newChunkZ)) && entity.ticksExisted == 0) {
                        recentBlazes++;
                        main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_BLAZE_COUNT, 4);
                        if (recentBlazes >= 10) {
                            magmaTime = 1200;
                            magmaAccuracy = EnumUtils.MagmaTimerAccuracy.EXACTLY;
                            if (currentTime - lastBlazeWavePost > 300000) {
                                lastBlazeWavePost = currentTime;
                                main.getUtils().sendInventiveTalentPingRequest(EnumUtils.MagmaEvent.BLAZE_WAVE);
                            }
                        }
                    }
                }
            }
        }
    }
 
Example #19
Source File: EntityTippedChingerArrow.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public static void registerFixesTippedArrow(DataFixer fixer) {
    EntityArrow.registerFixesArrow(fixer, "TippedArrow");
}
 
Example #20
Source File: ItemZundaArrow.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter)
{
    return new EntityZundaArrow(worldIn, shooter);
}
 
Example #21
Source File: ItemChingerToothArrow.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter) {
    EntityTippedChingerArrow entitytippedarrow = new EntityTippedChingerArrow(worldIn, shooter);
    entitytippedarrow.setPotionEffect(stack);
    return entitytippedarrow;
}
 
Example #22
Source File: EntityArmourStand.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (!worldObj.isRemote && !canInteract) {
		if (DamageSource.outOfWorld.equals(source)) {
			setDead();
			return false;
		} else if (isEntityInvulnerable())
			return false;
		else if (source.isExplosion()) {
			dropequipment();
			setDead();
			return false;
		} else if (DamageSource.inFire.equals(source)) {
			if (!isBurning())
				setFire(5);
			else
				damageArmorStand(0.15F);

			return false;
		} else if (DamageSource.onFire.equals(source) && getHealth() > 0.5F) {
			damageArmorStand(4.0F);
			return false;
		} else {
			boolean flag = "arrow".equals(source.getDamageType());
			boolean flag1 = "player".equals(source.getDamageType());

			if (!flag1 && !flag)
				return false;
			else {
				if (source.getSourceOfDamage() instanceof EntityArrow)
					source.getSourceOfDamage().setDead();

				if (source.getEntity() instanceof EntityPlayer && !((EntityPlayer) source.getEntity()).capabilities.allowEdit)
					return false;
				else if (source.getEntity() instanceof EntityPlayer && ((EntityPlayer) source.getEntity()).capabilities.isCreativeMode) {
					playParticles();
					setDead();
					return false;
				} else {
					long i = worldObj.getTotalWorldTime();

					if (i - punchCooldown > 5L && !flag)
						punchCooldown = i;
					else {
						dropBlock();
						playParticles();
						setDead();
					}

					return false;
				}
			}
		}
	} else
		return false;
}
 
Example #23
Source File: ItemZundaBow.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
{
    if (entityLiving instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)entityLiving;
        boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
        ItemStack itemstack = this.findAmmo(entityplayer);

        int i = this.getMaxItemUseDuration(stack) - timeLeft;
        i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, entityplayer, i, !itemstack.isEmpty() || flag);
        if (i < 0) return;

        if (!itemstack.isEmpty() || flag)
        {
            if (itemstack.isEmpty())
            {
                itemstack = new ItemStack(Items.ARROW);
            }

            float f = getArrowVelocity(i);

            if ((double)f >= 0.1D)
            {
                boolean flag1 = entityplayer.capabilities.isCreativeMode || (itemstack.getItem() instanceof ItemArrow && ((ItemArrow) itemstack.getItem()).isInfinite(itemstack, stack, entityplayer));

                if (!worldIn.isRemote)
                {
                    ItemArrow itemarrow = (ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW);
                    EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
                    entityarrow.shoot(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.05F, 1.0F);

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

                    int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);

                    if(entityarrow instanceof EntityZundaArrow){
                        entityarrow.setDamage(entityarrow.getDamage() + 2.0D);
                    }

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


                    int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);

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

                    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
                    {
                        entityarrow.setFire(100);
                    }

                    stack.damageItem(1, entityplayer);

                    if (flag1 || entityplayer.capabilities.isCreativeMode && (itemstack.getItem() == Items.SPECTRAL_ARROW || itemstack.getItem() == Items.TIPPED_ARROW))
                    {
                        entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                    }

                    worldIn.spawnEntity(entityarrow);
                }

                worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

                if (!flag1 && !entityplayer.capabilities.isCreativeMode)
                {
                    itemstack.shrink(1);

                    if (itemstack.isEmpty())
                    {
                        entityplayer.inventory.deleteStack(itemstack);
                    }
                }

                entityplayer.addStat(StatList.getObjectUseStats(this));
            }
        }
    }
}
 
Example #24
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 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 #25
Source File: CraftArrow.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityArrow getHandle() {
    return (EntityArrow) entity;
}
 
Example #26
Source File: ItemChickenArrow.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter) {
    return new EntityChickenArrow(worldIn, shooter);
}
 
Example #27
Source File: ArrowShootEvent.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
public final EntityArrow getArrow() {
    return arrow;
}
 
Example #28
Source File: CraftArrow.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftArrow(CraftServer server, EntityArrow entity) {
    super(server, entity);
}
 
Example #29
Source File: CraftArrow.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityArrow getHandle() {
    return (EntityArrow) entity;
}
 
Example #30
Source File: CraftArrow.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setPickupStatus(PickupStatus status) {
    Preconditions.checkNotNull(status, "status");
    getHandle().pickupStatus = EntityArrow.PickupStatus.getByOrdinal(status.ordinal());
}