本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingFallEvent.setDamageMultiplier方法的典型用法代码示例。如果您正苦于以下问题:Java LivingFallEvent.setDamageMultiplier方法的具体用法?Java LivingFallEvent.setDamageMultiplier怎么用?Java LivingFallEvent.setDamageMultiplier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingFallEvent
的用法示例。
在下文中一共展示了LivingFallEvent.setDamageMultiplier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
}
示例2: 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);
}
}
示例3: onFallEvent
import net.minecraftforge.event.entity.living.LivingFallEvent; //导入方法依赖的package包/类
@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;
}
}