Java Code Examples for net.minecraft.entity.IProjectile

The following are top voted examples for showing how to use net.minecraft.entity.IProjectile. 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: connor41-etfuturum2   File: DispenserBehaviourLingeringPotion.java   Source Code and License 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 2
Project: Factorization   File: BlowEntities.java   Source Code and License 6 votes vote down vote up
@Override
public boolean apply(Entity entity) {
    if (entity instanceof EntityItem) {
        return true;
    }
    if (target_speed <= 1) {
        return false;
    }
    if (entity instanceof EntityLiving || entity instanceof IProjectile || entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) {
        return true;
    }
    if (FzConfig.fanturpeller_works_on_players && entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        found_player = true;
        return !player.capabilities.isCreativeMode && !player.isSneaking();
    }
    return false;
    // Falling sand doesn't work too well with this
    // Minecarts seem to just jump back down (and would be too heavy anyways.)
    // Let's try to keep this method light, hmm?
}
 
Example 3
Project: Et-Futurum   File: DispenserBehaviourLingeringPotion.java   Source Code and License 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
Project: AdvancedPotions   File: BehaviorAdvancedProjectileDispense.java   Source Code and License 6 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 = BlockDispenser.func_149939_a(par1IBlockSource);
    EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
    ItemStack stack = par2ItemStack.splitStack(1);
    if (matchesItem(par2ItemStack)) {
        // dispense item as projectile because the item matches
        IProjectile iprojectile = this.getProjectileEntity(world, iposition, par2ItemStack);
        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);
    } else {
        // dispense item as item because it doesn't match
        BehaviorDefaultDispenseItem.doDispense(world, stack, 6, enumfacing, iposition);
    }
    return par2ItemStack;
}
 
Example 5
Project: MineFantasy   File: DispenseBombMF.java   Source Code and License 6 votes vote down vote up
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  {
float y = 1.1F;
      World var3 = source.getWorld();
      IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
      EnumFacing var5 = BlockDispenser.getFacing(source.getBlockMetadata());
      
      IProjectile var6 = this.getProjectileEntity(var3, var4, stack.getItemDamage());
      if(var6 != null)
      {
      	var6.setThrowableHeading((double)var5.getFrontOffsetX(), 0.10000000149011612D*y, (double)var5.getFrontOffsetY(), this.func_82500_b(), this.func_82498_a());
      	var3.spawnEntityInWorld((Entity)var6);
      	stack.splitStack(1);
      }
      return stack;
  }
 
Example 6
Project: MineFantasy   File: DispenseArrowMF.java   Source Code and License 6 votes vote down vote up
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  {
float y = 1.1F;
      World var3 = source.getWorld();
      IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
      EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
      
      IProjectile iprojectile = this.getProjectileEntity(var3, var4, stack.getItemDamage());
      if(iprojectile != null)
      {
      	iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
      	var3.spawnEntityInWorld((Entity)iprojectile);
      	stack.splitStack(1);
      }
      return stack;
  }
 
Example 7
Project: MineFantasy   File: DispenseBoltMF.java   Source Code and License 6 votes vote down vote up
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  {
float y = 1.1F;
      World var3 = source.getWorld();
      IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
      EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
      
      IProjectile iprojectile = this.getProjectileEntity(var3, var4, stack.getItemDamage());
      if(iprojectile != null)
      {
      	iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
      	var3.spawnEntityInWorld((Entity)iprojectile);
      	stack.splitStack(1);
      }
      return stack;
  }
 
Example 8
Project: BaseClient   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = BlockDispenser.getFacing(source.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);
    stack.splitStack(1);
    return stack;
}
 
Example 9
Project: BaseClient   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = BlockDispenser.getFacing(source.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);
    stack.splitStack(1);
    return stack;
}
 
Example 10
Project: connor41-etfuturum2   File: DispenserBehaviourTippedArrow.java   Source Code and License 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 11
Project: Backmemed   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    IProjectile iprojectile = this.getProjectileEntity(world, iposition, stack);
    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.getProjectileVelocity(), this.getProjectileInaccuracy());
    world.spawnEntityInWorld((Entity)iprojectile);
    stack.func_190918_g(1);
    return stack;
}
 
