Skip to content

Commit

Permalink
Finish preparing for alloy support
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg committed Sep 28, 2024
1 parent 74cacf2 commit 8513ab9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ITag;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import queengooborg.plusticreforged.Resources;
import queengooborg.plusticreforged.api.Item;
import queengooborg.plusticreforged.api.ItemTag;
import queengooborg.plusticreforged.api.Material;
import queengooborg.plusticreforged.api.MaterialType;
import queengooborg.plusticreforged.config.ModInfo;
Expand Down Expand Up @@ -56,44 +57,48 @@ public void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {

Consumer<IFinishedRecipe> wrappedConsumer = material.condition == null ? consumer : withCondition(consumer, material.condition);

boolean isTag = material.ingredient.isTag;
ITag<Item> tag = getTag(material.ingredient.location.getNamespace(), material.ingredient.location.getPath());

ItemOutput output = isTag ? ItemNameOutput.fromTag(tag, 1) : ItemNameOutput.fromName(material.ingredient.location);
Ingredient input = isTag ? Ingredient.of(tag) : ItemNameIngredient.from(material.ingredient.location);

if (material.type == MaterialType.METAL) {
// Metals are pretty straightforward
metalMelting(wrappedConsumer, material.moltenFluid.getFluid(), material.id, false, meltingDir + "metal/", true);
metalTagCasting(wrappedConsumer, material.moltenFluid.FLUID_OBJECT, material.id, castingDir + "metal/", false);
} else {
// Other materials are a bit more complex
int fluidValue = FluidValues.INGOT;

if (material.type == MaterialType.STONE || material.type == MaterialType.WOOD) {
fluidValue = FluidValues.METAL_BRICK;
ItemCastingRecipeBuilder.basinRecipe(output).setFluidAndTime(material.moltenFluid.FLUID_OBJECT, true, fluidValue).build(wrappedConsumer, this.modResource(castingDir + material.id));
} else if (material.type == MaterialType.GEM || material.type == MaterialType.POWDER) {
fluidValue = FluidValues.GEM;
castingWithCast(wrappedConsumer, material.moltenFluid.FLUID_OBJECT, fluidValue, TinkerSmeltery.gemCast, output, castingDir + (material.type == MaterialType.GEM ? "gem/" : "powder/") + material.id);

// XXX Create casting recipe for gem blocks

// ItemCastingRecipeBuilder.basinRecipe(Blocks.EMERALD_BLOCK)
// .setFluidAndTime(TinkerFluids.moltenEmerald, false, FluidValues.GEM_BLOCK)
// .build(consumer, modResource(folder + "emerald/block"));
// ResourceLocation gemBlock = new ResourceLocation(material.item.getNamespace(), material.item.getPath() + "_block");
// // XXX Make sure the gem block exists

// From Tinkers' Construct:
// ItemCastingRecipeBuilder.tableRecipe(ItemNameOutput.fromName(gemBlock)).setFluidAndTime(material.moltenFluid.FLUID_OBJECT, true, fluidValue).build(wrappedConsumer, this.modResource(castingDir + material.id));
if (material.ingredient instanceof Item) {
Item ingredient = (Item) material.ingredient;
boolean isTag = ingredient instanceof ItemTag;

ITag<net.minecraft.item.Item> tag = getTag(ingredient.location.getNamespace(), ingredient.location.getPath());

ItemOutput output = isTag ? ItemNameOutput.fromTag(tag, 1) : ItemNameOutput.fromName(ingredient.location);
Ingredient input = isTag ? Ingredient.of(tag) : ItemNameIngredient.from(ingredient.location);

if (material.type == MaterialType.METAL) {
// Metals are pretty straightforward
metalMelting(wrappedConsumer, material.moltenFluid.getFluid(), material.id, false, meltingDir + "metal/", true);
metalTagCasting(wrappedConsumer, material.moltenFluid.FLUID_OBJECT, material.id, castingDir + "metal/", false);
} else {
// We should never reach this point yet
log.warn("Unhandled material " + material.id + " of type: " + material.type);
// Other materials are a bit more complex
int fluidValue = FluidValues.INGOT;

if (material.type == MaterialType.STONE || material.type == MaterialType.WOOD) {
fluidValue = FluidValues.METAL_BRICK;
ItemCastingRecipeBuilder.basinRecipe(output).setFluidAndTime(material.moltenFluid.FLUID_OBJECT, true, fluidValue).build(wrappedConsumer, this.modResource(castingDir + material.id));
} else if (material.type == MaterialType.GEM || material.type == MaterialType.POWDER) {
fluidValue = FluidValues.GEM;
castingWithCast(wrappedConsumer, material.moltenFluid.FLUID_OBJECT, fluidValue, TinkerSmeltery.gemCast, output, castingDir + (material.type == MaterialType.GEM ? "gem/" : "powder/") + material.id);

// XXX Create casting recipe for gem blocks

// ItemCastingRecipeBuilder.basinRecipe(Blocks.EMERALD_BLOCK)
// .setFluidAndTime(TinkerFluids.moltenEmerald, false, FluidValues.GEM_BLOCK)
// .build(consumer, modResource(folder + "emerald/block"));
// ResourceLocation gemBlock = new ResourceLocation(material.item.getNamespace(), material.item.getPath() + "_block");
// // XXX Make sure the gem block exists

// From Tinkers' Construct:
// ItemCastingRecipeBuilder.tableRecipe(ItemNameOutput.fromName(gemBlock)).setFluidAndTime(material.moltenFluid.FLUID_OBJECT, true, fluidValue).build(wrappedConsumer, this.modResource(castingDir + material.id));
} else {
// We should never reach this point yet
log.warn("Unhandled material " + material.id + " of type: " + material.type);
}

MeltingRecipeBuilder.melting(input, material.moltenFluid.getFluid(), fluidValue, 1.0f).build(wrappedConsumer, modResource(meltingDir + material.id));
materialMeltingCasting(wrappedConsumer, material.resourceLocation, material.moltenFluid.FLUID_OBJECT, false, FluidValues.INGOT * 2, materialDir);
}

MeltingRecipeBuilder.melting(input, material.moltenFluid.getFluid(), fluidValue, 1.0f).build(wrappedConsumer, modResource(meltingDir + material.id));
materialMeltingCasting(wrappedConsumer, material.resourceLocation, material.moltenFluid.FLUID_OBJECT, false, FluidValues.INGOT * 2, materialDir);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public RubyMaterial() {
"ruby",
"Ruby",
new Description("A red gemstone that is said to increase the owner's vitality.", ""),
new ItemTag("forge", "gems/ruby", true),
new ItemTag("forge", "gems/ruby"),
null,
2,
MaterialType.GEM,
Expand Down

0 comments on commit 8513ab9

Please sign in to comment.