@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); }
@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? }
/** * 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; }
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; }
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; }
/** * 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; }
@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); }
/** * 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; }
/** * 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; }
@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; }
/** 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; } }
@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); } }
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); }
@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()); } }
@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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
@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; }
@Override protected IProjectile getProjectileEntity(World world, IPosition pos, ItemStack itemstack) { EntityBlowgunDart dart = (EntityBlowgunDart) getProjectileEntity(world, pos); dart.setDartEffectType(itemstack.getItemDamage()); return dart; }
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_; }
@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; }
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_; }
/** * 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; }
/** * 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; }
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(); } }
@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; }
@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); }
/** * 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; }
/** * 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; }
@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; }