TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(pair.getLeft(), pair.getRight()), fluid)); RecipeMatch.ofNBT(castIngot), fluid, ingotOre.getRight())); RecipeMatch.ofNBT(castNugget), fluid, nuggetOre.getRight())); RecipeMatch.ofNBT(castPlate), fluid, plateOre.getRight())); RecipeMatch.ofNBT(castGear), fluid, gearOre.getRight())); TinkerRegistry.registerTableCasting(new CastingRecipe(castIngot, RecipeMatch.of(ingotOre.getLeft()), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castNugget, RecipeMatch.of(nuggetOre.getLeft()), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castPlate, RecipeMatch.of(plateOre.getLeft()), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castGear, RecipeMatch.of(gearOre.getLeft()), fs, true, true));
@Override protected int repairCustom(Material material, NonNullList<ItemStack> repairItems) { Optional<RecipeMatch.Match> matchOptional = RecipeMatch.of(TinkerTools.sharpeningKit).matches(repairItems); if(!matchOptional.isPresent()) { return 0; } RecipeMatch.Match match = matchOptional.get(); for(ItemStack stacks : match.stacks) { // invalid material? if(TinkerTools.sharpeningKit.getMaterial(stacks) != material) { return 0; } } RecipeMatch.removeMatch(repairItems, match); HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); float durability = stats.durability * match.amount * TinkerTools.sharpeningKit.getCost(); durability /= Material.VALUE_Ingot; return (int) (durability); }
@Override public List<List<ItemStack>> getItems() { ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder(); for(RecipeMatch rm : items) { List<ItemStack> in = rm.getInputs(); if(!in.isEmpty()) { builder.add(in); } } return builder.build(); } }
int amount = known.get(fluid) / output.getCount(); output.setCount(1); TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(output, amount), fluid)); log.trace("Added automatic melting recipe for {} ({} {})", irecipe.getRecipeOutput().toString(), amount, fluid .getName());
/** Registers a casting recipe for the casting basin */ public static void registerBasinCasting(ItemStack output, ItemStack cast, Fluid fluid, int amount) { RecipeMatch rm = null; if(!cast.isEmpty()) { rm = RecipeMatch.ofNBT(cast); } registerBasinCasting(new CastingRecipe(output, rm, fluid, amount)); }
public boolean matches(ItemStack input) { return this.input != null && this.input.matches(ListUtil.getListFrom(input)).isPresent(); }
protected int calculateRepairAmount(List<Material> materials, NonNullList<ItemStack> repairItems) { Set<Material> materialsMatched = Sets.newHashSet(); float durability = 0f; // try to match each material once for(int index : getRepairParts()) { Material material = materials.get(index); if(materialsMatched.contains(material)) { continue; } // custom repairing durability += repairCustom(material, repairItems) * getRepairModifierForPart(index); Optional<RecipeMatch.Match> matchOptional = material.matches(repairItems); if(matchOptional.isPresent()) { RecipeMatch.Match match = matchOptional.get(); HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); if(stats != null) { materialsMatched.add(material); durability += ((float) stats.durability * (float) match.amount * getRepairModifierForPart(index)) / 144f; RecipeMatch.removeMatch(repairItems, match); } } } durability *= 1f + ((float) materialsMatched.size() - 1) / 9f; return (int) durability; }
/** Removes the match from the stacks. Has to be ensured that the match is contained in the stacks. */ public static void removeMatch(NonNullList<ItemStack> stacks, Match match) { int[] amountsRemoved = new int[match.stacks.size()]; removeOrder(stacks, match.stacks, amountsRemoved); removeRemaining(stacks, match.stacks, amountsRemoved); }
@Subscribe public void postInit(FMLPostInitializationEvent event) { registerSmelteryFuel(); registerMeltingCasting(); // register remaining cast creation for(FluidStack fs : castCreationFluids) { TinkerRegistry.registerTableCasting(new ItemStack(cast), ItemStack.EMPTY, fs.getFluid(), fs.amount); TinkerRegistry.registerTableCasting(new CastingRecipe(castGem, RecipeMatch.of("gemEmerald"), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castIngot, RecipeMatch.of("ingotBrick"), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castIngot, RecipeMatch.of("ingotBrickNether"), fs, true, true)); TinkerRegistry.registerTableCasting(new CastingRecipe(castIngot, new RecipeMatch.Item(TinkerCommons.searedBrick, 1), fs, true, true)); } proxy.postInit(); TinkerRegistry.tabSmeltery.setDisplayIcon(new ItemStack(searedTank)); }
/** Registers a casting recipe for casting table */ public static void registerTableCasting(ItemStack output, ItemStack cast, Fluid fluid, int amount) { RecipeMatch rm = null; if(cast != ItemStack.EMPTY) { rm = RecipeMatch.ofNBT(cast); } registerTableCasting(new CastingRecipe(output, rm, fluid, amount)); }
public boolean matches(ItemStack stack) { return input.matches(ListUtil.getListFrom(stack)).isPresent(); }
RecipeMatch.removeMatch(stacks, match); break; RecipeMatch.removeMatch(stacks, match); RecipeMatch.removeMatch(usedStacks, match);
public static RecipeMatch of(String oredict, int matched) { return of(oredict, 1, matched); }
@Override public void apply() { RecipeMatch rm = null; if(cast != null) { List<ItemStack> validCasts = cast.getItems().stream().map(CraftTweakerMC::getItemStack).collect(Collectors.toList()); if(validCasts.isEmpty()) CraftTweakerAPI.logInfo("Could not find matching items for " + cast.toString() + ". Substituting empty cast for recipe with output " + output.getDisplayName()); else if(validCasts.size() == 1) //Keep compat to old handler if(validCasts.get(0).getMetadata() == OreDictionary.WILDCARD_VALUE) { rm = RecipeMatch.of(validCasts, output.getCount()); } else { rm = RecipeMatch.ofNBT(validCasts.get(0), output.getCount()); } else rm = RecipeMatch.of(validCasts, output.getCount()); } if(table) TinkerRegistry.registerTableCasting(new CastingRecipeTweaker(output, rm, new FluidStack(fluid, amount), time, consumeCast, false)); else TinkerRegistry.registerBasinCasting(new CastingRecipeTweaker(output, rm, new FluidStack(fluid, amount), time, consumeCast, false)); }
public static RecipeMatch ofNBT(ItemStack stack) { return ofNBT(stack, 1); }
@Override public boolean matches(ItemStack cast, Fluid fluid) { if((cast.isEmpty() && this.cast == null) || (this.cast != null && this.cast.matches(ListUtil.getListFrom(cast)).isPresent())) { return this.fluid.getFluid() == fluid; } return false; }
RecipeMatch.removeMatch(materialItems, match.get());
@Override public List<List<ItemStack>> getItems() { ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder(); for(RecipeMatch rm : items) { List<ItemStack> in = rm.getInputs(); if(!in.isEmpty()) { builder.add(in); } } return builder.build(); }
public static RecipeMatch of(List<ItemStack> oredict) { return of(oredict, 1); }
RecipeMatch.ofNBT(stack), fs, true, true)); RecipeMatch rm = RecipeMatch.ofNBT(clayCast); FluidStack fs = new FluidStack(fluid, toolPart.getCost()); TinkerRegistry.registerTableCasting(new CastingRecipe(stack, rm, fs, true, false)); RecipeMatch.ofNBT(stack), fs, true, true)); RecipeMatch.ofNBT(stack), fs, true, true));