Example 12
Project: CustomWorldGen   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    IProjectile iprojectile = this.getProjectileEntity(world, iposition, stack);
    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.getProjectileVelocity(), this.getProjectileInaccuracy());
    world.spawnEntityInWorld((Entity)iprojectile);
    stack.splitStack(1);
    return stack;
}
 
Example 13
Project: AdvancedCombat   File: TrackingDispenserBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
       World world = source.getWorld();
       BlockPos pos = source.getBlockPos();
       Vec3d pos2 = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
       Vec3d dir = this.getNearestTargetDirection(world, pos);
       if(dir == null) return null;
       IPosition ipos = new PositionImpl(pos2.x + dir.x * .75, pos2.y + dir.y * .75, pos2.z + dir.z * .75);
       IProjectile iproj = this.getProjectileEntity(standard, world, ipos, stack);
       iproj.shoot(dir.x, dir.y + 0.1F, dir.z, 
       		this.getProjectileVelocity(standard), this.getProjectileInaccuracy(standard));
       world.spawnEntity((Entity)iproj);
       stack.splitStack(1);
       return stack;
}
 
Example 14
Project: AdvancedCombat   File: TrackingDispenserBehavior.java   Source Code and License 5 votes vote down vote up
/** Get the projectile entity via reflection */
private IProjectile getProjectileEntity(BehaviorProjectileDispense standard, World world, IPosition pos, ItemStack stack) {
	Method m = ACUtils.findMethod(BehaviorProjectileDispense.class, standard, new String[]{"getProjectileEntity", "func_82499_a"}, 
			World.class, IPosition.class, ItemStack.class);
	try {
		return (IProjectile)m.invoke(standard, world, pos, stack);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 15
Project: Overlord   File: Overlord.java   Source Code and License 5 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
	AugmentRegistry.registerAugment(new ItemStack(Items.GOLDEN_APPLE), new AugmentSlowRegen());
	AugmentRegistry.registerAugment(new ItemStack(Items.GOLDEN_APPLE, 1, 1), new AugmentFastRegen());
	AugmentRegistry.registerAugment(new ItemStack(Items.IRON_INGOT), new AugmentIron());
	AugmentRegistry.registerAugment(new ItemStack(Blocks.OBSIDIAN), new AugmentObsidian());
	AugmentRegistry.registerAugment(new ItemStack(Blocks.ANVIL), new AugmentAnvil());
	AugmentRegistry.registerAugment(new ItemStack(Items.SKULL, 1, 1), new AugmentWither());
	AugmentRegistry.registerAugment(new ItemStack(Items.SUGAR), new AugmentJitters());
	AugmentRegistry.registerAugment(new ItemStack(skinsuit_mummy), new AugmentMummy());

	OreDictionary.registerOre("book", squad_editor);

	MilkRegistry.getInstance().registerMilk(new ItemStack(Items.MILK_BUCKET), new ItemStack(Items.BUCKET));
	MilkRegistry.getInstance().registerMilk(new ItemStack(milk_bottle), new ItemStack(Items.GLASS_BOTTLE));

	BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(keychain_occupied, new DispenseBehaviorKeychain());
	BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(milk_bottle, new BehaviorProjectileDispense() {
		@Override
		@Nonnull
		protected IProjectile getProjectileEntity(@Nonnull World worldIn, @Nonnull IPosition position, @Nonnull ItemStack stackIn) {
			return new EntityMilkBottle(worldIn, position.getX(), position.getY(), position.getZ());
		}
	});

	if (Loader.isModLoaded("ic2")) {
		modCompat = new IC2Compat();
		modCompat.init(event);
	}
}
 
Example 16
Project: Alchemy   File: EntityProjectileTracker.java   Source Code and License 5 votes vote down vote up
public static <T extends Entity & IProjectile> void track(T entity, Entity target) {
	double dx = target.posX - entity.posX;
	double dy = target.getEntityBoundingBox().minY + target.height / 3 - entity.posY;
	double dz = target.posZ - entity.posZ;
	double dr = sqrt(dx * dx + dz * dz);
	entity.setThrowableHeading(dx, dy + dr * 0.2, dz, 1.6F, 2);
}
 
Example 17
Project: Et-Futurum   File: DispenserBehaviourTippedArrow.java   Source Code and License 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 18
Project: ARKCraft-Code   File: EntityARKCreature.java   Source Code and License 5 votes vote down vote up
@Override
public void onDeath(DamageSource cause)
{
	super.onDeath(cause);

	Entity killedBy = cause.getSourceOfDamage();
	Entity indirect = cause.getEntity();

	Entity actualKiller;

	if (indirect != null && killedBy instanceof IProjectile)
	{
		actualKiller = indirect;
	}
	else
	{
		actualKiller = killedBy;
	}

	// TODO grant xp if creature is ridden (possible to kill while ridden)
	// TODO grant xp to owner nearby
	if (actualKiller instanceof EntityARKCreature)
	{
		if (((EntityARKCreature) killedBy)
				.isOwned()) ((EntityARKCreature) killedBy).addXP(creature.getBaseKillXP());
	}
	else if (actualKiller instanceof EntityPlayer)
	{
		ARKPlayer data = ARKPlayer.get((EntityPlayer) actualKiller);
		data.addXP(getKillXP());
	}
}
 
Example 19
Project: ARKCraft-Code   File: DispenseWeaponProjectile.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{
    World world = blocksource.getWorld();
    IPosition pos = BlockDispenser.getDispensePosition(blocksource);
    EnumFacing face = BlockDispenser.getFacing(blocksource.getBlockMetadata());
    IProjectile projectile = getProjectileEntity(world, pos, itemstack);
    projectile.setThrowableHeading(face.getFrontOffsetX(), face.getFrontOffsetY() + getYVel(), face.getFrontOffsetZ(), getVelocity(), getDeviation());
    world.spawnEntityInWorld((Entity) projectile);
    itemstack.splitStack(1);
    return itemstack;
}
 
Example 20
Project: Resilience-Client-Source   File: BehaviorProjectileDispense.java   Source Code and 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 var3 = par1IBlockSource.getWorld();
    IPosition var4 = BlockDispenser.func_149939_a(par1IBlockSource);
    EnumFacing var5 = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
    IProjectile var6 = this.getProjectileEntity(var3, var4);
    var6.setThrowableHeading((double)var5.getFrontOffsetX(), (double)((float)var5.getFrontOffsetY() + 0.1F), (double)var5.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
    var3.spawnEntityInWorld((Entity)var6);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 21
Project: MineFantasy   File: DispenseArrowMF.java   Source Code and License 5 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World world, IPosition pos, int meta)
{
	EntityArrowMF arrow = new EntityArrowMF(world, pos.getX(), pos.getY(), pos.getZ(), meta);
	
	arrow.canBePickedUp = 1;
	return arrow;
}
 
Example 22
Project: MineFantasy   File: DispenseBoltMF.java   Source Code and License 5 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World world, IPosition pos, int meta)
{
	EntityBoltMF bolt = new EntityBoltMF(world, pos.getX(), pos.getY(), pos.getZ(), meta);
	bolt.canBePickedUp = 1;
	return bolt;
}
 
