Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gem rework #223

Merged
merged 4 commits into from
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static void register() {
Diamond = new Material.Builder(276, "diamond")
.gem(3).ore()
.color(0xC8FFFF).iconSet(DIAMOND)
.flags(GENERATE_BOLT_SCREW, GENERATE_LENS, GENERATE_GEAR, NO_SMASHING, NO_SMELTING, FLAMMABLE,
.flags(GENERATE_BOLT_SCREW, GENERATE_LENS, GENERATE_GEAR, NO_SMASHING, NO_SMELTING,
HIGH_SIFTER_OUTPUT, DISABLE_DECOMPOSITION, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES)
.components(Carbon, 1)
.toolStats(8.0f, 3.0f, 1280, 15)
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gregtech.api.unification.stack.MaterialStack;
import gregtech.api.util.LocalizationUtils;
import gregtech.api.util.function.TriConsumer;
import gregtech.common.ConfigHolder;
import net.minecraft.client.resources.I18n;
import org.apache.commons.lang3.Validate;
import stanhebben.zenscript.annotations.ZenClass;
Expand Down Expand Up @@ -75,9 +76,9 @@ public class OrePrefix {
// A regular Gem worth one Dust. Introduced by Eloraam
public static final OrePrefix gem = new OrePrefix("gem", M, null, MaterialIconType.gem, ENABLE_UNIFICATION, hasGemProperty);
// A regular Gem worth one small Dust. Introduced by TerraFirmaCraft
public static final OrePrefix gemChipped = new OrePrefix("gemChipped", M / 4, null, MaterialIconType.gemChipped, ENABLE_UNIFICATION, hasGemProperty);
public static final OrePrefix gemChipped = new OrePrefix("gemChipped", M / 4, null, MaterialIconType.gemChipped, ENABLE_UNIFICATION, hasGemProperty.and(unused -> ConfigHolder.U.generateLowQualityGems));
// A regular Gem worth two small Dusts. Introduced by TerraFirmaCraft
public static final OrePrefix gemFlawed = new OrePrefix("gemFlawed", M / 2, null, MaterialIconType.gemFlawed, ENABLE_UNIFICATION, hasGemProperty);
public static final OrePrefix gemFlawed = new OrePrefix("gemFlawed", M / 2, null, MaterialIconType.gemFlawed, ENABLE_UNIFICATION, hasGemProperty.and(unused -> ConfigHolder.U.generateLowQualityGems));
// A regular Gem worth two Dusts. Introduced by TerraFirmaCraft
public static final OrePrefix gemFlawless = new OrePrefix("gemFlawless", M * 2, null, MaterialIconType.gemFlawless, ENABLE_UNIFICATION, hasGemProperty);
// A regular Gem worth four Dusts. Introduced by TerraFirmaCraft
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gregtech/common/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ public static class UnofficialOptions {
@Config.RequiresWorldRestart
public double multiblockSteamToEU = 0.5;

@Config.Comment("Whether to generate flawed and chipped gems for materials and recipes involving them. Useful for mods like Terrafirmacraft. Default: false")
public boolean generateLowQualityGems = false;

public static class GT5U {

@Config.Comment("Require Wrench to break machines? Default: false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gregtech.api.recipes.builders.BlastRecipeBuilder;
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.MarkerMaterials;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.properties.DustProperty;
Expand All @@ -29,8 +30,9 @@

public class MaterialRecipeHandler {

private static final List<OrePrefix> GEM_ORDER = Arrays.asList(
OrePrefix.gemChipped, OrePrefix.gemFlawed, OrePrefix.gem, OrePrefix.gemFlawless, OrePrefix.gemExquisite);
private static final List<OrePrefix> GEM_ORDER = ConfigHolder.U.generateLowQualityGems ? Arrays.asList(
OrePrefix.gemChipped, OrePrefix.gemFlawed, OrePrefix.gem, OrePrefix.gemFlawless, OrePrefix.gemExquisite) :
Arrays.asList(OrePrefix.gem, OrePrefix.gemFlawless, OrePrefix.gemExquisite);

private static final Set<Material> circuitRequiringMaterials = new HashSet<>();

Expand All @@ -46,7 +48,7 @@ public static void register() {
OrePrefix.dustTiny.addProcessingHandler(PropertyKey.DUST, MaterialRecipeHandler::processTinyDust);

for (OrePrefix orePrefix : GEM_ORDER) {
orePrefix.addProcessingHandler(PropertyKey.GEM, MaterialRecipeHandler::processGem);
orePrefix.addProcessingHandler(PropertyKey.GEM, MaterialRecipeHandler::processGemConversion);
}

setMaterialRequiresCircuit(Materials.Silicon);
Expand All @@ -57,32 +59,39 @@ public static void setMaterialRequiresCircuit(Material material) {
}

public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty property) {
ItemStack dustStack = OreDictUnifier.get(dustPrefix, mat);
if (mat.hasProperty(PropertyKey.GEM)) {
ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, mat);
ItemStack tinyDarkAshStack = OreDictUnifier.get(OrePrefix.dustTiny, Materials.DarkAsh);
ItemStack smallDarkAshStack = OreDictUnifier.get(OrePrefix.dustSmall, Materials.DarkAsh);

if (mat.hasFlag(CRYSTALLIZABLE)) {

RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder()
.input(dustPrefix, mat)
.fluidInputs(Materials.Water.getFluid(200))
.inputs(dustStack)
.fluidInputs(Materials.Water.getFluid(250))
.chancedOutput(gemStack, 7000, 1000)
.duration(1500).EUt(24)
.duration(1200).EUt(24)
.buildAndRegister();

RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder()
.input(dustPrefix, mat)
.fluidInputs(Materials.DistilledWater.getFluid(36))
.chancedOutput(gemStack, 9000, 1000)
.duration(1200).EUt(24)
.inputs(dustStack)
.fluidInputs(Materials.DistilledWater.getFluid(50))
.outputs(gemStack)
.duration(600).EUt(24)
.buildAndRegister();
}

} else if (!mat.hasFlag(EXPLOSIVE) && !mat.hasFlag(FLAMMABLE)) {
if (!mat.hasFlag(EXPLOSIVE) && !mat.hasFlag(FLAMMABLE)) {
RecipeMaps.IMPLOSION_RECIPES.recipeBuilder()
.input(dustPrefix, mat, 4)
.outputs(GTUtility.copyAmount(3, gemStack), GTUtility.copyAmount(2, tinyDarkAshStack))
.inputs(GTUtility.copyAmount(4, dustStack))
.outputs(GTUtility.copyAmount(3, gemStack), smallDarkAshStack)
.explosivesAmount(2)
.buildAndRegister();

RecipeMaps.IMPLOSION_RECIPES.recipeBuilder()
.inputs(GTUtility.copyAmount(4, dustStack))
.outputs(GTUtility.copyAmount(3, gemStack), smallDarkAshStack)
.explosivesType(MetaItems.DYNAMITE.getStackForm())
.buildAndRegister();
}

} else if (mat.hasProperty(PropertyKey.INGOT)) {
Expand All @@ -98,7 +107,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty
int duration = Math.max(1, (int) (mat.getAverageMass() * blastTemp / 50L));

BlastRecipeBuilder ingotSmeltingBuilder = RecipeMaps.BLAST_RECIPES.recipeBuilder()
.input(dustPrefix, mat)
.inputs(dustStack)
.outputs(ingotStack)
.blastFurnaceTemp(blastTemp)
.duration(duration).EUt(120);
Expand All @@ -119,7 +128,7 @@ public static void processDust(OrePrefix dustPrefix, Material mat, DustProperty
} else {
if (mat.hasFlag(GENERATE_PLATE) && !mat.hasFlag(EXCLUDE_PLATE_COMPRESSOR_RECIPE)) {
RecipeMaps.COMPRESSOR_RECIPES.recipeBuilder()
.input(dustPrefix, mat)
.inputs(dustStack)
.outputs(OreDictUnifier.get(OrePrefix.plate, mat))
.buildAndRegister();
}
Expand Down Expand Up @@ -270,7 +279,7 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP

}

public static void processGem(OrePrefix gemPrefix, Material material, GemProperty property) {
public static void processGemConversion(OrePrefix gemPrefix, Material material, GemProperty property) {
long materialAmount = gemPrefix.materialAmount;
ItemStack crushedStack = OreDictUnifier.getDust(material, materialAmount);

Expand All @@ -284,10 +293,20 @@ public static void processGem(OrePrefix gemPrefix, Material material, GemPropert
if (!prevStack.isEmpty()) {
ModHandler.addShapelessRecipe(String.format("gem_to_gem_%s_%s", prevPrefix, material), prevStack,
"h", new UnificationEntry(gemPrefix, material));
RecipeMaps.FORGE_HAMMER_RECIPES.recipeBuilder()

RecipeMaps.CUTTER_RECIPES.recipeBuilder()
.input(gemPrefix, material)
.outputs(prevStack)
.duration(20).EUt(16)
.duration(20)
.EUt(16)
.buildAndRegister();

RecipeMaps.LASER_ENGRAVER_RECIPES.recipeBuilder()
.inputs(prevStack)
.notConsumable(OrePrefix.craftingLens, MarkerMaterials.Color.White)
.output(gemPrefix, material)
.duration(300)
.EUt(240)
.buildAndRegister();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gregtech.api.recipes.ModHandler;
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
Expand Down Expand Up @@ -258,27 +259,35 @@ public static void processCrushedPurified(OrePrefix purifiedPrefix, Material mat
ItemStack chippedStack = OreDictUnifier.get(OrePrefix.gemChipped, material);

if (material.hasFlag(HIGH_SIFTER_OUTPUT)) {
RecipeMaps.SIFTER_RECIPES.recipeBuilder()
RecipeBuilder<SimpleRecipeBuilder> builder = RecipeMaps.SIFTER_RECIPES.recipeBuilder()
.input(purifiedPrefix, material)
.chancedOutput(exquisiteStack, 300, 60)
.chancedOutput(flawlessStack, 1200, 180)
.chancedOutput(gemStack, 4500, 540)
.chancedOutput(flawedStack, 1400, 240)
.chancedOutput(chippedStack, 2800, 320)
.chancedOutput(dustStack, 3500, 500)
.duration(800).EUt(16)
.buildAndRegister();
.chancedOutput(exquisiteStack, 500, 150)
.chancedOutput(flawlessStack, 1500, 200)
.chancedOutput(gemStack, 5000, 1000)
.chancedOutput(dustStack, 2500, 500)
.duration(800).EUt(16);

if (!flawedStack.isEmpty())
builder.chancedOutput(flawedStack, 2000, 500);
if (!chippedStack.isEmpty())
builder.chancedOutput(chippedStack, 3000, 350);

builder.buildAndRegister();
} else {
RecipeMaps.SIFTER_RECIPES.recipeBuilder()
RecipeBuilder<SimpleRecipeBuilder> builder = RecipeMaps.SIFTER_RECIPES.recipeBuilder()
.input(purifiedPrefix, material)
.chancedOutput(exquisiteStack, 100, 30)
.chancedOutput(flawlessStack, 400, 70)
.chancedOutput(gemStack, 1500, 300)
.chancedOutput(flawedStack, 2000, 240)
.chancedOutput(chippedStack, 4000, 320)
.chancedOutput(dustStack, 5000, 600)
.duration(800).EUt(16)
.buildAndRegister();
.chancedOutput(exquisiteStack, 300, 100)
.chancedOutput(flawlessStack, 1000, 150)
.chancedOutput(gemStack, 3500, 500)
.chancedOutput(dustStack, 5000, 750)
.duration(800).EUt(16);

if (!flawedStack.isEmpty())
builder.chancedOutput(flawedStack, 2500, 300);
if (!exquisiteStack.isEmpty())
builder.chancedOutput(chippedStack, 3500, 400);

builder.buildAndRegister();
}
}
processMetalSmelting(purifiedPrefix, material, property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ private static void registerMixingCrystallizationRecipes() {

RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder()
.input(OrePrefix.dust, Materials.SiliconDioxide)
.fluidInputs(Materials.DistilledWater.getFluid(200))
.fluidInputs(Materials.DistilledWater.getFluid(250))
.chancedOutput(OreDictUnifier.get(OrePrefix.gem, Materials.Quartzite), 1000, 1000)
.duration(1500).EUt(24).buildAndRegister();
.duration(1200).EUt(24).buildAndRegister();

//todo find UU-Matter replacement
// RecipeMaps.AUTOCLAVE_RECIPES.recipeBuilder()
Expand Down