當前位置: 首頁>>代碼示例>>Java>>正文


Java DamageCause.LAVA屬性代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.LAVA屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.LAVA屬性的具體用法?Java DamageCause.LAVA怎麽用?Java DamageCause.LAVA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.event.entity.EntityDamageEvent.DamageCause的用法示例。


在下文中一共展示了DamageCause.LAVA屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemDamage

@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:26,代碼來源:EnvironmentManager.java

示例2: onEntityDamage

@EventHandler
public void onEntityDamage(final EntityDamageEvent event) {

	if (event.getCause() == DamageCause.DROWNING || event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.LAVA) {

		// Ok so an entity damage event begins
		// Find the nearest gate!
		final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation());
		final WorldCoord entityCoordUp = new WorldCoord(event.getEntity().getLocation().getBlock().getRelative(BlockFace.UP));
		final Gate nearestGate = GateUtil.nearestGate(entityCoord, false);
		final Gate nearestGateUp = GateUtil.nearestGate(entityCoordUp, false);

		if (nearestGate != null || nearestGateUp != null) {
			event.setCancelled(true);
			event.getEntity().setFireTicks(0);
		}
	}
}
 
開發者ID:NoChanceSD,項目名稱:AncientGates,代碼行數:18,代碼來源:PluginEntityListener.java

示例3: onEntityDamage

@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(EntityDamageEvent event)
{
	if (event.isCancelled() || event.getDamage() <= 0.0D)
		return;

	if (! bloodEffectEnabled || bloodEffectGunsOnly || bloodEffectType == null)
		return;

	Entity entity = event.getEntity();
	if (event.getEntity() instanceof LivingEntity)
	{
		if (entity instanceof Player)
		{
			if (((Player) entity).getGameMode() == GameMode.CREATIVE)
				return;
		}

		if (event.getCause() != DamageCause.DROWNING && event.getCause() != DamageCause.LAVA)
		{
			World world = entity.getWorld();
			world.playEffect(entity.getLocation(), Effect.STEP_SOUND, bloodEffectType);
			world.playEffect(entity.getLocation().add(0, 1, 0), Effect.STEP_SOUND, bloodEffectType);
		}
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornGuns,代碼行數:26,代碼來源:EntityListener.java

示例4: resolve

public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent.getCause() == DamageCause.LAVA) {
        return new SimpleLavaDamageInfo(null);
    }

    return null;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:8,代碼來源:LavaDamageResolver.java

示例5: onDamageGet

@EventHandler(priority=EventPriority.MONITOR)
public void onDamageGet(EntityDamageEvent e) {
	if (!e.isCancelled()) {
		if (e instanceof EntityDamageByEntityEvent) {
			if (((EntityDamageByEntityEvent) e).getDamager() instanceof Player && SlimefunStartup.chance(100, 45)) {
				if (SlimefunManager.isItemSimiliar(((Player) ((EntityDamageByEntityEvent) e).getDamager()).getInventory().getItemInMainHand(), SlimefunItem.getItem("BLADE_OF_VAMPIRES"), true)) {
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).playSound(((EntityDamageByEntityEvent) e).getDamager().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F);
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
				}
			}
		}
		if (e.getEntity() instanceof Player) {
			if (!e.isCancelled()) {
				if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItem.getByID("LAVA_TALISMAN"));
				if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItem.getByID("WATER_TALISMAN"));
				if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItem.getByID("ANGEL_TALISMAN"));
				if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItem.getByID("FIRE_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("WARRIOR_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("KNIGHT_TALISMAN"));
				if (e.getCause() == DamageCause.PROJECTILE) {
					if (Talisman.checkFor(e, SlimefunItem.getByID("WHIRLWIND_TALISMAN"))) {
						if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
							Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0);
							Projectile projectile = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), ((EntityDamageByEntityEvent) e).getDamager().getType());
							projectile.setVelocity(direction);
							((EntityDamageByEntityEvent) e).getDamager().remove();
						}
					}
				}
			}
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:33,代碼來源:TalismanListener.java

示例6: getBlockDamageCause

private static DamageCause getBlockDamageCause(Block block) {
    switch(block.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            return DamageCause.LAVA;

        case FIRE:
            return DamageCause.FIRE;

        default:
            return DamageCause.CONTACT;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:DisableDamageMatchModule.java

示例7: toBukkit

public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
	// TODO Direct mapping via DamageCause.valueOf?
	switch (nukkit) {
		case CONTACT:
			return DamageCause.CONTACT;
		case ENTITY_ATTACK:
			return DamageCause.ENTITY_ATTACK;
		case PROJECTILE:
			return DamageCause.PROJECTILE;
		case SUFFOCATION:
			return DamageCause.SUFFOCATION;
		case FALL:
			return DamageCause.FALL;
		case FIRE:
			return DamageCause.FIRE;
		case FIRE_TICK:
			return DamageCause.FIRE_TICK;
		case LAVA:
			return DamageCause.LAVA;
		case DROWNING:
			return DamageCause.DROWNING;
		case BLOCK_EXPLOSION:
			return DamageCause.BLOCK_EXPLOSION;
		case ENTITY_EXPLOSION:
			return DamageCause.ENTITY_EXPLOSION;
		case VOID:
			return DamageCause.VOID;
		case SUICIDE:
			return DamageCause.SUICIDE;
		case MAGIC:
			return DamageCause.MAGIC;
		case LIGHTNING:
			return DamageCause.LIGHTNING;
		case CUSTOM:
		default:
			return DamageCause.CUSTOM;
	}
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:38,代碼來源:PokkitDamageCause.java

示例8: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {
        if (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) {
            event.getEntity().setFireTicks(0);
        }
        if (event.getCause() != DamageCause.VOID) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:EyeOfEnder-Ltd,項目名稱:EOEHub,代碼行數:11,代碼來源:PlayerListener.java


注:本文中的org.bukkit.event.entity.EntityDamageEvent.DamageCause.LAVA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。