Java 类net.minecraftforge.event.entity.living.LivingFallEvent 实例源码

项目:4Space-5    文件:EventHandlerGC.java   
@SubscribeEvent
public void onEntityFall(LivingFallEvent event)
{
    if (event.entityLiving instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        if (player.ridingEntity instanceof EntityAutoRocket || player.ridingEntity instanceof EntityLanderBase)
        {
            event.distance = 0.0F;
            event.setCanceled(true);
            return;
        }
    }

    if (event.entityLiving.worldObj.provider instanceof IGalacticraftWorldProvider)
    {
        event.distance *= ((IGalacticraftWorldProvider) event.entityLiving.worldObj.provider).getFallDamageModifier();
    }
}
项目:grapplemod    文件:LongFallBoots.java   
@SubscribeEvent
public void onLivingFallEvent(LivingFallEvent event)
{
    if (event.getEntity() != null && event.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer)event.getEntity();

        for (ItemStack armor : player.getArmorInventoryList()) {
            if (armor != null && armor.getItem() instanceof LongFallBoots)
            {
                // this cancels the fall event so you take no damage
                event.setCanceled(true);
            }
        }
    }
}
项目:GelsPlus    文件:EventHandler.java   
@SubscribeEvent
public void fallEvent(LivingFallEvent event) {
    if (event.entityLiving != null) {
        ItemStack boots;
        EntityLivingBase entity = event.entityLiving;

        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            boots = player.inventory.armorItemInSlot(0);
        } else
            boots = entity.getEquipmentInSlot(4);

        if (boots != null && boots.getItem() != null && boots.getItem() == ModItems.longfall)
            event.distance = 0;
    }
}
项目:NausicaaMod    文件:NausicaaEventHandler.java   
@SubscribeEvent
public void entityfall(LivingFallEvent event) {

    if (event.entityLiving instanceof EntityPlayer) {// make sure its a player
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        if (Main.debug) System.out.println(event.distance);

        if(MLib.doesPlayerHaveItems(player, LapMain.volucitePendant,LapMain.volucite,LapMain.voluciteNecklace, Item.getItemFromBlock(LapMain.voluciteBlock)))
            event.distance = 0;


        if (MLib.isPlayerHoldingItem(player, Main.glider)) {

            double yMotion = Math.abs(player.motionY);// get absolute value of y motion
            if (yMotion > .2) {// check how large motion is
                event.distance = (float) (yMotion) * 5; // then compute fall distance
                if (Main.debug) System.out.println("Fall dist: " + event.distance + "\nThrust: " + yMotion);// for debugging
            } else {
                event.distance = 0;// if small (less than .2 bloks per ____(tick?), set to none
                player.addChatMessage(new ChatComponentText("Perfect landing!"));
            }
        }

    }
}
项目:Narutocraft-PL_Mod    文件:NCEventHandler.java   
/** on Living Fall action */
@SubscribeEvent
public void onLivingFallEvent(LivingFallEvent event) {
    if (event.entity instanceof EntityPlayer) {
        ExtendedProperties props = ExtendedProperties.get((EntityPlayer) event.entity);
        if ((event.distance > 3.0F) && (props.getCurrentChakra() > 0)) {
            System.out.println("[EVENT] Fall distance: " + event.distance);
            System.out.println("[EVENT] Current chakra: " + props.getCurrentChakra());
            float reduceby = props.getCurrentChakra() < (event.distance - 3.0F)
                    ? props.getCurrentChakra()
                    : (event.distance - 3.0F);
            event.distance -= reduceby;
            props.consumeChakra((int) reduceby);
        }
    }
}
项目:ZeldaSwordSkills    文件:ZSSEntityEvents.java   
/**
 * NOTE: LivingFallEvent is not called in Creative mode, so must
 *      also listen for {@link PlayerFlyableFallEvent}
 * Should receive canceled to make sure LeapingBlow triggers/deactivates
 */
