当前位置: 首页>>代码示例>>Java>>正文


Java Material.MONSTER_EGG属性代码示例

本文整理汇总了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);
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:26,代码来源:NMSHandler.java

示例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);
				}
			}
		}
	//}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:23,代码来源:CustomBlock.java

示例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;
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:24,代码来源:HitboxUtils.java

示例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);
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:19,代码来源:AntiUseEggsChangeSpawnerType.java

示例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);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:24,代码来源:MyPetManager.java

示例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);
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:15,代码来源:SpawnerController.java

示例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;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:8,代码来源:NMSHandler.java

示例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);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:33,代码来源:SpawnMob.java

示例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;
}
 
开发者ID:upperlevel,项目名称:book-api,代码行数:7,代码来源:Main.java

示例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;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:28,代码来源:ItemUtils.java

示例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);
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:29,代码来源:SpawnMob.java


注:本文中的org.bukkit.Material.MONSTER_EGG属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。