Java Code Examples for org.bukkit.Material#MONSTER_EGG

The following examples show how to use org.bukkit.Material#MONSTER_EGG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerListener.java    From Carbon with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
               }
           }
       }
   }
 
Example 2
Source File: NMSHandler.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: SpawnEgg1_9.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 4
Source File: Settings.java    From Shopkeepers with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: SpawnEgg1_11.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 6
Source File: SpawnEgg1_12.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 7
Source File: SpawnEgg1_10.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 8
Source File: SpawnEgg1_12.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source File: NMSHandler.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: NMSHandler.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: SpawnEgg1_10.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: SpawnEgg1_11.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: SpawnEgg1_9.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: SpawnEgg1_9.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: TNTSheep.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Material getItemMaterial() {
  return Material.MONSTER_EGG;
}
 
Example 16
Source File: SpawnEgg.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public SpawnEgg() {
    super(Material.MONSTER_EGG);
}
 
Example 17
Source File: ZombieShop.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack getSubTypeItem() {
	return new ItemStack(Material.MONSTER_EGG, 1, (short) 54);
}
 
Example 18
Source File: PigZombieShop.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack getSubTypeItem() {
	return new ItemStack(Material.MONSTER_EGG, 1, (short) 57);
}
 
Example 19
Source File: SpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
protected SpawnEggItemData(byte rawData, ItemMeta meta) {
    super(Material.MONSTER_EGG, rawData, meta);
}
 
Example 20
Source File: SpawnEgg.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param data the raw data value
 * @deprecated Magic value
 */
@Deprecated
public SpawnEgg(byte data) {
    super(Material.MONSTER_EGG, data);
}