@SubscribeEvent(receiveCanceled=true)
public void onFall(LivingFallEvent event) {
    if (event.entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entity;
        ZSSPlayerInfo info = ZSSPlayerInfo.get(player);
        ZSSPlayerSkills skills = info.getPlayerSkills();
        if (skills.isSkillActive(SkillBase.leapingBlow)) {
            ((LeapingBlow) skills.getPlayerSkill(SkillBase.leapingBlow)).onImpact(player, event.distance);
        }

        if (!event.isCanceled() && info.reduceFallAmount > 0.0F) {
            event.distance -= info.reduceFallAmount;
            info.reduceFallAmount = 0.0F;
        }
    }
}
项目:OpenBlocks    文件:ExplosiveEnchantmentsHandler.java   
@SubscribeEvent
public void onFall(LivingFallEvent evt) {
    final Entity e = evt.getEntityLiving();
    if (evt.getDistance() > 4 && !e.isSneaking() && e instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer)e;

        EnchantmentLevel level = tryUseEnchantment(player, EntityEquipmentSlot.FEET);
        if (level == null) return;
        JumpInfo boost = new JumpInfo(level, evt.getDistance());
        level.createJumpExplosion(player);
        if (OpenMods.proxy.isClientPlayer(player)) {
            // And Now, Ladies and Gentlemen!
            // Logic Defying...
            // Loved By Everyone...
            // Possibly Buggy
            // TEEERRRRRIIIIBLE HAAAAAACK!
            KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindJump.getKeyCode(), true);
            // no, seriously, can't find better way to make jump
            jumpBoosts.put(player, boost);
        }
        evt.setCanceled(true);
    }
}
项目:Possessed    文件:ServerEventHandler.java   
@SubscribeEvent
public void onFall(LivingFallEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        PossessivePlayer possessivePlayer = PossessHandler.get((EntityPlayer) event.getEntityLiving());
        if (possessivePlayer != null) {
            possessivePlayer.getPossessing().fall(event.getDistance(), event.getDamageMultiplier());
            event.setCanceled(true);
        }
    }
}
项目:Wizardry    文件:PotionLowGrav.java   
@SubscribeEvent
public void fall(LivingFallEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (!entity.isPotionActive(this)) return;

    PotionEffect effect = entity.getActivePotionEffect(this);
    if (effect == null) return;

    event.setDistance((float) (event.getDistance() / (effect.getAmplifier() + 0.5)));
}
项目:Wizardry    文件:PotionCrash.java   
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void fall(LivingFallEvent e) {
    EntityLivingBase entitySource = e.getEntityLiving();
    PotionEffect crash = entitySource.getActivePotionEffect(this);
    if (crash == null) return;

    PotionEffect jump = entitySource.getActivePotionEffect(MobEffects.JUMP_BOOST);
    float f = (jump == null) ? 0.0f : (jump.getAmplifier() + 1);
    float damage = MathHelper.clamp((e.getDistance() - 3.0f - f) * e.getDamageMultiplier() * 2, 0, 10f);

    float range = damage / 10f + Math.max(crash.getAmplifier(), 5);

    if (damage > 0.0f) {
        e.setDamageMultiplier(e.getDamageMultiplier() / (crash.getAmplifier() + 2));
        List<EntityLivingBase> entities = entitySource.world.getEntitiesWithinAABB(EntityLivingBase.class, entitySource.getEntityBoundingBox().grow(range * 2));
        entities.stream().filter(entity -> entity != entitySource && entity.onGround).forEach(entity -> {
                entity.attackEntityFrom(damageSourceEarthquake(entitySource), range);
            entity.motionY = range / 10.0;
            entity.velocityChanged = true;
        });

        if (!entitySource.world.isRemote) for (BlockPos pos : BlockPos.getAllInBoxMutable(
                new BlockPos(entitySource.getPositionVector())
                        .add(-range,
                                -2,
                                -range),
                new BlockPos(entitySource.getPositionVector())
                        .add(range,
                                0,
                                range))) {
            IBlockState state = entitySource.world.getBlockState(pos);
            if (state.isFullCube()) entitySource.world.playEvent(2001, pos.toImmutable(), Block.getStateId(state));
        }
    }
}
项目:Wizardry    文件:PotionTimeSlow.java   
@SubscribeEvent
public void fall(LivingFallEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (!entity.isPotionActive(this)) return;

    PotionEffect effect = entity.getActivePotionEffect(this);
    if (effect == null) return;

    event.setDistance((float) (event.getDistance() / (effect.getAmplifier() + 0.5)));
}
项目:morecommands    文件:CommandFly.java   
@Override
public void onEvent(LivingFallEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
        ServerPlayerSettings settings = getPlayerSettings(player);

        if (settings.noFall) {event.setCanceled(true);}
        else if (settings.justDisabled) {
            event.setCanceled(true);
            settings.justDisabled = false;
        }
    }
}
项目:morecommands    文件:CommandFalldamage.java   
@Override
public void onEvent(LivingFallEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
        if (!getPlayerSettings(player).falldamage) event.setCanceled(true);
    }
}
项目:Kingdom-Keys-Re-Coded    文件:EntityEvents.java   
@SubscribeEvent
    public void onFall (LivingFallEvent event) {
        if (event.getEntityLiving() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getEntityLiving();
            DriveStateCapability.IDriveState DS = player.getCapability(ModCapabilities.DRIVE_STATE, null);
            if (DS.getInDrive())
                event.setDistance(0);

//            if(player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() == 0){
//                player.motionY=-0.001;
//            }
        }
    }
