private EnumDyeColor getColor( final ItemStack ei ) { try { if ( ei != null && ei.hasTagCompound() ) { return EnumDyeColor.valueOf( ModUtil.getTagCompound( ei ).getString( "color" ) ); } } catch ( final IllegalArgumentException e ) { // nope! } return EnumDyeColor.WHITE; }
public EnumDyeColor getTapeColor( final ItemStack item ) { final NBTTagCompound compound = item.getTagCompound(); if ( compound != null && compound.hasKey( "color" ) ) { try { return EnumDyeColor.valueOf( compound.getString( "color" ) ); } catch ( final IllegalArgumentException iae ) { // nope! } } return EnumDyeColor.WHITE; }
@ZenMethod public static void addDyeRecipe(IItemStack output, IIngredient input, String stringDye, int levels) { if (levels < 0 || levels > InspirationsRegistry.getCauldronMax()) { CraftTweakerAPI.logError(String.format("Ignoring Cauldron Dyeing recipe for %s: Invalid levels %d given, must be between 0 and %d", output.getDisplayName(), levels, InspirationsRegistry.getCauldronMax())); return; } EnumDyeColor dye = EnumDyeColor.valueOf(stringDye.toUpperCase()); if (dye == null) { CraftTweakerAPI.logError("Ignoring Cauldron Dyeing recipe for " + output.getDisplayName() + ": Could not find matching dye color for " + stringDye); return; } ModTweaker.LATE_ADDITIONS.add(new AddDye(InputHelper.toStack(output), input, dye, levels)); }
@ZenMethod public static void removeDyeRecipe(IIngredient output, @Optional IIngredient input, @Optional String stringDye) { init(); EnumDyeColor dye = null; if (stringDye != null) { dye = EnumDyeColor.valueOf(stringDye.toUpperCase()); if (dye == null) { CraftTweakerAPI.logError("Ignoring Cauldron Dyeing recipe removalS: Could not find matching dye color for " + stringDye); return; } } CraftTweakerAPI.apply(new RemoveDye(output, input, dye)); }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (!(sender instanceof EntityPlayerMP)) { throw new CommandException("pe.command.showbag.notplayer"); } if (args.length != 2) { throw new WrongUsageException("pe.command.showbag.usage"); } EntityPlayerMP senderPlayer = (EntityPlayerMP) sender; EnumDyeColor color; try { color = EnumDyeColor.valueOf(args[0].toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { throw new CommandException("pe.command.showbag.nocolor", args[0]); } senderPlayer.closeScreen(); senderPlayer.getNextWindowId(); senderPlayer.openContainer = createContainer(server, senderPlayer, args[1], color); senderPlayer.openContainer.windowId = senderPlayer.currentWindowId; PacketHandler.sendTo(new ShowBagPKT(senderPlayer.openContainer.windowId), senderPlayer); senderPlayer.openContainer.addListener(senderPlayer); }
setColor.newColor = EnumDyeColor.valueOf( ChiselsAndBitsMenu.instance.doAction.name() ); setColor.chatNotification = ChiselsAndBits.getConfig().chatModeNotification; NetworkRouter.instance.sendToServer( setColor );