本文整理汇总了Java中org.bukkit.Material.MONSTER_EGG属性的典型用法代码示例。如果您正苦于以下问题:Java Material.MONSTER_EGG属性的具体用法?Java Material.MONSTER_EGG怎么用?Java Material.MONSTER_EGG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.MONSTER_EGG属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpawnEgg
/**
* Get spawn egg
* @param type
* @param amount
* @return
*/
public ItemStack getSpawnEgg(EntityType type, int amount) {
//Bukkit.getLogger().info("DEBUG: setting spawn egg " + type.toString());
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
NBTTagCompound tagCompound = stack.getTag();
if(tagCompound == null){
tagCompound = new NBTTagCompound();
}
//Bukkit.getLogger().info("DEBUG: tag = " + tagCompound);
NBTTagCompound id = new NBTTagCompound();
if (!bToMConversion.containsKey(type)) {
id.setString("id", "minecraft:" + type.toString().toLowerCase());
} else {
id.setString("id", "minecraft:" + bToMConversion.get(type));
}
tagCompound.set("EntityTag", id);
stack.setTag(tagCompound);
//Bukkit.getLogger().info("DEBUG: after tag = " + tagCompound);
return CraftItemStack.asBukkitCopy(stack);
}
示例2: removeBlock
public void removeBlock(BlockBreakEvent e) {
for (Entity en : e.getBlock().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
en.remove();
en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
ItemStack block = new ItemStack(Material.MONSTER_EGG, 1);
ItemMeta bmeta = block.getItemMeta();
bmeta.setDisplayName(name);
block.setItemMeta(bmeta);
if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
e.getPlayer().getInventory().addItem(block);
} else {
e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), block);
}
}
}
//}
}
示例3: isInteractableItem
/**
* checks if this item is interactable
*/
public static boolean isInteractableItem(ItemStack item) {
if (item == null || item.getType() == Material.AIR) {
return false;
}
if (item.getType().isBlock()) {
return true;
}
if (item.getType() == Material.REDSTONE || item.getType() == Material.WATER_BUCKET || item.getType() == Material.LAVA_BUCKET) {
return true;
}
if (item.getType() == Material.MONSTER_EGG) {
return true;
}
if (item.getType() == Material.EGG || item.getType() == Material.SNOW_BALL || item.getType() == Material.BOW || item.getType() == Material.ENDER_PEARL || item.getType() == Material.EYE_OF_ENDER || item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.EXP_BOTTLE || item.getType() == Material.FIREWORK_CHARGE) {
return true;
}
if (item.getType().isEdible()) {
return true;
}
return false;
}
示例4: onPlayerInteract
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent e) {
if (!cm.isDisableChangeSpawnerType) {
return;
}
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
if (e.getItem() == null) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
if (e.getItem().getType() == Material.MONSTER_EGG || e.getItem().getType() == Material.MONSTER_EGGS) {
e.setCancelled(true);
}
}
}
}
示例5: onMyPetCreate
@EventHandler(ignoreCancelled = true)
public void onMyPetCreate(MyPetCreateEvent event) {
Player player = event.getOwner().getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
ItemStack petItem = new ItemStack(Material.MONSTER_EGG);
ItemMeta meta = petItem.getItemMeta();
meta.setDisplayName(RPGInventory.getLanguage().getMessage("mypet.egg", event.getMyPet().getPetName()));
petItem.setItemMeta(meta);
petItem = ItemUtils.setTag(petItem, MYPET_TAG, event.getMyPet().getUUID().toString());
Inventory inventory = InventoryManager.get(player).getInventory();
Slot petSlot = getMyPetSlot();
ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
boolean hasPet = !petSlot.isCup(currentPet);
inventory.setItem(petSlot.getSlotId(), petItem);
if (hasPet) {
player.getInventory().addItem(currentPet);
}
}
示例6: onModify
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onModify(PlayerInteractEvent evt) {
if (!preventSpawnerModify || evt.getItem() == null || evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Player player = evt.getPlayer();
if (Perms.has(player)) return;
if (evt.getClickedBlock().getType() == Material.MOB_SPAWNER) {
Material type = evt.getItem().getType();
if (type == Material.MONSTER_EGG || type == Material.MONSTER_EGGS) {
evt.setCancelled(true);
AzureAPI.log(player, messagePreventSpawnerModify);
}
}
}
示例7: getSpawnEgg
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
SpawnEggMeta spm = (SpawnEggMeta)egg.getItemMeta();
spm.setSpawnedType(type);
egg.setItemMeta(spm);
return egg;
}
示例8: onSpawn
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getHand() != EquipmentSlot.HAND) return;
if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
if (!files.getConfig().getStringList("mundosPermitidos").contains(p.getLocation().getWorld().getName())) {
p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "No se puede usar en este mundo");
return;
}
int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
String s = e.getItem().getItemMeta().getLore().get(1);
RegionManager m = WGBukkit.getPlugin().getRegionManager(p.getWorld());
if (m != null) {
m.getApplicableRegions(p.getLocation()).getRegions().forEach(re ->{
if (re != null && re.getOwners().contains(p.getUniqueId())) {
return;
}
});
}
SNMob mob = new SNMob(p);
if (!mob.isOwner(id)) {
p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
return;
}
mob.spawnMob(id, s);
p.getInventory().getItemInMainHand().setAmount(-1);
}
}
示例9: getHorseItem
private ItemStack getHorseItem() {
ItemStack item = new ItemStack(Material.MONSTER_EGG);
SpawnEggMeta meta = (SpawnEggMeta) item.getItemMeta();
meta.setSpawnedType(EntityType.HORSE);
item.setItemMeta(meta);
return item;
}
示例10: getTexturedItem
@NotNull
public static ItemStack getTexturedItem(String texture) {
String[] textures = texture.split(":");
if (Material.getMaterial(textures[0]) == null) {
RPGInventory.getPluginLogger().warning("Material " + textures[0] + " not found");
return new ItemStack(Material.AIR);
}
ItemStack item = new ItemStack(Material.getMaterial(textures[0]));
if (textures.length == 2) {
if (item.getType() == Material.MONSTER_EGG) {
item = toBukkitItemStack(item);
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
nbt.put("EntityTag", NbtFactory.ofCompound("temp").put("id", textures[1]));
} else {
item.setDurability(Short.parseShort(textures[1]));
if (isItemHasDurability(item)) {
item = setTag(item, UNBREAKABLE_TAG, "1");
item = setTag(item, HIDE_FLAGS_TAG, "63");
}
}
}
return item;
}
示例11: onSpawn
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getHand() != EquipmentSlot.HAND) return;
if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
String s = e.getItem().getItemMeta().getLore().get(1);
boolean canCatch = true;
ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;
if (!canCatch) {
p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes spawnear un mob en parcelas ajenas");
return;
}
SNMob mob = new SNMob(p);
if (!mob.isOwner(id)) {
p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
return;
}
mob.spawnMob(id, s);
p.getInventory().getItemInMainHand().setAmount(-1);
}
}