本文整理匯總了Java中org.bukkit.entity.Villager.setAdult方法的典型用法代碼示例。如果您正苦於以下問題:Java Villager.setAdult方法的具體用法?Java Villager.setAdult怎麽用?Java Villager.setAdult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.Villager
的用法示例。
在下文中一共展示了Villager.setAdult方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: spawnVillager
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
/**
* Spawns a Villager of the given VillagerType at the provided Location
*
* @param type - the Type of the Villager you wish to Spawn
* @param location - the Location at which you want the Villager to be
* @return Villager - the Villager that you had set at the provided Location if you wish to use it
*/
public Villager spawnVillager(VillagerType type, Location location) {
if (!location.getChunk().isLoaded()) {
location.getChunk().load();
}
Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
villager.setAdult();
villager.setAgeLock(true);
villager.setProfession(Profession.FARMER);
villager.setRemoveWhenFarAway(false);
villager.setCustomName(type.getColor() + type.getName());
villager.setCustomNameVisible(true);
villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
villager.teleport(location, TeleportCause.PLUGIN);
villager.setHealth(20.0D);
return villager;
}
示例2: spawn
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public static void spawn(){
for(Location loc : mineageddon()){
final Villager v = HubVillager.spawn(loc);
v.setAdult();
v.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon");
v.setCustomNameVisible(true);
v.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 10000000,100,false));
}
}
示例3: onBlockPlaced
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPlaced(BlockPlaceEvent evt) {
Block block = evt.getBlock();
if (block.getType().equals(Material.EMERALD_BLOCK) || block.getType().equals(Material.DIAMOND_BLOCK) || block.getType().equals(Material.IRON_BLOCK)) {
World world = block.getWorld();
Block below = world.getBlockAt(new Location(world, block.getX(), block.getY() - 1, block.getZ()));
Block below2 = world.getBlockAt(new Location(world, block.getX(), block.getY() - 2, block.getZ()));
if (below != null && below.getType().equals(Material.OBSIDIAN) && below2.getType().equals(Material.OBSIDIAN)) {
VillagerTradeOffer[] offers = null;
Profession profession = Profession.FARMER;
if (block.getType().equals(Material.DIAMOND_BLOCK)) {
offers = new VillagerTradeOffer[] {
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 24), new ItemStack(Material.DIAMOND_SWORD, 1)),
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 64), new ItemStack(Material.DIAMOND_LEGGINGS, 1)),
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 64), new ItemStack(Material.DIAMOND_CHESTPLATE, 1)),
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 32), new ItemStack(Material.DIAMOND_HELMET, 1)),
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 32), new ItemStack(Material.DIAMOND_BOOTS, 1)),
new VillagerTradeOffer(new ItemStack(Material.EMERALD, 24), new ItemStack(Material.DIAMOND_PICKAXE, 1))
};
profession = Profession.BLACKSMITH;
} else if (block.getType().equals(Material.EMERALD_BLOCK)) {
offers = new VillagerTradeOffer[] {
new VillagerTradeOffer(new ItemStack(Material.BONE, 64), new ItemStack(Material.EMERALD, 1)),
new VillagerTradeOffer(new ItemStack(Material.ROTTEN_FLESH, 64), new ItemStack(Material.EMERALD, 1)),
new VillagerTradeOffer(new ItemStack(Material.SPIDER_EYE, 64), new ItemStack(Material.EMERALD, 1)),
new VillagerTradeOffer(new ItemStack(Material.STRING, 64), new ItemStack(Material.EMERALD, 1)),
};
profession = Profession.FARMER;
}
if (offers != null) {
block.setType(Material.AIR);
below.setType(Material.AIR);
below2.setType(Material.AIR);
Villager villager = world.spawn(block.getLocation(), Villager.class);
villager.setAdult();
villager.setBreed(false);
villager.setProfession(profession);
EntityVillager entityVillager = ((CraftVillager)villager).getHandle();
MerchantRecipeList recipes = entityVillager.getOffers(((CraftPlayer)evt.getPlayer()).getHandle());
recipes.clear();
for(VillagerTradeOffer offer : offers) {
recipes.add(offer.getMerchantRecipie());
}
}
}
}
}