Example 23
Project: ExpandedRailsMod   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = (EnumFacing)source.func_189992_e().getValue(BlockDispenser.FACING);
    IProjectile iprojectile = this.getProjectileEntity(world, iposition, stack);
    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.getProjectileVelocity(), this.getProjectileInaccuracy());
    world.spawnEntityInWorld((Entity)iprojectile);
    stack.splitStack(1);
    return stack;
}
 
Example 24
Project: balkons-weaponmod   File: DispenseWeaponProjectile.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{
	World world = blocksource.getWorld();
	IPosition pos = BlockDispenser.func_149939_a(blocksource);
	EnumFacing face = BlockDispenser.func_149937_b(blocksource.getBlockMetadata());
	IProjectile projectile = getProjectileEntity(world, pos, itemstack);
	projectile.setThrowableHeading(face.getFrontOffsetX(), face.getFrontOffsetY() + getYVel(), face.getFrontOffsetZ(), getVelocity(), getDeviation());
	world.spawnEntityInWorld((Entity) projectile);
	itemstack.splitStack(1);
	return itemstack;
}
 
Example 25
Project: balkons-weaponmod   File: DispenseBlowgunDart.java   Source Code and License 5 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos, ItemStack itemstack)
{
	EntityBlowgunDart dart = (EntityBlowgunDart) getProjectileEntity(world, pos);
	dart.setDartEffectType(itemstack.getItemDamage());
	return dart;
}
 
