org.bukkit.Material#MONSTER_EGG源码实例Demo

下面列出了org.bukkit.Material#MONSTER_EGG 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BedwarsRel   文件: SpawnEgg1_9.java
/**
 * Converts from an item stack to a spawn egg 1.9
 *
 * @param item - ItemStack, quantity is disregarded
 * @return SpawnEgg 1.9
 */
public static SpawnEgg1_9 fromItemStack(ItemStack item) {
  if (item == null) {
    throw new IllegalArgumentException("item cannot be null");
  }
  if (item.getType() != Material.MONSTER_EGG) {
    throw new IllegalArgumentException("item is not a monster egg");
  }
  net.minecraft.server.v1_9_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound != null) {
    @SuppressWarnings("deprecation")
    EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
    if (type != null) {
      return new SpawnEgg1_9(type);
    } else {
      return null;
    }
  } else {
    return null;
  }
}
 
源代码2 项目: BedwarsRel   文件: SpawnEgg1_11.java
/**
 * Converts from an item stack to a spawn egg 1.9
 *
 * @param item - ItemStack, quantity is disregarded
 * @return SpawnEgg 1.9
 */
public static SpawnEgg1_11 fromItemStack(ItemStack item) {
  if (item == null) {
    throw new IllegalArgumentException("item cannot be null");
  }
  if (item.getType() != Material.MONSTER_EGG) {
    throw new IllegalArgumentException("item is not a monster egg");
  }
  net.minecraft.server.v1_11_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound != null) {
    @SuppressWarnings("deprecation")
    EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
    if (type != null) {
      return new SpawnEgg1_11(type);
    } else {
      return null;
    }
  } else {
    return null;
  }
}
 
源代码3 项目: BedwarsRel   文件: SpawnEgg1_12.java
/**
 * Converts from an item stack to a spawn egg 1.9
 *
 * @param item - ItemStack, quantity is disregarded
 * @return SpawnEgg 1.9
 */
public static SpawnEgg1_12 fromItemStack(ItemStack item) {
  if (item == null) {
    throw new IllegalArgumentException("item cannot be null");
  }
  if (item.getType() != Material.MONSTER_EGG) {
    throw new IllegalArgumentException("item is not a monster egg");
  }
  net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound != null) {
    @SuppressWarnings("deprecation")
    EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
    if (type != null) {
      return new SpawnEgg1_12(type);
    } else {
      return null;
    }
  } else {
    return null;
  }
}
 
源代码4 项目: BedwarsRel   文件: SpawnEgg1_10.java
/**
 * Converts from an item stack to a spawn egg 1.9
 *
 * @param item - ItemStack, quantity is disregarded
 * @return SpawnEgg 1.9
 */
public static SpawnEgg1_10 fromItemStack(ItemStack item) {
  if (item == null) {
    throw new IllegalArgumentException("item cannot be null");
  }
  if (item.getType() != Material.MONSTER_EGG) {
    throw new IllegalArgumentException("item is not a monster egg");
  }
  net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound != null) {
    @SuppressWarnings("deprecation")
    EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
    if (type != null) {
      return new SpawnEgg1_10(type);
    } else {
      return null;
    }
  } else {
    return null;
  }
}
 
源代码5 项目: Shopkeepers   文件: Settings.java
public static boolean isShopCreationItem(ItemStack item) {
	if (!Utils.isSimilar(item, Settings.shopCreationItem, (short) Settings.shopCreationItemData, Settings.shopCreationItemName, Settings.shopCreationItemLore)) {
		return false;
	}

	// check spawn egg entity type:
	if (shopCreationItem == Material.MONSTER_EGG && !Utils.isEmpty(shopCreationItemSpawnEggEntityType) && NMSManager.getProvider().supportsSpawnEggEntityType()) {
		EntityType spawnEggEntityType = NMSManager.getProvider().getSpawnEggEntityType(item); // can be null
		EntityType requiredEntityType = null;
		try {
			requiredEntityType = EntityType.valueOf(shopCreationItemSpawnEggEntityType);
		} catch (IllegalArgumentException e) {
			// unknown entity type, require 'empty' entity type
		}
		if (!Objects.equal(spawnEggEntityType, requiredEntityType)) return false;
	}

	return true;
}
 
源代码6 项目: askyblock   文件: NMSHandler.java
/**
 * 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_11_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);
}
 
源代码7 项目: Carbon   文件: PlayerListener.java
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
   public void onPlayerInteractMobSpawner(PlayerInteractEvent evt) {
       if (plugin.getConfig().getBoolean("features.monsterEggMobSpawner", true)) {
           if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
               if (evt.getPlayer().getItemInHand().getType() == Material.MONSTER_EGG && evt.getClickedBlock().getType() == Material.MOB_SPAWNER) {
                   ItemStack egg = evt.getPlayer().getItemInHand();
                   CreatureSpawner cs = (CreatureSpawner) evt.getClickedBlock().getState();
                   cs.setSpawnedType(EntityType.fromId(egg.getData().getData()));
                   cs.update(true);
                   evt.setUseItemInHand(Event.Result.DENY);
                   evt.setCancelled(true);
               }
           }
       }
   }
 
源代码8 项目: BedwarsRel   文件: SpawnEgg1_9.java
/**
 * Get an itemstack of spawn eggs
 *
 * @return ItemStack of spawn eggs
 */
@SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) {
  ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
  net.minecraft.server.v1_9_R2.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound == null) {
    tagCompound = new NBTTagCompound();
  }
  NBTTagCompound id = new NBTTagCompound();
  id.setString("id", type.getName());
  tagCompound.set("EntityTag", id);
  stack.setTag(tagCompound);
  return CraftItemStack.asBukkitCopy(stack);
}
 
源代码9 项目: BedwarsRel   文件: SpawnEgg1_9.java
/**
 * Get an itemstack of spawn eggs
 *
 * @return ItemStack of spawn eggs
 */
@SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) {
  ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
  net.minecraft.server.v1_9_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound == null) {
    tagCompound = new NBTTagCompound();
  }
  NBTTagCompound id = new NBTTagCompound();
  id.setString("id", type.getName());
  tagCompound.set("EntityTag", id);
  stack.setTag(tagCompound);
  return CraftItemStack.asBukkitCopy(stack);
}
 
源代码10 项目: BedwarsRel   文件: SpawnEgg1_11.java
/**
 * Get an itemstack of spawn eggs
 *
 * @return ItemStack of spawn eggs
 */
@SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) {
  ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
  net.minecraft.server.v1_11_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound == null) {
    tagCompound = new NBTTagCompound();
  }
  NBTTagCompound id = new NBTTagCompound();
  id.setString("id", type.getName());
  tagCompound.set("EntityTag", id);
  stack.setTag(tagCompound);
  return CraftItemStack.asBukkitCopy(stack);
}
 
源代码11 项目: BedwarsRel   文件: SpawnEgg1_12.java
/**
 * Get an itemstack of spawn eggs
 *
 * @return ItemStack of spawn eggs
 */
@SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) {
  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();
  }
  NBTTagCompound id = new NBTTagCompound();
  id.setString("id", type.getName());
  tagCompound.set("EntityTag", id);
  stack.setTag(tagCompound);
  return CraftItemStack.asBukkitCopy(stack);
}
 
源代码12 项目: BedwarsRel   文件: SpawnEgg1_10.java
/**
 * Get an itemstack of spawn eggs
 *
 * @return ItemStack of spawn eggs
 */
@SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) {
  ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
  net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
  NBTTagCompound tagCompound = stack.getTag();
  if (tagCompound == null) {
    tagCompound = new NBTTagCompound();
  }
  NBTTagCompound id = new NBTTagCompound();
  id.setString("id", type.getName());
  tagCompound.set("EntityTag", id);
  stack.setTag(tagCompound);
  return CraftItemStack.asBukkitCopy(stack);
}
 
源代码13 项目: askyblock   文件: NMSHandler.java
/**
 * Get spawn egg
 * @param type
 * @param amount
 * @return
 */
@SuppressWarnings("deprecation")
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
    net.minecraft.server.v1_9_R2.ItemStack stack = CraftItemStack.asNMSCopy(item);
    NBTTagCompound tagCompound = stack.getTag();
    if(tagCompound == null){
        tagCompound = new NBTTagCompound();
    }
    NBTTagCompound id = new NBTTagCompound();
    id.setString("id", type.getName());
    tagCompound.set("EntityTag", id);
    stack.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(stack);
}
 
源代码14 项目: askyblock   文件: NMSHandler.java
/**
 * Get spawn egg
 * @param type
 * @param amount
 * @return
 */
@SuppressWarnings("deprecation")
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
    net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
    NBTTagCompound tagCompound = stack.getTag();
    if(tagCompound == null){
        tagCompound = new NBTTagCompound();
    }
    NBTTagCompound id = new NBTTagCompound();
    id.setString("id", type.getName());
    tagCompound.set("EntityTag", id);
    stack.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(stack);
}
 
源代码15 项目: Kettle   文件: SpawnEgg.java
public SpawnEgg() {
    super(Material.MONSTER_EGG);
}
 
源代码16 项目: Kettle   文件: SpawnEgg.java
/**
 * @param data the raw data value
 * @deprecated Magic value
 */
@Deprecated
public SpawnEgg(byte data) {
    super(Material.MONSTER_EGG, data);
}
 
源代码17 项目: SonarPet   文件: SpawnEggItemData.java
protected SpawnEggItemData(byte rawData, ItemMeta meta) {
    super(Material.MONSTER_EGG, rawData, meta);
}
 
源代码18 项目: Shopkeepers   文件: ZombieShop.java
@Override
public ItemStack getSubTypeItem() {
	return new ItemStack(Material.MONSTER_EGG, 1, (short) 54);
}
 
源代码19 项目: BedwarsRel   文件: TNTSheep.java
@Override
public Material getItemMaterial() {
  return Material.MONSTER_EGG;
}
 
源代码20 项目: Shopkeepers   文件: PigZombieShop.java
@Override
public ItemStack getSubTypeItem() {
	return new ItemStack(Material.MONSTER_EGG, 1, (short) 57);
}
 
 方法所在类
 同类方法