项目:Cyclic    文件:PotionBounce.java   
@SubscribeEvent
public void onFall(LivingFallEvent event) {
  EntityLivingBase entity = event.getEntityLiving();
  if (entity == null || entity instanceof EntityPlayer == false || entity.isSneaking()
      || entity.isPotionActive(this) == false) {
    return;
  }
  EntityPlayer player = (EntityPlayer) entity;
  if (event.getDistance() >= MIN_HEIGHT_START_BOUNCE) {
    event.setDamageMultiplier(0);
    if (entity.getEntityWorld().isRemote == false) {
      event.setCanceled(true); //nada serverside
    }
    else {
      UtilSound.playSound(player, player.getPosition(), SoundEvents.BLOCK_SLIME_FALL, SoundCategory.PLAYERS, UtilSound.VOLUME / event.getDistance());
      UtilParticle.spawnParticle(player.world, EnumParticleTypes.SLIME, player.getPosition());
      event.setDistance(0);// fall distance
      player.motionY *= -PERCENT_HEIGHT_BOUNCED;
      player.isAirBorne = true;
      player.onGround = false;
      //postpone until one tick later. otherwise there is vanilla code internally that says "ok you finished falldamage so motionY=0;"
      player.posY += 0.01;
      player.getEntityData().setInteger(NBT_TICK, player.ticksExisted + 1);
      player.getEntityData().setInteger(NBT_MOTIONY, (int) (player.motionY * 100f));
    }
  }
  else if (!entity.getEntityWorld().isRemote && entity.isSneaking()) {
    event.setDamageMultiplier(DAMAGE_REDUCTION);
  }
}
项目:FutureCraft    文件:CoreEventHandler.java   
@SubscribeEvent
public void onFallEvent(LivingFallEvent event) {
    //System.out.println("falling");
    WorldProvider provider = event.entityLiving.worldObj.provider;
    if (provider instanceof WorldProviderPlanet) {
        event.distance *= (float) ((WorldProviderPlanet)provider).getGravity() * 0.8;
    }
}
项目:grapplemod    文件:CommonProxyClass.java   
@SubscribeEvent
public void onLivingFallEvent(LivingFallEvent event)
{
    if (event.getEntity() != null && grapplemod.attached.contains(event.getEntity().getEntityId()))
    {
        event.setCanceled(true);
    }
}
项目:Progression    文件:RewardFallDamage.java   
@SubscribeEvent
public void onLivingUpdate(LivingFallEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        int damage = (int) (event.getDistance() - 3);
        int maxAbsorbed = PlayerTracker.getPlayerData(player).getAbilities().getFallDamagePrevention();
        if (damage < maxAbsorbed) {
            event.setCanceled(true);
        } else {
            event.setDistance(event.getDistance() - maxAbsorbed);
        }
    }
}
项目:AdvancedRocketry    文件:PlanetEventHandler.java   
@SubscribeEvent
public void fallEvent(LivingFallEvent event) {
    if(event.entity.worldObj.provider instanceof IPlanetaryProvider) {
        IPlanetaryProvider planet = (IPlanetaryProvider)event.entity.worldObj.provider;
        event.distance *= planet.getGravitationalMultiplier((int)event.entity.posX, (int)event.entity.posZ);
    }
}
项目:Minecraft-Modding    文件:ExoHandler.java   
@SubscribeEvent
public void absorbFall(LivingFallEvent event)
{
    if (event.entityLiving.getCurrentArmor(3) == null) return;
    if (event.entityLiving.getCurrentArmor(3).getItem() instanceof Exoskeleton) {
        event.setCanceled(true);
    }
}
项目:parachute    文件:PlayerFallEvent.java   
@SuppressWarnings("unused")
    @SubscribeEvent
    public void onFallEvent(LivingFallEvent event) {
        if (event.getEntityLiving() instanceof EntityPlayer && isDismounting) { //ConfigHandler.isDismounting()) {
            event.setCanceled(true);
            event.setDistance(0.0f);
            event.setDamageMultiplier(0.0f);
//            ConfigHandler.setIsDismounting(false);
            isDismounting = false;
        }
    }
