本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingFallEvent类的典型用法代码示例。如果您正苦于以下问题:Java LivingFallEvent类的具体用法?Java LivingFallEvent怎么用?Java LivingFallEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LivingFallEvent类属于net.minecraftforge.event.entity.living包,在下文中一共展示了LivingFallEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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();
}
}
示例2: onLivingFallEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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);
}
}
}
}
示例3: fallEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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;
}
}
示例4: entityfall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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!"));
}
}
}
}
示例5: onLivingFallEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
/** 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);
}
}
}
示例6: onFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
/**
* 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;
}
}
}
示例7: onFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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);
}
}
示例8: onFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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);
}
}
}
示例9: fall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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)));
}
示例10: fall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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));
}
}
}
示例11: onEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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;
}
}
}
示例12: onEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@Override
public void onEvent(LivingFallEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
if (!getPlayerSettings(player).falldamage) event.setCanceled(true);
}
}
示例13: onFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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;
// }
}
}
示例14: onFall
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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);
}
}
示例15: onFallEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入依赖的package包/类
@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;
}
}