Skip to content

Commit

Permalink
Fix display of sifter byproducts for materials with no exquisite (Gre…
Browse files Browse the repository at this point in the history
  • Loading branch information
kumquat-ir authored Apr 14, 2024
1 parent 40b2002 commit e9b9425
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
57 changes: 26 additions & 31 deletions src/main/java/gregtech/integration/jei/basic/OreByProduct.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gregtech.integration.jei.basic;

import gregtech.api.GTValues;
import gregtech.api.recipes.chance.output.impl.ChancedItemOutput;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
Expand Down Expand Up @@ -30,10 +29,14 @@
import java.util.ArrayList;
import java.util.List;

import static gregtech.api.GTValues.LV;

public class OreByProduct implements IRecipeWrapper {

private static final List<OrePrefix> ORES = new ArrayList<>();

private static final int NUM_INPUTS = 21;

public static void addOreByProductPrefix(OrePrefix orePrefix) {
if (!ORES.contains(orePrefix)) {
ORES.add(orePrefix);
Expand Down Expand Up @@ -62,14 +65,14 @@ public static void addOreByProductPrefix(OrePrefix orePrefix) {
public OreByProduct(Material material) {
if (ALWAYS_MACHINES == null) {
ALWAYS_MACHINES = ImmutableList.of(
MetaTileEntities.MACERATOR[GTValues.LV].getStackForm(),
MetaTileEntities.MACERATOR[GTValues.LV].getStackForm(),
MetaTileEntities.CENTRIFUGE[GTValues.LV].getStackForm(),
MetaTileEntities.ORE_WASHER[GTValues.LV].getStackForm(),
MetaTileEntities.THERMAL_CENTRIFUGE[GTValues.LV].getStackForm(),
MetaTileEntities.MACERATOR[GTValues.LV].getStackForm(),
MetaTileEntities.MACERATOR[GTValues.LV].getStackForm(),
MetaTileEntities.CENTRIFUGE[GTValues.LV].getStackForm());
MetaTileEntities.MACERATOR[LV].getStackForm(),
MetaTileEntities.MACERATOR[LV].getStackForm(),
MetaTileEntities.CENTRIFUGE[LV].getStackForm(),
MetaTileEntities.ORE_WASHER[LV].getStackForm(),
MetaTileEntities.THERMAL_CENTRIFUGE[LV].getStackForm(),
MetaTileEntities.MACERATOR[LV].getStackForm(),
MetaTileEntities.MACERATOR[LV].getStackForm(),
MetaTileEntities.CENTRIFUGE[LV].getStackForm());
}
OreProperty property = material.getProperty(PropertyKey.ORE);
int oreMultiplier = property.getOreMultiplier();
Expand Down Expand Up @@ -97,7 +100,7 @@ public OreByProduct(Material material) {
// set up machines as inputs
List<ItemStack> simpleWashers = new ArrayList<>();
simpleWashers.add(new ItemStack(Items.CAULDRON));
simpleWashers.add(MetaTileEntities.ORE_WASHER[GTValues.LV].getStackForm());
simpleWashers.add(MetaTileEntities.ORE_WASHER[LV].getStackForm());

if (!material.hasProperty(PropertyKey.BLAST)) {
addToInputs(new ItemStack(Blocks.FURNACE));
Expand All @@ -116,19 +119,19 @@ public OreByProduct(Material material) {

if (washedIn != null && washedIn.getKey() != null) {
hasChemBath = true;
addToInputs(MetaTileEntities.CHEMICAL_BATH[GTValues.LV].getStackForm());
addToInputs(MetaTileEntities.CHEMICAL_BATH[LV].getStackForm());
} else {
addToInputs(ItemStack.EMPTY);
}
if (separatedInto != null && !separatedInto.isEmpty()) {
hasSeparator = true;
addToInputs(MetaTileEntities.ELECTROMAGNETIC_SEPARATOR[GTValues.LV].getStackForm());
addToInputs(MetaTileEntities.ELECTROMAGNETIC_SEPARATOR[LV].getStackForm());
} else {
addToInputs(ItemStack.EMPTY);
}
if (material.hasProperty(PropertyKey.GEM)) {
hasSifter = true;
addToInputs(MetaTileEntities.SIFTER[GTValues.LV].getStackForm());
addToInputs(MetaTileEntities.SIFTER[LV].getStackForm());
} else {
addToInputs(ItemStack.EMPTY);
}
Expand All @@ -141,7 +144,7 @@ public OreByProduct(Material material) {
}

// total number of inputs added
currentSlot += 21;
currentSlot += NUM_INPUTS;

// BASIC PROCESSING

Expand Down Expand Up @@ -256,8 +259,6 @@ public OreByProduct(Material material) {
// sifter
if (hasSifter) {
boolean highOutput = material.hasFlag(MaterialFlags.HIGH_SIFTER_OUTPUT);
ItemStack flawedStack = OreDictUnifier.get(OrePrefix.gemFlawed, material);
ItemStack chippedStack = OreDictUnifier.get(OrePrefix.gemChipped, material);

addToOutputs(material, OrePrefix.gemExquisite, 1);
addGemChance(300, 100, 500, 150, highOutput);
Expand All @@ -267,19 +268,10 @@ public OreByProduct(Material material) {
addGemChance(3500, 500, 5000, 1000, highOutput);
addToOutputs(material, OrePrefix.dustPure, 1);
addGemChance(5000, 750, 2500, 500, highOutput);

if (!flawedStack.isEmpty()) {
addToOutputs(flawedStack);
addGemChance(2500, 300, 2000, 500, highOutput);
} else {
addEmptyOutputs(1);
}
if (!chippedStack.isEmpty()) {
addToOutputs(chippedStack);
addGemChance(3500, 400, 3000, 350, highOutput);
} else {
addEmptyOutputs(1);
}
addToOutputs(material, OrePrefix.gemFlawed, 1);
addGemChance(2500, 300, 2000, 500, highOutput);
addToOutputs(material, OrePrefix.gemChipped, 1);
addGemChance(3500, 400, 3000, 350, highOutput);
} else {
addEmptyOutputs(6);
}
Expand Down Expand Up @@ -345,8 +337,11 @@ private void addToInputs(ItemStack stack) {
}

private void addChance(int base, int tier) {
// this is solely for the chance overlay and tooltip, neither of which care about the ItemStack
chances.put(currentSlot - 1, new ChancedItemOutput(ItemStack.EMPTY, base, tier));
// hacky check to not add a chance for empty stacks
if (!outputs.get(currentSlot - 1 - NUM_INPUTS).get(0).isEmpty()) {
// this is solely for the chance overlay and tooltip, neither of which care about the ItemStack
chances.put(currentSlot - 1, new ChancedItemOutput(ItemStack.EMPTY, base, tier));
}
}

// make the code less :weary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ public void setRecipe(IRecipeLayout recipeLayout, @NotNull OreByProduct recipeWr
new ItemStackTextRenderer(recipeWrapper.getChance(i / 2 + itemInputs.size()),
ChancedOutputLogic.OR),
ITEM_OUTPUT_LOCATIONS.get(i) + 1, ITEM_OUTPUT_LOCATIONS.get(i + 1) + 1, 16, 16, 0, 0);
itemOutputExists.add(itemOutputs.get(i / 2).size() > 0);
itemOutputExists.add(!itemOutputs.get(i / 2).isEmpty());
}

List<List<FluidStack>> fluidInputs = ingredients.getInputs(VanillaTypes.FLUID);
fluidInputExists.clear();
for (int i = 0; i < FLUID_LOCATIONS.size(); i += 2) {
fluidStackGroup.init(i / 2, true, new FluidStackTextRenderer(1, false, 16, 16, null),
FLUID_LOCATIONS.get(i) + 1, FLUID_LOCATIONS.get(i + 1) + 1, 16, 16, 0, 0);
fluidInputExists.add(fluidInputs.get(i / 2).size() > 0);
fluidInputExists.add(!fluidInputs.get(i / 2).isEmpty());
}

itemStackGroup.addTooltipCallback(recipeWrapper::addTooltip);
Expand Down Expand Up @@ -208,7 +208,7 @@ public void drawExtras(@NotNull Minecraft minecraft) {

for (int i = 0; i < ITEM_OUTPUT_LOCATIONS.size(); i += 2) {
// stupid hack to show all sifter slots if the first one exists
if (itemOutputExists.get(i / 2) || (i > 28 * 2 && itemOutputExists.get(28) && hasSifter)) {
if (itemOutputExists.get(i / 2) || (i >= 28 * 2 && hasSifter)) {
slot.draw(minecraft, ITEM_OUTPUT_LOCATIONS.get(i), ITEM_OUTPUT_LOCATIONS.get(i + 1));
}
}
Expand Down

0 comments on commit e9b9425

Please sign in to comment.