Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisis committed Nov 20, 2024
1 parent f411bce commit 446e929
Show file tree
Hide file tree
Showing 2 changed files with 299 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import java.util.List;
import java.util.Objects;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;

import bartworks.system.material.Werkstoff;
import bartworks.system.material.WerkstoffLoader;
import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable;
Expand All @@ -45,9 +49,6 @@
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.common.items.behaviors.BehaviourDataOrb;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;

public class CellLoader implements IWerkstoffRunnable {

Expand All @@ -61,159 +62,168 @@ public void run(Werkstoff werkstoff) {
|| werkstoff.getStats()
.isCentrifuge())
&& !werkstoff.hasItemType(dust)) {

if (werkstoff.getContents().getValue().size() > 0) {

List<FluidStack> flOutputs = new ArrayList<>();
List<ItemStack> stOutputs = new ArrayList<>();
HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>();
int cells = 0;
for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents()

if (werkstoff.getContents()
.getValue()
.toArray(new Pair[0])) {
if (container.getKey() instanceof Materials) {
if ((((Materials) container.getKey()).hasCorrespondingGas()
|| ((Materials) container.getKey()).hasCorrespondingFluid()
|| ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID)
&& ((Materials) container.getKey()).getDust(0) == null) {
FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue());
if (tmpFl == null || tmpFl.getFluid() == null) {
tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue());
}
flOutputs.add(tmpFl);
if (flOutputs.size() > 1) {
.size() > 0) {

List<FluidStack> flOutputs = new ArrayList<>();
List<ItemStack> stOutputs = new ArrayList<>();
HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>();
int cells = 0;
for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents()
.getValue()
.toArray(new Pair[0])) {
if (container.getKey() instanceof Materials) {
if ((((Materials) container.getKey()).hasCorrespondingGas()
|| ((Materials) container.getKey()).hasCorrespondingFluid()
|| ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID)
&& ((Materials) container.getKey()).getDust(0) == null) {
FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue());
if (tmpFl == null || tmpFl.getFluid() == null) {
tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue());
}
flOutputs.add(tmpFl);
if (flOutputs.size() > 1) {
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Materials) container.getKey()).getCells(container.getValue()));
tracker.put(
container.getKey(),
new Pair<>(container.getValue(), stOutputs.size() - 1));
} else {
stOutputs.add(
((Materials) container.getKey()).getCells(
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
cells += container.getValue();
}
} else {
if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue;
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Materials) container.getKey()).getCells(container.getValue()));
stOutputs.add(((Materials) container.getKey()).getDust(container.getValue()));
tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1));
} else {
stOutputs.add(
((Materials) container.getKey()).getCells(
((Materials) container.getKey()).getDust(
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
cells += container.getValue();
}
} else {
if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue;
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Materials) container.getKey()).getDust(container.getValue()));
tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1));
} else if (container.getKey() instanceof Werkstoff) {
if (((Werkstoff) container.getKey()).getStats()
.isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) {
FluidStack tmpFl = ((Werkstoff) container.getKey())
.getFluidOrGas(1000 * container.getValue());
if (tmpFl == null || tmpFl.getFluid() == null) {
tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue());
}
flOutputs.add(tmpFl);
if (flOutputs.size() > 1) {
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue()));
tracker.put(
container.getKey(),
new Pair<>(container.getValue(), stOutputs.size() - 1));
} else {
stOutputs.add(
((Werkstoff) container.getKey()).get(
cell,
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
cells += container.getValue();
}
} else {
stOutputs.add(
((Materials) container.getKey()).getDust(
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
}
} else if (container.getKey() instanceof Werkstoff) {
if (((Werkstoff) container.getKey()).getStats()
.isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) {
FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue());
if (tmpFl == null || tmpFl.getFluid() == null) {
tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue());
}
flOutputs.add(tmpFl);
if (flOutputs.size() > 1) {
if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue;
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue()));
stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue()));
tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1));
} else {
stOutputs.add(
((Werkstoff) container.getKey()).get(
cell,
dust,
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
cells += container.getValue();
}
} else {
if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue;
if (!tracker.containsKey(container.getKey())) {
stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue()));
tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1));
} else {
stOutputs.add(
((Werkstoff) container.getKey()).get(
dust,
tracker.get(container.getKey())
.getKey() + container.getValue()));
stOutputs.remove(
tracker.get(container.getKey())
.getValue() + 1);
}
}
}
}
ItemStack input = werkstoff.get(cell);
input.stackSize = 1;
ItemStack input = werkstoff.get(cell);
input.stackSize = 1;

int cellEmpty = cells - 1;
int cellEmpty = cells - 1;

stOutputs.add(Materials.Empty.getCells(-cellEmpty));
if (werkstoff.getStats()
.isElektrolysis())
RecipeMaps.electrolyzerRecipes.add(
new GTRecipe(
true,
new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null },
stOutputs.toArray(new ItemStack[0]),
null,
null,
new FluidStack[] { null },
new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null },
(int) Math.max(
1L,
Math.abs(
werkstoff.getStats()
.getProtons()
* werkstoff.getContents()
.getValue()
.size())),
Math.min(
4,
werkstoff.getContents()
.getValue()
.size())
* 30,
0));
if (werkstoff.getStats()
.isCentrifuge())
RecipeMaps.centrifugeRecipes.add(
new GTRecipe(
true,
new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null },
stOutputs.toArray(new ItemStack[0]),
null,
null,
new FluidStack[] { null },
new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null },
(int) Math.max(
1L,
Math.abs(
werkstoff.getStats()
.getMass()
* werkstoff.getContents()
.getValue()
.size())),
Math.min(
4,
werkstoff.getContents()
.getValue()
.size())
* 5,
0));
} else {
GTLog.err.println("Autogenerated recipe(s) using Werkstoff material '" + werkstoff.getDefaultName() + "' (fluid) removed due to no contents in material definition.");
}
stOutputs.add(Materials.Empty.getCells(-cellEmpty));
if (werkstoff.getStats()
.isElektrolysis())
RecipeMaps.electrolyzerRecipes.add(
new GTRecipe(
true,
new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null },
stOutputs.toArray(new ItemStack[0]),
null,
null,
new FluidStack[] { null },
new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null },
(int) Math.max(
1L,
Math.abs(
werkstoff.getStats()
.getProtons()
* werkstoff.getContents()
.getValue()
.size())),
Math.min(
4,
werkstoff.getContents()
.getValue()
.size())
* 30,
0));
if (werkstoff.getStats()
.isCentrifuge())
RecipeMaps.centrifugeRecipes.add(
new GTRecipe(
true,
new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null },
stOutputs.toArray(new ItemStack[0]),
null,
null,
new FluidStack[] { null },
new FluidStack[] { !flOutputs.isEmpty() ? flOutputs.get(0) : null },
(int) Math.max(
1L,
Math.abs(
werkstoff.getStats()
.getMass()
* werkstoff.getContents()
.getValue()
.size())),
Math.min(
4,
werkstoff.getContents()
.getValue()
.size())
* 5,
0));
} else {
GTLog.err.println(
"Autogenerated recipe(s) using Werkstoff material '" + werkstoff.getDefaultName()
+ "' (fluid) removed due to no contents in material definition.");
}
}

// Tank "Recipe"
Expand Down
Loading

0 comments on commit 446e929

Please sign in to comment.