• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ExperienceOrb类的典型用法和代码示例

java 13次浏览

本文整理汇总了Java中org.bukkit.entity.ExperienceOrb的典型用法代码示例。如果您正苦于以下问题:Java ExperienceOrb类的具体用法?Java ExperienceOrb怎么用?Java ExperienceOrb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ExperienceOrb类属于org.bukkit.entity包,在下文中一共展示了ExperienceOrb类的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

点赞 3

import org.bukkit.entity.ExperienceOrb; //导入依赖的package包/类
public void run(){
    switch (rain){
        case EXP:
            locs.forEach(l -> {
                experienceOrb = (ExperienceOrb)l.getWorld().spawnEntity(l, EntityType.EXPERIENCE_ORB);
                experienceOrb.setExperience(levels);
            });
            break;
        case MAT:
            locs.forEach(l -> l.getWorld().dropItemNaturally(l, new ItemStack(material)));
            break;
        default:
            cancel();
            break;
    }
}
 

开发者ID:cadox8,
项目名称:WC,
代码行数:17,
代码来源:RainTask.java

示例2: onTarget

点赞 3

import org.bukkit.entity.ExperienceOrb; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
 

开发者ID:OvercastNetwork,
项目名称:ProjectAres,
代码行数:21,
代码来源:DamageMatchModule.java

示例3: repellExpOrb

点赞 3

import org.bukkit.entity.ExperienceOrb; //导入依赖的package包/类
final void repellExpOrb(final Player player, final ExperienceOrb orb) {
	final Location pLoc = player.getLocation();
	final Location oLoc = orb.getLocation();
	final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
	final double dx = Math.abs(dir.getX());
	final double dz = Math.abs(dir.getZ());
	if ( (dx == 0.0) && (dz == 0.0)){
		// Special case probably never happens
		dir.setX(0.001);
	}
	if ((dx < 3.0) && (dz < 3.0)){
		final Vector nDir = dir.normalize();
		final Vector newV = nDir.clone().multiply(0.3);
		newV.setY(0);
		orb.setVelocity(newV);
		if ((dx < 1.0) && (dz < 1.0)){
			// maybe oLoc
			orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
		} 
		if ((dx < 0.5) && (dz < 0.5)){
			orb.remove();
		} 
	} 
}
 

开发者ID:smessie,
项目名称:SkyWarsReloaded,
代码行数:25,
代码来源:SpectatorListener.java

示例4: onEntityExplode

点赞 3

import org.bukkit.entity.ExperienceOrb; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    if (!event.isCancelled()) {
        Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null;
        if (player != null) {
            for (Block block : event.blockList()) {
                if (filter == null || filter.evaluate(player, block).equals(FilterState.ALLOW)) {
                    if (region == null || region.contains(new BlockRegion(null, block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5))))) {
                        for (ItemStack drop : this.drops) {
                            GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop);
                        }
                        if (this.experience != 0) {
                            ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class);
                            xp.setExperience(this.experience);
                        }
                        block.setType(replace);
                    }
                }
            }
        }
    }
}
 

开发者ID:dentmaged,
项目名称:Cardinal-Plus,
代码行数:23,
代码来源:Blockdrops.java

示例5: onEntityExplode

点赞 3

import org.bukkit.entity.ExperienceOrb; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    if (!event.isCancelled()) {
        Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null;
        if (player != null) {
            List<Block> toRemove = new ArrayList<>();
            for (Block block : event.blockList()) {
                if (filter == null || filter.evaluate(player, block, event).equals(FilterState.ALLOW)) {
                    if (region == null || region.contains(block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5)))) {
                        for (ItemStack drop : this.drops) {
                            GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop);
                        }
                        if (this.experience != 0) {
                            ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class);
                            xp.setExperience(this.experience);
                        }
                        toRemove.add(block);
                        block.setType(replaceType);
                        block.setData((byte) replaceDamage);
                    }
                }
            }
            event.blockList().removeAll(toRemove);
        }
    }
}
 

开发者ID:twizmwazin,
项目名称:CardinalPGM,
代码行数:27,
代码来源:Blockdrops.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)