项目:NightfallMod    文件:ProjectZEventHandler.java   
/** for falling-will make more visible the faster you fall */
@SubscribeEvent
public void entityfall(LivingFallEvent event) {

    if (event.entityLiving instanceof EntityPlayer) {// make sure its a player
        //this.alterVisibility((EntityPlayer)event.entityLiving, .4);

        ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) event.entityLiving);
        // props.changeMana(-4);
        // System.out.println(props.getInsanity()+"++4"+((EntityPlayer) event.entityLiving).getCommandSenderName()+" is the name");
    }
}
项目:McMod-CheatStar    文件:EventItemSuperStar.java   
@SubscribeEvent
public void fall(LivingFallEvent event)
{
    if(!shouldCancelled(event.entityLiving))
    {
        return;
    }

    event.setCanceled(true);
}
项目:Mankini    文件:ItemBatMankini.java   
@SubscribeEvent
   public void PlayerFall(LivingFallEvent event)
{   
    if(event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        event.distance = 0F;
    }

    }
项目:Mankini    文件:BatMankiniJump.java   
@SubscribeEvent
   public void PlayerFall(LivingFallEvent event)
{   
    if(event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        event.distance = 0F;
    }

    }
项目:NausicaaMod    文件:NPlayerHandler.java   
@SubscribeEvent
public void livingFall (LivingFallEvent evt) // Only for negating fall damage
{
    if (evt.entityLiving instanceof EntityPlayer)
    {
        if(((EntityPlayer)evt.entityLiving).inventory.hasItemStack(new ItemStack(LapMain.volucite)))
            evt.distance = 0;
    }
}
项目:MineCraft    文件:WallClimber.java   
@SubscribeEvent
public void negateFallDamage(LivingFallEvent event) {
    if (!(event.getEntity() instanceof EntityPlayer)) {
        return;
    }

    event.setCanceled(true);
}
项目:Blockbender    文件:ForgeListener.java   
@SubscribeEvent
public void cancelFallDamage(LivingFallEvent evt)
{
    if (evt.entityLiving != null) {
        ItemStack held = evt.entityLiving.getHeldItem();
        if ((held != null) && (held.getItem() instanceof ItemGlider))
            evt.distance = 1.1F;
    }
}
项目:CubesEdge    文件:MovementRoll.java   
@SubscribeEvent
public void onFall(LivingFallEvent event) {
    if (event.entityLiving instanceof EntityPlayer
            && ((EntityPlayerCustom)event.entityLiving.getExtendedProperties("Cube's Edge Player")).isRolling) {
        event.distance = 0;
    }
}
项目:Zombie-Total-Conversion-Craft    文件:PlayerManager.java   
@SuppressWarnings("unused")
@SubscribeEvent
public void onLivingFall(LivingFallEvent event) {
    if(event.distance > 3 && EntityPlayer.class.isAssignableFrom(event.entityLiving.getClass())) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 15, 3));
        ZombieTCPlayerProperties playerProperties = ZombieTCPlayerProperties.get(player);
        playerProperties.timeSinceHit = 0;
    }
}
项目:ModTutoriel17    文件:LivingEventHandler.java   
@SubscribeEvent
public void onLivingFall(LivingFallEvent event)
{
    ItemStack boots = event.entityLiving.getEquipmentInSlot(1); // récupère les bottes
    if(boots != null && boots.getItem() == ModTutoriel.bootsTuto)  // on vérifie que l'entité à des bottes avec le null check puis si elle a des bottes, on vérifie si c'est les bottes tuto
    {
        boots.damageItem(MathHelper.floor_float(event.distance), event.entityLiving); // on endommage les bottes en fonction de la puissance de la chute
        event.distance = 0F; // on défini la distance à 0 pour pas que l'entité prenne de dégât
        if(boots.stackSize == 0)  // si le stack size est de 0 (donc que les bottes ont cassées)
        {
            event.entityLiving.setCurrentItemOrArmor(1, null); // on met un item null au niveau des bottes, c'est pour évite un bug d'affichage
        }
    }
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier);
    return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()});
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooks.java   
public static float onLivingFall(EntityLivingBase entity, float distance)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance);
    return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
}
项目:CauldronGit    文件:ForgeHooks.java   
public static float onLivingFall(EntityLivingBase entity, float distance)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance);
    return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
