diff --git a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java index fb1af11438b..8e062d069c0 100755 --- a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java +++ b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java @@ -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; @@ -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 ORES = new ArrayList<>(); + private static final int NUM_INPUTS = 21; + public static void addOreByProductPrefix(OrePrefix orePrefix) { if (!ORES.contains(orePrefix)) { ORES.add(orePrefix); @@ -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(); @@ -97,7 +100,7 @@ public OreByProduct(Material material) { // set up machines as inputs List 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)); @@ -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); } @@ -141,7 +144,7 @@ public OreByProduct(Material material) { } // total number of inputs added - currentSlot += 21; + currentSlot += NUM_INPUTS; // BASIC PROCESSING @@ -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); @@ -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); } @@ -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: diff --git a/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java b/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java index 635526f3114..db4f2bc6345 100644 --- a/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java @@ -154,7 +154,7 @@ 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> fluidInputs = ingredients.getInputs(VanillaTypes.FLUID); @@ -162,7 +162,7 @@ public void setRecipe(IRecipeLayout recipeLayout, @NotNull OreByProduct recipeWr 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); @@ -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)); } }