Example 26
Project: Cauldron   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_)
{
    World world = p_82487_1_.getWorld();
    IPosition iposition = BlockDispenser.func_149939_a(p_82487_1_);
    EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.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);
    p_82487_2_.splitStack(1);
    return p_82487_2_;
}
 
Example 27
Project: ZeldaSwordSkills   File: ItemZeldaShield.java   Source Code and License 5 votes vote down vote up
@Method(modid="battlegear2")
@Override
public boolean catchArrow(ItemStack shield, EntityPlayer player, IProjectile projectile) {
	if (toolMaterial == ToolMaterial.WOOD && projectile instanceof EntityArrow){
		setArrowCount(shield, getArrowCount(shield) + 1);
		player.setArrowCountInEntity(player.getArrowCountInEntity() - 1);
		((EntityArrow) projectile).setDead();
		return true;
	}
	return false;
}
 
Example 28
Project: RuneCraftery   File: BehaviorProjectileDispense.java   Source Code and License 5 votes vote down vote up
public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
   World var3 = p_82487_1_.func_82618_k();
   IPosition var4 = BlockDispenser.func_82525_a(p_82487_1_);
   EnumFacing var5 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h());
   IProjectile var6 = this.func_82499_a(var3, var4);
   var6.func_70186_c((double)var5.func_82601_c(), (double)((float)var5.func_96559_d() + 0.1F), (double)var5.func_82599_e(), this.func_82500_b(), this.func_82498_a());
   var3.func_72838_d((Entity)var6);
   p_82487_2_.func_77979_a(1);
   return p_82487_2_;
}
 
Example 29
Project: RuneCraftery   File: BehaviorProjectileDispense.java   Source Code and 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 = BlockDispenser.getIPositionFromBlockSource(par1IBlockSource);
    EnumFacing enumfacing = BlockDispenser.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);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 30
Project: RuneCraftery   File: DispenserBehaviorArrow.java   Source Code and 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;
    return entityarrow;
}
 
Example 31
Project: MyEssentials-Core   File: EntityUtils.java   Source Code and License 5 votes vote down vote up
private static String getEntityTypeNonCache(Entity e) {
	if (e instanceof EntityGolem) {
        return "Golem";
    } else if (e instanceof IBossDisplayData) {
    	return "Boss";
    } else if (e instanceof IAnimals) {
    	return "Animal";
    } else if (e instanceof IMob) {
    	return "Monster";
    } else if (e instanceof IProjectile) {
    	return "Projectile";
    } else if (e instanceof INpc) {
    	return "NPC";
    } else if (e instanceof EntityItem) {
    	return "Item";
    } else if (e instanceof EntityMob) {
    	return "Monster";
    } else if (e instanceof EntityPlayer) {
    	return "Player";
    } else if (e instanceof EntityFireball) {
    	return "Projectile";
    } else if (e instanceof EntityTNTPrimed) {
    	return "TNT";
    } else {
    	return "Unknown"; // e.getClass().getName();
    }
}
 
Example 32
Project: Battlegear2   File: ItemShield.java   Source Code and License 5 votes vote down vote up
@Override
public boolean catchArrow(ItemStack shield, EntityPlayer player, IProjectile arrow){
    if(arrow instanceof EntityArrow){
        setArrowCount(shield, getArrowCount(shield)+1);
        player.setArrowCountInEntity(player.getArrowCountInEntity() - 1);
        ((EntityArrow)arrow).setDead();
        return true;
    }
    return false;
}
 
Example 33
Project: BetterNutritionMod   File: BehaviorProjectileDispense.java   Source Code and 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 = BlockDispenser.getIPositionFromBlockSource(par1IBlockSource);
    EnumFacing enumfacing = BlockDispenser.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);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 34