public void onFall(LivingFallEvent event)
{

}
项目:Aura-Cascade    文件:AuraTilePumpFall.java   
public void onFall(LivingFallEvent event) {
    addFuel((int) (Config.pumpFallDuration * event.getDistance()), Config.pumpFallSpeed);
}
项目:AdventureBackpack2    文件:PlayerEventHandler.java   
/**
 * Used by the Piston boots to lessen the fall damage. It's hacky, but I don't care.
 *
 * @param event
 */
@SubscribeEvent
public void onFall(LivingFallEvent event)
{
    if (event.entity != null)
    {
        if (event.entityLiving instanceof EntityCreature && ConfigHandler.FIX_LEAD)
        {
            EntityCreature creature = (EntityCreature) event.entityLiving;
            if (creature.getLeashed() && creature.getLeashedToEntity() != null && creature.getLeashedToEntity() instanceof EntityPlayer)
            {
                EntityPlayer player = (EntityPlayer) creature.getLeashedToEntity();
                if (creature.motionY > -2.0f && player.motionY > -2.0f)
                {
                    event.setCanceled(true);
                }
            }
        }

        if (event.entityLiving instanceof EntityFriendlySpider)
        {
            if (((EntityFriendlySpider) event.entityLiving).riddenByEntity != null
                    && ((EntityFriendlySpider) event.entityLiving).riddenByEntity instanceof EntityPlayer
                    && event.distance < 5)
            {
                event.setCanceled(true);
            }
        }

        if (event.entityLiving instanceof EntityPlayer)
        {
            if (Wearing.isWearingBoots(((EntityPlayer) event.entityLiving)) && event.distance < 8)
            {
                event.setCanceled(true);
            }
            if(Wearing.isWearingTheRightBackpack((EntityPlayer)event.entityLiving,"IronGolem") && ConfigHandler.BACKPACK_ABILITIES)
            {
                event.setCanceled(true);
            }
        }
    }
}
项目:Cauldron    文件:ForgeHooks.java   
public static float onLivingFall(EntityLivingBase entity, float distance)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance);
    return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
}
项目:Cauldron    文件:ForgeHooks.java   
public static float onLivingFall(EntityLivingBase entity, float distance)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance);
    return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
}
项目:Cauldron    文件:ForgeHooks.java   
public static float onLivingFall(EntityLivingBase entity, float distance)
{
    LivingFallEvent event = new LivingFallEvent(entity, distance);
    return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
}