Skip to content

Commit f4b0738

Browse files
committed
Fix JEI pages, compare Stacks properly & Spotless
1 parent 4f3deb7 commit f4b0738

File tree

5 files changed

+228
-137
lines changed

5 files changed

+228
-137
lines changed

src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySteamSieve.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ protected IItemHandlerModifiable createExportItemHandler() {
4040
public ModularUI.Builder createUITemplate(EntityPlayer player) {
4141
ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND_STEAM.get(this.isHighPressure), 176,
4242
192)
43-
.label(6, 6, this.getMetaFullName()).shouldColor(false)
44-
.slot(this.importItems, 0, 17, 43, GuiTextures.SLOT_STEAM.get(isHighPressure))
45-
.slot(this.importItems, 1, 35, 43, GuiTextures.SLOT_STEAM.get(isHighPressure),
46-
GuiTextures.STRING_SLOT_OVERLAY)
47-
.progressBar(workableHandler::getProgressPercent, 25, 68, 20, 20,
48-
GuiTextures.PROGRESS_BAR_SIFT_STEAM.get(isHighPressure),
49-
ProgressWidget.MoveType.VERTICAL_INVERTED, workableHandler.getRecipeMap())
50-
.widget((new ImageWidget(79, 77, 18, 18,
51-
GuiTextures.INDICATOR_NO_STEAM.get(this.isHighPressure)))
52-
.setPredicate(() -> this.workableHandler.isHasNotEnoughEnergy()))
53-
.bindPlayerInventory(player.inventory, GuiTextures.SLOT_STEAM.get(this.isHighPressure), 7, 109);
43+
.label(6, 6, this.getMetaFullName()).shouldColor(false)
44+
.slot(this.importItems, 0, 17, 43, GuiTextures.SLOT_STEAM.get(isHighPressure))
45+
.slot(this.importItems, 1, 35, 43, GuiTextures.SLOT_STEAM.get(isHighPressure),
46+
GuiTextures.STRING_SLOT_OVERLAY)
47+
.progressBar(workableHandler::getProgressPercent, 25, 68, 20, 20,
48+
GuiTextures.PROGRESS_BAR_SIFT_STEAM.get(isHighPressure),
49+
ProgressWidget.MoveType.VERTICAL_INVERTED, workableHandler.getRecipeMap())
50+
.widget((new ImageWidget(79, 77, 18, 18,
51+
GuiTextures.INDICATOR_NO_STEAM.get(this.isHighPressure)))
52+
.setPredicate(() -> this.workableHandler.isHasNotEnoughEnergy()))
53+
.bindPlayerInventory(player.inventory, GuiTextures.SLOT_STEAM.get(this.isHighPressure), 7, 109);
5454

5555
for (int y = 0; y < 5; y++) {
5656
for (int x = 0; x < 6; x++) {

src/main/java/gregtech/integration/exnihilo/recipes/CraftingRecipes.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package gregtech.integration.exnihilo.recipes;
22

3-
import exnihilocreatio.ModBlocks;
4-
5-
import exnihilocreatio.ModItems;
6-
73
import gregtech.api.recipes.ModHandler;
84
import gregtech.api.unification.OreDictUnifier;
95
import gregtech.api.unification.material.Materials;
@@ -13,13 +9,15 @@
139
import gregtech.integration.exnihilo.ExNihiloConfig;
1410
import gregtech.integration.exnihilo.ExNihiloModule;
1511
import gregtech.integration.exnihilo.items.ExNihiloPebble;
16-
1712
import gregtech.loaders.recipe.MetaTileEntityLoader;
1813

1914
import net.minecraft.init.Blocks;
2015
import net.minecraft.init.Items;
2116
import net.minecraft.item.ItemStack;
2217

18+
import exnihilocreatio.ModBlocks;
19+
import exnihilocreatio.ModItems;
20+
2321
import static gregtech.api.unification.material.Materials.*;
2422
import static gregtech.api.unification.material.Materials.GraniteRed;
2523
import static gregtech.api.unification.ore.OrePrefix.*;
@@ -46,7 +44,8 @@ public static void registerRecipes() {
4644
// Pebbles
4745
ModHandler.addShapedRecipe("pebble_to_basalt", OreDictUnifier.get(cobble, Basalt, 1), "PP", "PP", 'P',
4846
new ItemStack(ExNihiloModule.pebbleItem, 1, ExNihiloPebble.GTPebbles.BASALT.ordinal()));
49-
ModHandler.addShapedRecipe("pebble_to_black_granite", OreDictUnifier.get(cobble, GraniteBlack, 1), "PP", "PP", 'P',
47+
ModHandler.addShapedRecipe("pebble_to_black_granite", OreDictUnifier.get(cobble, GraniteBlack, 1), "PP", "PP",
48+
'P',
5049
new ItemStack(ExNihiloModule.pebbleItem, 1, ExNihiloPebble.GTPebbles.BLACK_GRANITE.ordinal()));
5150
ModHandler.addShapedRecipe("pebble_to_marble", OreDictUnifier.get(cobble, Marble, 1), "PP", "PP", 'P',
5251
new ItemStack(ExNihiloModule.pebbleItem, 1, ExNihiloPebble.GTPebbles.MARBLE.ordinal()));

src/main/java/gregtech/integration/exnihilo/recipes/MachineRecipes.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package gregtech.integration.exnihilo.recipes;
22

3-
43
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
54
import gregtech.api.recipes.chance.output.ChancedOutputLogic;
65
import gregtech.api.unification.OreDictUnifier;
76
import gregtech.api.util.Mods;
87
import gregtech.integration.exnihilo.ExNihiloConfig;
98
import gregtech.integration.exnihilo.ExNihiloModule;
109

11-
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
12-
1310
import net.minecraft.init.Blocks;
1411
import net.minecraft.item.ItemStack;
1512
import net.minecraftforge.fluids.FluidUtil;
@@ -21,6 +18,7 @@
2118
import exnihilocreatio.modules.AppliedEnergistics2;
2219
import exnihilocreatio.registries.manager.ExNihiloRegistryManager;
2320
import exnihilocreatio.registries.types.Siftable;
21+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
2422

2523
import java.util.ArrayList;
2624
import java.util.List;
@@ -31,10 +29,8 @@
3129
import static gregtech.api.unification.ore.OrePrefix.*;
3230
import static gregtech.integration.exnihilo.ExNihiloModule.*;
3331

34-
3532
public class MachineRecipes {
3633

37-
3834
public static void registerRecipes() {
3935
// Pebbles
4036
COMPRESSOR_RECIPES.recipeBuilder()
@@ -170,11 +166,10 @@ public static void mirrorExNihiloRecipes() {
170166
}
171167
}
172168
}
173-
if (sieveRecipes.containsKey(stack)) {
174-
sieveRecipes.get(stack).add(recipe.getMesh());
175-
} else {
176-
sieveRecipes.put(stack, new ArrayList<>() {{ add(recipe.getMesh()); }});
169+
if (sieveRecipes.keySet().stream().noneMatch(stack::isItemEqual)) {
170+
sieveRecipes.put(stack, new ArrayList<>());
177171
}
172+
sieveRecipes.computeIfAbsent(stack, key -> new ArrayList<>()).add(recipe.getMesh());
178173
builder.buildAndRegister();
179174
}
180175
}
@@ -185,7 +180,7 @@ public static void mirrorExNihiloRecipes() {
185180
if (FluidUtil.getFluidContained(recipe.getFluid()) != null) {
186181
for (List<ItemStack> listStack : recipe.getInputs()) {
187182
for (ItemStack stack : listStack) {
188-
if (extractorRecipes.stream().anyMatch(stack1 -> stack1.isItemEqual(stack))) {
183+
if (extractorRecipes.stream().anyMatch(stack::isItemEqual)) {
189184
continue;
190185
}
191186
extractorRecipes.add(stack);

src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package gregtech.integration.exnihilo.recipes;
22

3-
import exnihilocreatio.registries.types.Siftable;
4-
53
import gregtech.api.unification.OreDictUnifier;
64
import gregtech.integration.IntegrationModule;
75
import gregtech.integration.exnihilo.ExNihiloConfig;
86

9-
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
10-
117
import net.minecraft.block.Block;
128
import net.minecraft.item.ItemStack;
139
import net.minecraft.item.crafting.Ingredient;
10+
import net.minecraftforge.oredict.OreIngredient;
1411

1512
import exnihilocreatio.registries.manager.ExNihiloRegistryManager;
13+
import exnihilocreatio.registries.types.Siftable;
1614
import exnihilocreatio.util.ItemInfo;
17-
15+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
1816

1917
import java.util.ArrayList;
18+
import java.util.Arrays;
2019
import java.util.List;
21-
20+
import java.util.Optional;
2221

2322
/**
24-
* Used for adding/removing recipes to the Sieve for CEu (and addons), drops will be added at {@link net.minecraftforge.fml.common.event.FMLInitializationEvent} to the Ex Nihilo sifting list.
23+
* Used for adding/removing recipes to the Sieve for CEu (and addons), drops will be added at
24+
* {@link net.minecraftforge.fml.common.event.FMLInitializationEvent} to the Ex Nihilo sifting list.
2525
*/
2626
public class SieveDrops {
2727

@@ -49,7 +49,8 @@ private static boolean validateDrops(ItemStack output, int meshlevel, float chan
4949

5050
@SuppressWarnings("unused")
5151
public static void removeDrop(ItemStack input, ItemStack output) {
52-
siftables.entrySet().removeIf(siftable -> siftable.getKey().test(input) && siftable.getValue().removeIf(drop -> drop.getDrop().getItemStack().isItemEqual(output)));
52+
siftables.entrySet().removeIf(siftable -> siftable.getKey().test(input) &&
53+
siftable.getValue().removeIf(drop -> drop.getDrop().getItemStack().isItemEqual(output)));
5354
}
5455

5556
public static void addDrop(Block input, ItemStack output, int meshLevel, float chance) {
@@ -71,7 +72,7 @@ public static void addDrop(String oredict, ItemStack output, int meshLevel, floa
7172
IntegrationModule.logger.error("Cannot find oredict {}!", oredict, new Throwable());
7273
return;
7374
}
74-
addDrop(Ingredient.fromStacks(stacks.toArray(new ItemStack[0])), output, meshLevel, chance);
75+
addDrop(new OreIngredient(oredict), output, meshLevel, chance);
7576
}
7677

7778
public static void addDrop(Ingredient ingredient, ItemStack output, int meshLevel, float chance) {
@@ -82,11 +83,17 @@ public static void addDrop(Ingredient ingredient, Siftable siftable) {
8283
if (!validateDrops(siftable.getDrop().getItemStack(), siftable.getMeshLevel(), siftable.getChance())) {
8384
return;
8485
}
85-
if (siftables.containsKey(ingredient)) {
86-
siftables.get(ingredient).add(siftable);
87-
return;
86+
ItemStack[] matchingStacks = ingredient.getMatchingStacks();
87+
Optional<Ingredient> optionalIngredient = siftables.keySet().stream()
88+
.filter(ingredient1 -> Arrays.stream(ingredient1.getMatchingStacks()).allMatch(stack -> Arrays
89+
.stream(matchingStacks).anyMatch(stack1 -> ItemStack.areItemsEqual(stack, stack1))))
90+
.findFirst();
91+
if (!optionalIngredient.isPresent()) {
92+
siftables.put(ingredient, new ArrayList<>());
93+
} else {
94+
ingredient = optionalIngredient.get();
8895
}
89-
siftables.put(ingredient, new ArrayList<>() {{ add(siftable); }});
96+
siftables.get(ingredient).add(siftable);
9097
}
9198

9299
public static void registerSiftingRecipes() {
@@ -97,11 +104,12 @@ public static void registerSiftingRecipes() {
97104
ExNihiloRegistryManager.SIEVE_REGISTRY.getRegistry().clear();
98105
if (!siftablesDirt.isEmpty()) {
99106
ExNihiloRegistryManager.SIEVE_REGISTRY.register(
100-
Ingredient.fromStacks(OreDictUnifier.getAllWithOreDictionaryName("dirt").toArray(new ItemStack[0])),
107+
Ingredient.fromStacks(
108+
OreDictUnifier.getAllWithOreDictionaryName("dirt").toArray(new ItemStack[0])),
101109
siftablesDirt);
102110
}
103111
}
104-
siftables.forEach((ExNihiloRegistryManager.SIEVE_REGISTRY::register));
112+
siftables.forEach(ExNihiloRegistryManager.SIEVE_REGISTRY::register);
105113

106114
siftables = null; // let this get GC'd, no more eating my memory
107115
}

0 commit comments

Comments
 (0)