Project: BetterNutritionMod   File: DispenserBehaviorArrow.java   Source Code and 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;
    return entityarrow;
}
 
Example 35
Project: CodeLyokoMod   File: EventHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
    Entity ent = event.entity;
    if (!(ent instanceof EntityPlayer || ent instanceof EntityLyoko || ent instanceof EntitySpecter || ent instanceof IProjectile || ent instanceof EntityVehicle))
        if (CodeLyoko.entityInLyoko(ent))
            event.setCanceled(true);
}
 
Example 36
Project: Artifacts   File: BehaviorProjectileDispense.java   Source Code and 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 37
Project: Artifacts   File: DispenserBehaviorArrow.java   Source Code and 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 38
Project: Mods   File: EntityAIAirblast.java   Source Code and License 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void updateTask() {
	// System.out.println("executing
	// "+TF2ActionHandler.playerAction.server.get(host));
	boolean easier = host.world.getDifficulty() == EnumDifficulty.NORMAL;
	delay--;
	if (delay > 0 || this.host.getRNG().nextFloat() > (easier ? 0.22f : 0.28f)) {
		host.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 5;// System.out.println("reset:");
		return;
	}
	Vec3d eyeVec = new Vec3d(host.posX, host.posY + host.getEyeHeight(), host.posZ);
	List<Entity> list = host.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(eyeVec.x - 5,
			eyeVec.y - 5, eyeVec.z - 5, eyeVec.x + 5, eyeVec.y + 5, eyeVec.z + 5));
	boolean airblast = false;
	for (Entity entity : list)
		// System.out.println(entity+"
		// "+ItemFlameThrower.isPushable(host,entity));
		if (ItemFlameThrower.isPushable(host, entity)
				&& (entity instanceof EntityThrowable || entity instanceof IProjectile)) {
			// System.out.println(entity);
			// System.out.println("dystans:
			// "+(entity.getDistanceSq(host.posX, host.posY +
			// (double)host.getEyeHeight(), host.posZ)<25));
			// System.out.println(TF2weapons.getTeam(entity)+"
			// "+TF2weapons.getTeam(host));
			airblast = entity.getDistanceSq(host.posX, host.posY + host.getEyeHeight(),
					host.posZ) < (easier ? 16 : 25)
					&& TF2Util.lookingAt(host, (easier ? 40 : 60), entity.posX, entity.posY + entity.height / 2,
							entity.posZ);
			if (airblast)
				break;
		}

	if (airblast) {
		// System.out.println("airblast:");
		((ItemFlameThrower) this.host.getHeldItemMainhand().getItem()).altUse(this.host.getHeldItemMainhand(), host,
				this.host.world);
		this.delay = easier ? 30 : 18;
	} else
		host.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 5;
}
 
Example 39
Project: Engination   File: ItemTomato.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition position, ItemStack stackIn) {
	return new EntityTomato(world, position.getX(), position.getY(), position.getZ());
}
 
Example 40
Project: Cyclic   File: BehaviorProjectileThrowable.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) {
  EntityThrowableDispensable thrown = throwable.getThrownEntity(worldIn, position.getX(), position.getY(), position.getZ());
  return thrown;
}
 
Example 41
Project: Minestrappolation-4   File: DispenserIceBall.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition pos)
{
	return new EntityIceball(worldIn, pos.getX(), pos.getY(), pos.getZ(), 0, 0, 0.1);
}
 
