@Override public IRecipe parse(JsonContext context, JsonObject json) { String group = JsonUtils.getString(json, "group", ""); NonNullList<Ingredient> ings = NonNullList.create(); for(JsonElement ele : JsonUtils.getJsonArray(json, "ingredients")) ings.add(CraftingHelper.getIngredient(ele, context)); if(ings.isEmpty()) throw new JsonParseException("No ingredients for shapeless recipe"); if(ings.size() > 9) throw new JsonParseException("Too many ingredients for shapeless recipe"); ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context); return new RecipeTorchGun(group, itemstack, ings); }
@Override public IRecipe parse(JsonContext context, JsonObject json) { int clamp = JsonUtils.getInt(json, "clamp"); boolean combining = JsonUtils.getBoolean(json, "combining"); JsonArray upgradeList = JsonUtils.getJsonArray(json, "upgrades"); Map<Ingredient, Double> upgrades = new LinkedHashMap<>(); int n = 0; for (JsonElement element : upgradeList) { if (element.isJsonObject()) { JsonObject upgrade = element.getAsJsonObject(); double amount = JsonUtils.getFloat(upgrade, "amount"); Ingredient ingredient = CraftingHelper.getIngredient(upgrade.get("ingredient"), context); upgrades.put(ingredient, amount); } else { throw new JsonSyntaxException("Expected " + n + " to be a JsonObject, was " + JsonUtils.toString(json)); } n++; } return new RandoresForgeUpgradeRecipe(clamp, combining, upgrades); }
public MagibenchShapelessRecipe(@Nonnull ItemStack result, int minTier, String entryId, Object... recipe) { setTier(minTier); setEntry(entryId); out = result.copy(); for (Object in : recipe) { Ingredient ing = CraftingHelper.getIngredient(in); if (ing != null) { ingredients.add(ing); this.simple &= ing.isSimple(); } else { StringBuilder ret = new StringBuilder("Invalid shapeless ore recipe: "); for (Object tmp : recipe) { ret.append(tmp).append(", "); } ret.append(out); throw new RuntimeException(ret.toString()); } } }
@Override public IRecipe parse(JsonContext context, JsonObject json) { String group = JsonUtils.getString(json, "group", ""); NonNullList<Ingredient> ingredients = NonNullList.create(); for (JsonElement element : JsonUtils.getJsonArray(json, "ingredients")) ingredients.add(CraftingHelper.getIngredient(element, context)); if (ingredients.isEmpty()) throw new JsonParseException("No ingredients in shapeless recipe"); ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context); RecipeShapelessFluid recipe = new RecipeShapelessFluid(group.isEmpty() ? null : new ResourceLocation(group), result, ingredients); return recipe; }
@Nonnull @Override public Ingredient parse(JsonContext context, JsonObject json) { final ItemStack stack = CraftingHelper.getItemStack(json, context); Item tip = JsonUtils.getItem(json, "tip"); Item container = JsonUtils.getItem(json, "container"); stack.setTagCompound(new NBTTagCompound()); if (stack.getTagCompound() != null) { stack.getTagCompound().setString("tip", tip.getRegistryName().getResourcePath()); stack.getTagCompound().setString("uses", container.getRegistryName().getResourcePath()); } return new IngredientNBT(stack); }
/** * Converts an object array into a NonNullList of Ingredients */ private static NonNullList<Ingredient> buildInput (Object[] input) { NonNullList<Ingredient> list = NonNullList.create(); for(Object obj : input){ if(obj instanceof Ingredient){ list.add((Ingredient) obj); } else { Ingredient ingredient = CraftingHelper.getIngredient(obj); if(ingredient == null){ ingredient = Ingredient.EMPTY; } list.add(ingredient); } } return list; }
@Nonnull @Override public Ingredient parse(JsonContext context, JsonObject json) { final ItemStack stack = CraftingHelper.getItemStack(json, context); int estus = JsonUtils.getInt(json, "estus", 0); int uses = JsonUtils.getInt(json, "uses", 0); stack.setTagCompound(new NBTTagCompound()); if (stack.getTagCompound() != null) { stack.getTagCompound().setInteger("estus", estus); stack.getTagCompound().setInteger("uses", uses); } return new IngredientNBT(stack); }
private static NonNullList<Ingredient> convertToNonNullList(Object[] input) { NonNullList<Ingredient> list = NonNullList.create(); for (Object any : input) { if (any instanceof Ingredient) { list.add((Ingredient) any); } else { Ingredient ing = CraftingHelper.getIngredient(any); if (ing == null) { ing = Ingredient.EMPTY;// EMPTY/.. same as new Ingredient(new ItemStack[0]) } list.add(ing); } } return list; }
RecipeAmadronTablet() { super("amadron_tablet_actual"); this.primer = CraftingHelper.parseShaped("ppp", "pgp", "pcp", 'p', new ItemStack(Itemss.PLASTIC, 1, ItemPlastic.GREY), 'g', Itemss.GPS_TOOL, 'c', new ItemStack(Itemss.AIR_CANISTER, 1, OreDictionary.WILDCARD_VALUE)); this.recipe = new ShapedOreRecipe(RL("matcher_amadron_tablet"), new ItemStack(Itemss.AMADRON_TABLET, 1, Itemss.AMADRON_TABLET.getMaxDamage()), primer); }
public RecipeGun(String dyeName, Item output) { super(output.getRegistryName().getResourcePath() + "_actual"); this.output = output; this.primer = CraftingHelper.parseShaped("idi", "c ", "ili", 'd', dyeName, 'i', Itemss.INGOT_IRON_COMPRESSED, 'l', Blocks.LEVER, 'c', new ItemStack(Itemss.AIR_CANISTER, 1, OreDictionary.WILDCARD_VALUE)); this.recipe = new ShapedOreRecipe(RL("matcher_" + output.getRegistryName().getResourcePath()), getRecipeOutput(), primer); }
public void preInit(FMLPreInitializationEvent event) { IFRegistries.poke(); CraftingHelper.register(new ResourceLocation(Reference.MOD_ID, "configuration_value"), new ConfigurationConditionFactory()); random = new Random(); FluidsRegistry.registerFluids(); BlockRegistry.poke(); MinecraftForge.EVENT_BUS.register(new BlockRegistry()); MinecraftForge.EVENT_BUS.register(new ItemRegistry()); MinecraftForge.EVENT_BUS.register(new StrawRegistry()); MinecraftForge.EVENT_BUS.register(new MeatFeederTickHandler()); MinecraftForge.EVENT_BUS.register(new MobDeathHandler()); MinecraftForge.EVENT_BUS.register(new WorldTickHandler()); MinecraftForge.EVENT_BUS.register(new PlantRecollectableRegistryHandler()); MinecraftForge.EVENT_BUS.register(new FakePlayerRideEntityHandler()); MinecraftForge.EVENT_BUS.register(new PlantInteractorHarvestDropsHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(IndustrialForegoing.instance, new GuiHandler()); CustomConfiguration.config = new Configuration(event.getSuggestedConfigurationFile()); CustomConfiguration.config.load(); CustomConfiguration.sync(); CustomConfiguration.configValues = new HashMap<>(); CustomConfiguration.configValues.put("useTEFrames", CustomConfiguration.config.getBoolean("useTEFrames", Configuration.CATEGORY_GENERAL, true, "Use Thermal Expansion Machine Frames instead of Tesla Core Lib")); if (Loader.isModLoaded("crafttweaker")) CraftTweakerHelper.register(); EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "pink_slime"), EntityPinkSlime.class, "pink_slime", 135135, IndustrialForegoing.instance, 32, 1, false, 10485860, 16777215); PINK_SLIME_LOOT = LootTableList.register(new ResourceLocation(Reference.MOD_ID, "entities/pink_slime")); }
public MagibenchRecipe(ItemStack out, int minTier, String entryId, CraftingHelper.ShapedPrimer primer) { setEntry(entryId); setTier(minTier); this.out = out.copy(); this.width = primer.width; this.height = primer.height; this.ingredients = primer.input; this.mirrored = primer.mirrored; }
@Override public IRecipe parse(JsonContext context, JsonObject json) { String group = JsonUtils.getString(json, "group", ""); NonNullList<Ingredient> ings = NonNullList.create(); for (JsonElement ele : JsonUtils.getJsonArray(json, "ingredients")) ings.add(CraftingHelper.getIngredient(ele, context)); if (ings.isEmpty()) throw new JsonParseException("No ingredients for shapeless recipe"); ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context); int[] damage = new int[ings.size()]; if (JsonUtils.hasField(json, "damage")) { JsonArray array = JsonUtils.getJsonArray(json, "damage"); if (array.size() > damage.length) throw new JsonParseException("Too many values for damage array: got " + array.size() + ", expected " + damage.length); for (int i = 0; i < array.size(); i++) { JsonElement element = array.get(i); if (!element.isJsonPrimitive() || !element.getAsJsonPrimitive().isNumber()) throw new JsonSyntaxException("Entry in damage array is not a number, got " + element); damage[i] = element.getAsJsonPrimitive().getAsInt(); } } return new DamageableShapelessOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), damage, ings, itemstack); }
@Nonnull @Override public Ingredient parse(JsonContext context, JsonObject json) { if (!CraftingHelper.processConditions(JsonUtils.getJsonArray(json, "conditions"), context)) { if (json.has("fail")) { CraftingHelper.getIngredient(JsonUtils.getJsonObject(json, "failed_condition"), context); } return Ingredient.EMPTY; } return CraftingHelper.getIngredient(JsonUtils.getJsonObject(json, "pass"), context); }
/** * Adds a basic shaped recipe * * @param output The stack that should be produced */ public static void addShapedRecipe(ItemStack output, Object... params) { ResourceLocation location = getNameForRecipe(output); CraftingHelper.ShapedPrimer primer = CraftingHelper.parseShaped(params); ShapedRecipes recipe = new ShapedRecipes(output.getItem().getRegistryName().toString(), primer.width, primer.height, primer.input, output); recipe.setRegistryName(location); GameData.register_impl(recipe); }
/** * This should only be used for registering recipes for vanilla objects and not mod-specific objects. * @param name The name of the recipe. ModID is pre-pended to it. * @param stack The output of the recipe. * @param recipeComponents The recipe components. */ public static ShapedRecipes AddShapedRecipe(String name, String groupName, ItemStack stack, Object... recipeComponents) { name = Prefab.MODID.toLowerCase().replace(' ', '_') + ":" + name; ShapedPrimer primer = CraftingHelper.parseShaped(recipeComponents); ShapedRecipes shapedrecipes = new ShapedRecipes(groupName, primer.width, primer.height, primer.input, stack); shapedrecipes.setRegistryName(name); ForgeRegistries.RECIPES.register(shapedrecipes); return shapedrecipes; }
@Override public Ingredient parse(JsonContext context, JsonObject json) { JsonPrimitive categoryName = json.getAsJsonPrimitive("category"); JsonPrimitive keyName = json.getAsJsonPrimitive("key"); ConfigCategory category = ConfigManager.instance.config.getCategory(categoryName.getAsString()); Property property = category.get(keyName.getAsString()); if (property.getBoolean()) return CraftingHelper.getIngredient(json.getAsJsonObject("then"), context); return CraftingHelper.getIngredient(json.getAsJsonObject("else"), context); }
public VolumetricIngredient(String ingredient, long nanoLitersPerItem) { this.ingredient = CraftingHelper.getIngredient(ingredient); if(this.ingredient == Ingredient.EMPTY) Log.warn("VolumetricIngredient encountered invalid (empty) input ingredient. This is a bug."); this.nanoLitersPerItem = nanoLitersPerItem; }
public VolumetricIngredient(Matter matter, CubeSize size) { this.ingredient = CraftingHelper.getIngredient(matter.getCube(size)); if(this.ingredient == Ingredient.EMPTY) Log.warn("VolumetricIngredient encountered invalid (empty) input ingredient. This is a bug."); this.nanoLitersPerItem = size.nanoLiters; }
private void addShapelessRecipe(IForgeRegistry<IRecipe> reg, ResourceLocation name, ResourceLocation group, @Nonnull ItemStack output, Object... params) { NonNullList<Ingredient> lst = NonNullList.create(); for (Object i : params) lst.add(CraftingHelper.getIngredient(i)); reg.register(new ShapelessRecipes(group == null ? "" : group.toString(), output, lst).setRegistryName(name)); }
@Override public IRecipe parse(JsonContext context, JsonObject json) { return new RandoresTomeRecipe(CraftingHelper.getIngredient(json.get("book"), context)); }
@Override public IRecipe parse(JsonContext context, JsonObject json) { JsonArray pattern = JsonUtils.getJsonArray(json, "pattern"); List<String> strs = new ArrayList<>(); for (JsonElement element : pattern) { strs.add(element.getAsString()); } char[][] grid = new char[strs.size()][]; for (int i = 0; i < strs.size(); i++) { grid[i] = strs.get(i).toCharArray(); } if (grid.length > 3 || (grid.length > 0 && grid[0].length > 3)) { throw new JsonSyntaxException("Pattern may not be larger than 3x3"); } Map<Character, Ingredient> ingredientMap = new HashMap<>(); if (json.has("key")) { JsonObject keys = JsonUtils.getJsonObject(json, "key"); keys.entrySet().forEach(entry -> { String key = entry.getKey(); if (key.length() != 1) { throw new JsonSyntaxException("Keys must be 1 character, was: " + key); } else if (key.equals(" ")) { throw new JsonSyntaxException("' ' is a reserved key"); } else if (key.equals("#")) { throw new JsonSyntaxException("'#' is a reserved key"); } Ingredient ingredient = CraftingHelper.getIngredient(entry.getValue(), context); ingredientMap.put(key.charAt(0), ingredient); }); } String component = JsonUtils.getString(json, "component"); CraftableType type = CraftableTypeRegistry.instance().get(component); if (type == null) { throw new JsonSyntaxException("Unknown component " + component); } RandoresItemRecipe recipe = new RandoresItemRecipe(ingredientMap, type, grid, JsonUtils.getInt(json, "quantity")); RECIPES.put(type, recipe); return recipe; }
public MagibenchRecipe(Item out, int minTier, String entryId, Object... recipe) { this(new ItemStack(out), minTier, entryId, CraftingHelper.parseShaped(recipe)); }
public MagibenchRecipe(Block out, int minTier, String entryId, Object... recipe) { this(new ItemStack(out), minTier, entryId, CraftingHelper.parseShaped(recipe)); }
public MagibenchRecipe(ItemStack out, int minTier, String entryId, Object... recipe) { this(out, minTier, entryId, CraftingHelper.parseShaped(recipe)); }
private DamageableShapedOreRecipe(@Nullable ResourceLocation group, int[] damageAmounts, @Nonnull ItemStack result, CraftingHelper.ShapedPrimer primer) { super(group, result, primer); this.damageAmounts = damageAmounts; mirroredDamageAmounts = mirror(damageAmounts); }
public SealRecipe(ResourceLocation loc, @Nonnull ItemStack result, CraftingHelper.ShapedPrimer recipe) { super(loc, result, recipe); }
private void addShapedRecipe(IForgeRegistry<IRecipe> reg, ResourceLocation name, ResourceLocation group, @Nonnull ItemStack output, Object... params) { ShapedPrimer primer = CraftingHelper.parseShaped(params); reg.register(new ShapedRecipes(group == null ? "" : group.toString(), primer.width, primer.height, primer.input, output).setRegistryName(name)); }
private void addShapedNBTRecipe(IForgeRegistry<IRecipe> reg, ResourceLocation name, ResourceLocation group, @Nonnull ItemStack output, Object... params) { ShapedPrimer primer = CraftingHelper.parseShaped(params); reg.register(new ShapedNBTRecipe(group == null ? "" : group.toString(), primer.width, primer.height, primer.input, output).setRegistryName(name)); }
/** * thin wrapper for addShapedRecipe * * @param output * @param params * @return */ private static IRecipe _addShapedRecipe(ItemStack output, Object... params) { CraftingHelper.ShapedPrimer primer = CraftingHelper.parseShaped(params); ShapedRecipes recipe = new ShapedRecipes(output.getItem().getRegistryName().toString(), primer.width, primer.height, primer.input, output); add(recipe, Util1pt12.buildName(output)); return recipe; }