net.minecraft.entity.IProjectile Java Examples

The following examples show how to use net.minecraft.entity.IProjectile. 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: EntityLivingBaseHook.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public static void onResetHurtTime(EntityLivingBase entity) {
    if (entity == Minecraft.getMinecraft().thePlayer) {
        SkyblockAddons main = SkyblockAddons.getInstance();
        if (!main.getUtils().isOnSkyblock() || !main.getConfigValues().isEnabled(Feature.COMBAT_TIMER_DISPLAY)) {
            return;
        }

        Minecraft mc = Minecraft.getMinecraft();
        List<Entity> nearEntities = mc.theWorld.getEntitiesWithinAABB(Entity.class,
                new AxisAlignedBB(mc.thePlayer.posX - 3, mc.thePlayer.posY - 2, mc.thePlayer.posZ - 3, mc.thePlayer.posX + 3, mc.thePlayer.posY + 2, mc.thePlayer.posZ + 3));
        boolean foundPossibleAttacker = false;

        for (Entity nearEntity : nearEntities) {
            if (nearEntity instanceof EntityMob || nearEntity instanceof EntityWolf || nearEntity instanceof IProjectile) {
                foundPossibleAttacker = true;
                break;
            }
        }

        if (foundPossibleAttacker) {
            SkyblockAddons.getInstance().getUtils().setLastDamaged(System.currentTimeMillis());
        }
    }
}
 
Example #2
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 #3
Source File: DispenserBehaviourLingeringPotion.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public ItemStack dispense(IBlockSource block, final ItemStack stack) {
	return new BehaviorProjectileDispense() {

		@Override
		protected IProjectile getProjectileEntity(World world, IPosition pos) {
			return new EntityLingeringPotion(world, pos.getX(), pos.getY(), pos.getZ(), stack.copy());
		}

		@Override
		protected float func_82498_a() {
			return super.func_82498_a() * 0.5F;
		}

		@Override
		protected float func_82500_b() {
			return super.func_82500_b() * 1.25F;
		}
	}.dispense(block, stack);
}
 
Example #4
Source File: DispenserBehaviourTippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack dispenseStack(IBlockSource block, final ItemStack stack) {
	return new BehaviorProjectileDispense() {

		@Override
		protected IProjectile getProjectileEntity(World world, IPosition pos) {
			EntityTippedArrow entity = new EntityTippedArrow(world, pos.getX(), pos.getY(), pos.getZ());
			entity.canBePickedUp = 1;
			entity.setEffect(TippedArrow.getEffect(stack));
			return entity;
		}
	}.dispense(block, stack);
}
 
Example #5
Source File: BehaviorProjectileDispense.java    From Artifacts with MIT License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    World world = par1IBlockSource.getWorld();
    IPosition iposition = BlockTrap.getIPositionFromBlockSource(par1IBlockSource);
    EnumFacing enumfacing = BlockTrap.getFacing(par1IBlockSource.getBlockMetadata());
    IProjectile iprojectile = this.getProjectileEntity(world, iposition);
    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
    world.spawnEntityInWorld((Entity)iprojectile);
    //playDispenseSound(par1IBlockSource);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example #6
Source File: DispenserBehaviorArrow.java    From Artifacts with MIT License 5 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition)
{
    /*EntityArrow entityarrow = new EntityArrow(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ());
    entityarrow.canBePickedUp = 1;
    entityarrow.setDamage(6);
    return entityarrow;*/
	EntitySpecialArrow entityarrow = new EntitySpecialArrow(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ(), 2);
	entityarrow.canBePickedUp = 1;
	return entityarrow;
}
 
Example #7
Source File: PotionAchromatic.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void performEffect(EntityLivingBase entity, int p_76394_2_) {
    /*if(entity.boundingBox != null) {
        List<Entity> projectiles = entity.worldObj.getEntitiesWithinAABB(IProjectile.class, entity.boundingBox.expand(3, 3, 3));

        for(Entity e : projectiles) {
            AxisAlignedBB boundingBox = e.boundingBox != null ? e.boundingBox : AxisAlignedBB.getBoundingBox(e.posX, e.posY, e.posZ, e.posX, e.posY, e.posZ);
            if(entity.boundingBox.expand(1.5, 1.5, 1.5).intersectsWith(boundingBox)) {
                double pMaxDist = new Vector3(entity.boundingBox.minX, entity.boundingBox.minY, entity.boundingBox.minZ).distance(new Vector3(entity.boundingBox.maxX, entity.boundingBox.maxY, entity.boundingBox.maxZ));
                double eMaxDist = new Vector3(boundingBox.minX, boundingBox.minY, boundingBox.minZ).distance(new Vector3(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
                double timeoutDist = pMaxDist + eMaxDist*2 + 4.5;

                Vector3 vec = new Vector3(e.motionX, e.motionY, e.motionZ).normalize();
                float dist = 0;

                boolean success = false;
                boolean state = true;

                Vector3 temp;
                do {
                    temp = vec.clone().multiply(dist);
                    if(state) {
                        if(entity.boundingBox.intersectsWith(boundingBox.copy().offset(temp.getX(), temp.getY(), temp.getZ()))) {
                            state = false;
                        }
                    } else {
                        if(!entity.boundingBox.intersectsWith(boundingBox.copy().offset(temp.getX(), temp.getY(), temp.getZ()))) {
                            success = true;
                            break;
                        }
                    }
                    dist += 0.1;
                } while(dist < timeoutDist);

                temp = vec.clone().multiply(dist + 1.25);
                if(success) {
                    e.posX += temp.getX();
                    e.posY += temp.getY();
                    e.posZ += temp.getZ();
                }
            }
        }
    }*/

    List<Entity> projectiles = entity.worldObj.getEntitiesWithinAABB(IProjectile.class, AxisAlignedBB.getBoundingBox(entity.posX - 4.0D, entity.posY - 4.0D, entity.posZ - 4.0D, entity.posX + 3.0D, entity.posY + 3.0D, entity.posZ + 3.0D));
    for (Entity e : projectiles) {
        Vector3 motionVec = new Vector3(e.motionX, e.motionY, e.motionZ).normalize().multiply(Math.sqrt((e.posX - entity.posX) * (e.posX - entity.posX) + (e.posY - entity.posY) * (e.posY - entity.posY) + (e.posZ - entity.posZ) * (e.posZ - entity.posZ)) * 2.0D);
        e.posX += motionVec.getX();
        e.posY += motionVec.getY();
        e.posZ += motionVec.getZ();
    }
}
 
Example #8
Source File: DispenserBehaviorExperienceBottle.java    From Artifacts with MIT License 4 votes vote down vote up
protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition)
{
    return new EntityExpBottle(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ());
}
 
Example #9
Source File: DispenserBehaviorSnowball.java    From Artifacts with MIT License 4 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition)
{
    return new EntitySnowball(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ());
}
 
Example #10
Source File: DispenserBehaviorEgg.java    From Artifacts with MIT License 4 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition)
{
    return new EntityEgg(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ());
}
 
Example #11
Source File: DispenserBehaviorPotionProjectile.java    From Artifacts with MIT License 4 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition)
{
    return new EntityPotion(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ(), this.potionItemStack.copy());
}
 
Example #12
Source File: BehaviorProjectileDispense.java    From Artifacts with MIT License 2 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected abstract IProjectile getProjectileEntity(World world, IPosition iposition);