@Override public Iterable<Recipe> getCraftingRecipes() { ShapedRecipe portalRecipe = new ShapedRecipe(makeItem(getAmountPerCraft())); portalRecipe.shape("BOB", "PCP", "OPO"); Dye purpleDye = new Dye(Material.INK_SACK); purpleDye.setColor(DyeColor.PURPLE); portalRecipe.setIngredient('B', Material.BLAZE_POWDER); portalRecipe.setIngredient('O', Material.OBSIDIAN); portalRecipe.setIngredient('P', Material.ENDER_PEARL); portalRecipe.setIngredient('C', purpleDye.toItemStack(1).getData()); return Collections.singletonList((Recipe) portalRecipe); }
/** * Checks to see if an item is a mining drop. * * @param item Item to check * @return true if the item is a mining drop, false otherwise */ public static boolean isMiningDrop(ItemStack item) { switch (item.getType()) { case COAL: case COAL_ORE: case DIAMOND: case DIAMOND_ORE: case EMERALD: case EMERALD_ORE: case GOLD_ORE: case IRON_ORE: case LAPIS_ORE: case REDSTONE_ORE: // Should we also have Glowing Redstone Ore here? case REDSTONE: case GLOWSTONE_DUST: // Should we also have Glowstone here? case QUARTZ: case QUARTZ_ORE: return true; case INK_SACK: return ((Dye) item.getData()).getColor() == DyeColor.BLUE; default: return false; } }
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void onInvOpen(InventoryClickEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(ProtocolSupportLegacySupport.getInstance(), () -> { Inventory topinv = event.getWhoClicked().getOpenInventory().getTopInventory(); if (!(topinv instanceof EnchantingInventory)) { return; } EnchantingInventory enchinv = (EnchantingInventory) topinv; Player player = (Player) event.getWhoClicked(); int lapisEnchAmount = enchinv.getSecondary() != null ? enchinv.getSecondary().getAmount() : 0; ItemStack[] contents = player.getInventory().getStorageContents(); for (int i = 0; i < contents.length; i++) { ItemStack itemstack = contents[i]; if (lapis.isSimilar(itemstack)) { int lapisPlayerAmount = Math.min(itemstack.getAmount(), Material.INK_SACK.getMaxStackSize() - lapisEnchAmount); itemstack.setAmount(itemstack.getAmount() - lapisPlayerAmount); if (itemstack.getAmount() == 0) { contents[i] = null; } lapisEnchAmount += lapisPlayerAmount; if (lapisEnchAmount == Material.INK_SACK.getMaxStackSize()) { break; } } } player.getInventory().setStorageContents(contents); if (lapisEnchAmount != 0) { enchinv.setSecondary(new Dye(DyeColor.BLUE).toItemStack(lapisEnchAmount)); } player.updateInventory(); }); }
@Override public BaseBlock getBlockInHand() throws WorldEditException { ItemStack itemStack = player.getItemInHand(); if (itemStack == null) { return EditSession.nullBlock; } final int typeId = itemStack.getTypeId(); switch (typeId) { case 0: return EditSession.nullBlock; case ItemID.INK_SACK: final Dye materialData = (Dye) itemStack.getData(); if (materialData.getColor() == DyeColor.BROWN) { return FaweCache.getBlock(BlockID.COCOA_PLANT, 0); } break; case ItemID.HEAD: return new SkullBlock(0, (byte) itemStack.getDurability()); default: final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability()); if (baseBlock != null) { return baseBlock; } break; } BaseBlock block = FaweCache.getBlock(typeId, itemStack.getType().getMaxDurability() != 0 ? 0 : Math.max(0, itemStack.getDurability())); if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && Fawe.<FaweBukkit>imp().getItemUtil() != null) { return new BrushBoundBaseBlock(this, WorldEdit.getInstance().getSession(this), itemStack); } return block; }
@Override public Collection<ItemStack> getDrops() { Dye dye = new Dye(); dye.setColor(DyeColor.BROWN); ItemStack item = new ItemStack(Material.INK_SACK, 3, dye.getData()); return GenericCrop.getDrops(item); }
/** * Checks to see if an item is a herbalism drop. * * @param item Item to check * @return true if the item is a herbalism drop, false otherwise */ public static boolean isHerbalismDrop(ItemStack item) { switch (item.getType()) { case WHEAT: case SEEDS: case CARROT_ITEM: case POTATO_ITEM: case NETHER_WARTS: case BROWN_MUSHROOM: case RED_MUSHROOM: case RED_ROSE: case YELLOW_FLOWER: case CACTUS: case SUGAR_CANE: case MELON: case MELON_SEEDS: case PUMPKIN: case PUMPKIN_SEEDS: case WATER_LILY: case VINE: case LONG_GRASS: case DOUBLE_PLANT: return true; case INK_SACK: return ((Dye) item.getData()).getColor() == DyeColor.BROWN; default: return false; } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) { if (!(event.getRightClicked() instanceof LivingEntity)) { return; } Player player = event.getPlayer(); Entity entity = event.getRightClicked(); ActionPlayerEntity action; if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart) { action = this.newAction(UseFurnaceMinecart.class, entity.getWorld()); } else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf) { action = this.newAction(EntityDye.class, entity.getWorld()); if (action != null) { ((EntityDye)action).setColor(((Dye)player.getItemInHand().getData()).getColor()); } } else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow) { action = this.newAction(EntityFillSoup.class, entity.getWorld()); } else { return; } if (action != null) { action.setEntity(entity); action.setPlayer(player); action.setLocation(entity.getLocation()); this.logAction(action); } }
private static MaterialData parseMatAndData(String matData) { String[] fields = matData.split("[:()]"); Material mat = Material.matchMaterial(fields[0]); if (mat == null) { throw new DHUtilsException("Unknown material " + fields[0]); } MaterialData res = new MaterialData(mat); if (fields.length > 1) { if (StringUtils.isNumeric(fields[1])) { res.setData(Byte.parseByte(fields[1])); } else { switch (mat) { case INK_SACK: Dye dye = new Dye(); dye.setColor(DyeColor.valueOf(fields[1].toUpperCase())); res = dye; break; case WOOL: case CARPET: case STAINED_GLASS: case STAINED_GLASS_PANE: case STAINED_CLAY: // maybe one day these will all implement Colorable... DyeColor dc2 = DyeColor.valueOf(fields[1].toUpperCase()); res.setData(dc2.getWoolData()); break; case SAPLING: case WOOD: TreeSpecies ts = TreeSpecies.valueOf(fields[1].toUpperCase()); res.setData(ts.getData()); break; } } } return res; }
@Override public Recipe getRecipe() { ShapedRecipe recipe = new ShapedRecipe(toItemStack()); Dye d = new Dye(); d.setColor(DyeColor.WHITE); recipe.shape("SM ", "SBS", " S "); recipe.setIngredient('S', Material.STONE); recipe.setIngredient('M', d); recipe.setIngredient('B', Material.BOWL); return recipe; }
@Override public Recipe getRecipe() { Dye greenDye = new Dye(); greenDye.setColor(DyeColor.GREEN); ShapelessRecipe recipe = new ShapelessRecipe(toItemStack(2)); recipe.addIngredient(Material.STONE_PLATE); recipe.addIngredient(greenDye); return recipe; }
public static String prettyName(final ItemStack item) { final Material mat = item.getType(); String out = prettyName(mat); if ( mat == Material.WOOL ) out += " (" + prettyName(((Wool) item.getData()).getColor()) + ")"; else if ( mat == Material.INK_SACK ) out += " (" + prettyName(((Dye) item.getData()).getColor()) + ")"; else if ( item.getDurability() != 0 ) out += " (" + item.getDurability() + ")"; return out; }
private ItemStack getLapis(){ Dye dye = new Dye(); dye.setColor(DyeColor.BLUE); return dye.toItemStack(64); }
@Test public void getDyeDyeColor() { testColorable(new Dye(Material.INK_SACK, dye.getDyeData())); }
/** * Check if the dye is cocoa beans. */ @Override public boolean checkPlantableItemData(MaterialData data) { return ((Dye) data).getColor() == DyeColor.BROWN; }
protected static Dye makeDye(DyeColor color) { Dye dye = new Dye(); dye.setColor(color); return dye; }
public Dye() { }
@Deprecated public Dye(int type) { }
public Dye(Material type) { }
@Deprecated public Dye(int type, byte data) { }
@Deprecated public Dye(Material type, byte data) { }
public Dye clone() { return null; }
/** * Create a new instance of the builder * * @param dye The dye to create from * * @return The builder instance */ public static ItemStackBuilder fromDye(Dye dye) { return new ItemStackBuilder(dye.toItemStack()); }