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


Java ExperienceOrb.setExperience方法代碼示例

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


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

示例1: onEntityExplode

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

示例2: onEntityExplode

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

示例3: dropExperience

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
private void dropExperience(BlockDrops drops, Location location) {
    if(drops.experience != 0) {
        ExperienceOrb expOrb = (ExperienceOrb) location.getWorld().spawnEntity(BlockUtils.center(location), EntityType.EXPERIENCE_ORB);
        if(expOrb != null) {
            expOrb.setExperience(drops.experience);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:BlockDropsMatchModule.java

示例4: onDeath

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
@EventHandler
public void onDeath(PlayerDeathEvent e) {
    Player p = e.getEntity();
    if (!Utils.isInArena(p)) {
        return;
    }
    int level = p.getLevel();
    ExperienceOrb exp = (ExperienceOrb) p.getWorld().spawnEntity(p.getLocation(), EntityType.EXPERIENCE_ORB);
    exp.setExperience(level * 2);
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:11,代碼來源:PlayerListener.java

示例5: spawn

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
@Override
@Nullable
public ExperienceOrb spawn(final Location loc) {
	final ExperienceOrb orb = super.spawn(loc);
	if (orb == null)
		return null;
	if (xp == -1)
		orb.setExperience(1);
	return orb;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:11,代碼來源:XpOrbData.java

示例6: doXP

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
private void doXP(DropConfig dc, String biomeName, ToolConfig dropModifier, Location loc, Player p) {
	double xpChance = dc.getXPChance(biomeName) 
			* (dropModifier == null ? 1.0 : dropModifier.getDropChanceModifier())
			* dc.getStateChance(biomeName, p);
	if (xpChance > Math.random()) {
		int toXP = dc.renderXP(biomeName, dropModifier);
		if (toXP > 0) {
			Entity xp = loc.getWorld().spawnEntity(loc, EntityType.EXPERIENCE_ORB);
			if (xp instanceof ExperienceOrb) {
				ExperienceOrb eo = (ExperienceOrb) xp;
				eo.setExperience(toXP);
			}
		}
	}
}
 
開發者ID:DevotedMC,項目名稱:HiddenOre,代碼行數:16,代碼來源:BlockBreakListener.java

示例7: dropItems

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
public void dropItems() {
	try {
		if (entity == null) {
			return;
		}
		
		LinkedList<MobDrop> dropped = getRandomDrops();
		World world = entity.getBukkitEntity().getWorld();
		Location loc = getLocation(entity);
		
		for (MobDrop d : dropped) {
			ItemStack stack;
			if (d.isVanillaDrop) {
				stack = ItemManager.createItemStack(d.vanillaType, 1, d.vanillaData);
			} else {
				LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterialFromId(d.craftMatId);
				stack = LoreCraftableMaterial.spawn(craftMat);
			}
			
			world.dropItem(loc, stack);
		}
		
		if (this.coinMax != 0 && this.coinMin != 0) {
			ExperienceOrb orb = (ExperienceOrb)world.spawn(loc, ExperienceOrb.class);
			Random random = new Random();
			int coins = random.nextInt(this.coinMax - this.coinMin) + this.coinMin;
			orb.setExperience(coins);

		}
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:34,代碼來源:CommonCustomMob.java

示例8: drop

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
private static void drop(Material material, int amount, Location location) {
    location.getWorld().dropItem(location, new ItemStack(material, amount));

    ExperienceOrb exp = location.getWorld().spawn(location, ExperienceOrb.class);
    exp.setExperience(1);
}
 
開發者ID:michael1011,項目名稱:BackPacks,代碼行數:7,代碼來源:BlockBreak.java

示例9: set

import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
@Override
public void set(final ExperienceOrb entity) {
	if (xp != -1)
		entity.setExperience(xp);
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:6,代碼來源:XpOrbData.java


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