Example 42
Project: Minestrappolation-4   File: DispenserMudBall.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World worldIn, IPosition pos)
{
	return new EntityMudBall(worldIn, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 43
Project: ARKCraft-Code   File: DispenseRocketPropelledGrenade.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	// TODO
	return new EntityRocketPropelledGrenade(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 44
Project: ARKCraft-Code   File: DispenseSimpleRifleAmmo.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
    return new EntitySimpleRifleAmmo(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 45
Project: ARKCraft-Code   File: DispenseWeaponProjectile.java   Source Code and License 4 votes vote down vote up
protected IProjectile getProjectileEntity(World world, IPosition pos, ItemStack itemstack)
{
    return getProjectileEntity(world, pos);
}
 
Example 46
Project: ARKCraft-Code   File: DispenseTranquilizer.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
    return new EntityTranquilizer(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 47
Project: ARKCraft-Code   File: DispenseSimpleBullet.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
    return new EntitySimpleBullet(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 48
Project: Gadomancy   File: PotionAchromatic.java   Source Code and License 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 49
Project: AdvancedPotions   File: BehaviorCapsuleDispense.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos, ItemStack stack) {
    EntityThrownCapsule capsule = new EntityThrownCapsule(world, stack);
    capsule.setPosition(pos.getX(), pos.getY(), pos.getZ());
    return capsule;
}
 
Example 50
Project: MineFantasy   File: DispenseBombMF.java   Source Code and License 4 votes vote down vote up
/**
 * Return the projectile entity spawned by this dispense behavior.
 */
protected IProjectile getProjectileEntity(World world, IPosition pos, int type)
{
	EntityBombThrown bomb = new EntityBombThrown(world, pos.getX(), pos.getY(), pos.getZ(), 20).setID(type);
	return bomb;
}
 
Example 51
Project: MineFantasy   File: DispenseBombMF.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World var1, IPosition var2) {
	return getProjectileEntity(var1, var2, 0);
}
 
Example 52
Project: MineFantasy   File: DispenseArrowMF.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World var1, IPosition var2)
{
	return getProjectileEntity(var1, var2, 0);
}
 
Example 53
Project: MineFantasy   File: DispenseBoltMF.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World var1, IPosition var2)
{
	return getProjectileEntity(var1, var2, 0);
}
 
Example 54
Project: balkons-weaponmod   File: DispenseCrossbowBolt.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	return new EntityCrossbowBolt(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 55
Project: balkons-weaponmod   File: DispenseMusketBullet.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	return new EntityMusketBullet(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 56
Project: balkons-weaponmod   File: DispenseJavelin.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	return new EntityJavelin(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 57
Project: balkons-weaponmod   File: DispenseWeaponProjectile.java   Source Code and License 4 votes vote down vote up
protected IProjectile getProjectileEntity(World world, IPosition pos, ItemStack itemstack)
{
	return getProjectileEntity(world, pos);
}
 
Example 58
Project: balkons-weaponmod   File: DispenseBlowgunDart.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	return new EntityBlowgunDart(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 59
Project: balkons-weaponmod   File: DispenseDynamite.java   Source Code and License 4 votes vote down vote up
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos)
{
	return new EntityDynamite(world, pos.getX(), pos.getY(), pos.getZ());
}
 
Example 60
Project: Cauldron   File: BehaviorProjectileDispense.java   Source Code and License 4 votes vote down vote up
public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_)
{
    World world = p_82487_1_.getWorld();
    IPosition iposition = BlockDispenser.func_149939_a(p_82487_1_);
    EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata());
    IProjectile iprojectile = this.getProjectileEntity(world, iposition);
    // CraftBukkit start
    ItemStack itemstack1 = p_82487_2_.splitStack(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(p_82487_1_.getXInt(), p_82487_1_.getYInt(), p_82487_1_.getZInt());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getFrontOffsetX(), (double)((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ()));

    if (!BlockDispenser.eventFired)
    {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled())
    {
        p_82487_2_.stackSize++;
        return p_82487_2_;
    }

    if (!event.getItem().equals(craftItem))
    {
        p_82487_2_.stackSize++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IBehaviorDispenseItem ibehaviordispenseitem = (IBehaviorDispenseItem) BlockDispenser.dispenseBehaviorRegistry.getObject(eventStack.getItem());

        if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider && ibehaviordispenseitem != this)
        {
            ibehaviordispenseitem.dispense(p_82487_1_, eventStack);
            return p_82487_2_;
        }
    }

    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
    ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) p_82487_1_.getBlockTileEntity());
    // CraftBukkit end
    world.spawnEntityInWorld((Entity)iprojectile);
    // p_82487_2_.splitStack(1); // CraftBukkit - Handled during event processing
    return p_82487_2_;
}