mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 14:34:33 +00:00
Minor cleanups (#50)
* Finalize, minor alloc reduction Also enable Jabel and generic injection * Update dependencies.gradle * Clean up Machine a bit * spotless more enhanced instanceof * Update ModuleMachine.java * More clen * WARN: Removed exception catching * Many, many tiny patches + birthday fix * Spotless * Spotless again * Fix getLow and clamp tolerance value * Revert event -> ignored on unused event parameters * Rename instanceof variables * Update Machine.java * Use StringBuilder * Cache getStack() * Oops, Jabel can't handle that * Spotless * Spotless again My IDE was fighting with it * Remove unused elements + scream test success
This commit is contained in:
1 parent
6b4f3eb1c7
commit
f0f14bb278
325 files changed
+1205
-1868
No files matched your search
@@ -9,6 +9,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
@@ -43,8 +44,9 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
for (Map.Entry<Object[], Object[]> recipe : RecipeManagers.centrifugeManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
if (obj instanceof ItemStack i && stack.isItemEqual(i)) {
|
||||
isRecipe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +66,9 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
for (Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
if (obj instanceof ItemStack i && stack.isItemEqual(i)) {
|
||||
isRecipe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,73 +85,72 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
|
||||
public Collection<ItemStack> getCrafting(ItemStack stack) {
|
||||
List<ItemStack> products = new ArrayList<>();
|
||||
for (Object recipeO : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipeO instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
|
||||
for (IRecipe iRecipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (iRecipe instanceof ShapelessRecipes shapeless) {
|
||||
boolean match = true;
|
||||
for (Object rec : recipe.recipeItems) {
|
||||
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
|
||||
for (final ItemStack rec : shapeless.recipeItems) {
|
||||
if (rec != null && !stack.isItemEqual(rec)) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
products.add(recipe.getRecipeOutput());
|
||||
products.add(shapeless.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapedRecipes) {
|
||||
ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
|
||||
if (iRecipe instanceof ShapedRecipes shaped) {
|
||||
boolean match = true;
|
||||
for (Object rec2 : recipe2.recipeItems) {
|
||||
if (rec2 != null && (!(rec2 instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec2))) {
|
||||
for (final ItemStack rec : shaped.recipeItems) {
|
||||
if (rec != null && !stack.isItemEqual(rec)) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
products.add(recipe2.getRecipeOutput());
|
||||
products.add(shaped.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapelessOreRecipe) {
|
||||
ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
|
||||
if (iRecipe instanceof ShapelessOreRecipe shapelessOre) {
|
||||
boolean match = true;
|
||||
for (Object rec : recipe3.getInput()) {
|
||||
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
|
||||
for (final Object rec : shapelessOre.getInput()) {
|
||||
if (rec != null && (!(rec instanceof ItemStack i) || !stack.isItemEqual(i))) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
products.add(recipe3.getRecipeOutput());
|
||||
products.add(shapelessOre.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<FluidStack> getAllFluids(ItemStack stack) {
|
||||
List<FluidStack> products = new ArrayList<>();
|
||||
products.addAll(getSqueezerFluid(stack));
|
||||
return products;
|
||||
return new ArrayList<>(getSqueezerFluid(stack));
|
||||
}
|
||||
|
||||
public Collection<FluidStack> getSqueezerFluid(ItemStack stack) {
|
||||
List<FluidStack> products = new ArrayList<>();
|
||||
for (Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
|
||||
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
for (final Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack i && stack.isItemEqual(i)) {
|
||||
isRecipe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isRecipe) {
|
||||
for (Object obj : recipe.getValue()) {
|
||||
if (obj instanceof FluidStack) {
|
||||
products.add((FluidStack) obj);
|
||||
for (final Object obj : recipe.getValue()) {
|
||||
if (obj instanceof FluidStack f) {
|
||||
products.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,41 +158,41 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
return products;
|
||||
}
|
||||
|
||||
protected Collection<? extends FluidStack> getAllProducts(FluidStack stack) {
|
||||
protected Collection<? extends FluidStack> getAllProducts() {
|
||||
return new UniqueFluidStackSet();
|
||||
}
|
||||
|
||||
protected Collection<ItemStack> getAllProductsAndFluids(Collection<ItemStack> collection) {
|
||||
Collection<ItemStack> products = new UniqueItemStackSet();
|
||||
for (ItemStack stack : collection) {
|
||||
for (final ItemStack stack : collection) {
|
||||
products.addAll(getAllProducts(stack));
|
||||
}
|
||||
|
||||
Collection<ItemStack> products2 = new UniqueItemStackSet();
|
||||
for (ItemStack stack2 : products) {
|
||||
for (final ItemStack stack2 : products) {
|
||||
products2.addAll(getAllProducts(stack2));
|
||||
}
|
||||
|
||||
Collection<ItemStack> products3 = new UniqueItemStackSet();
|
||||
for (ItemStack stack3 : products2) {
|
||||
for (final ItemStack stack3 : products2) {
|
||||
products3.addAll(getAllProducts(stack3));
|
||||
}
|
||||
|
||||
products.addAll(products2);
|
||||
products.addAll(products3);
|
||||
Collection<FluidStack> allFluids = new UniqueFluidStackSet();
|
||||
for (ItemStack stack4 : collection) {
|
||||
for (final ItemStack stack4 : collection) {
|
||||
allFluids.addAll(getAllFluids(stack4));
|
||||
}
|
||||
|
||||
Collection<FluidStack> fluids2 = new UniqueFluidStackSet();
|
||||
for (FluidStack stack5 : allFluids) {
|
||||
fluids2.addAll(getAllProducts(stack5));
|
||||
for (FluidStack ignored : allFluids) {
|
||||
fluids2.addAll(getAllProducts());
|
||||
}
|
||||
|
||||
Collection<FluidStack> fluids3 = new UniqueFluidStackSet();
|
||||
for (FluidStack stack6 : fluids2) {
|
||||
fluids3.addAll(getAllProducts(stack6));
|
||||
for (FluidStack ignored : fluids2) {
|
||||
fluids3.addAll(getAllProducts());
|
||||
}
|
||||
|
||||
allFluids.addAll(fluids2);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
|
||||
protected void createMoisture(IWidget parent, float x, float y, float w, float h, EnumMoisture value,
|
||||
EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumMoisture>(parent, x, y, w, h, EnumMoisture.class) {
|
||||
new ControlToleranceBar<>(parent, x, y, w, h, EnumMoisture.class) {
|
||||
|
||||
@Override
|
||||
protected String getName(EnumMoisture value) {
|
||||
@@ -143,14 +143,18 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
|
||||
@Override
|
||||
protected int getColor(EnumMoisture value) {
|
||||
return (new int[] { 0xccffcc, 0x66ccff, 0x3366ff })[value.ordinal()];
|
||||
return switch (value) {
|
||||
case DRY -> 0xccffcc;
|
||||
case NORMAL -> 0x66ccff;
|
||||
case DAMP -> 0x3366ff;
|
||||
};
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
protected void createAcidity(IWidget parent, float x, float y, float w, float h, EnumAcidity value,
|
||||
EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumAcidity>(parent, x, y, w, h, EnumAcidity.class) {
|
||||
new ControlToleranceBar<>(parent, x, y, w, h, EnumAcidity.class) {
|
||||
|
||||
@Override
|
||||
protected String getName(EnumAcidity value) {
|
||||
@@ -159,7 +163,11 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
|
||||
@Override
|
||||
protected int getColor(EnumAcidity value) {
|
||||
return (new int[] { 0xff0066, 0x00ff00, 0x0066ff })[value.ordinal()];
|
||||
return switch (value) {
|
||||
case ACID -> 0xff0066;
|
||||
case NEUTRAL -> 0x00ff00;
|
||||
case ALKALINE -> 0x0066ff;
|
||||
};
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
@@ -47,15 +47,11 @@ public class AnalystPageWood extends AnalystPageProduce {
|
||||
products.add(stackWood);
|
||||
}
|
||||
|
||||
// for (ItemStack stack :
|
||||
// ind.getGenome().getFruitProvider().getProducts()) {
|
||||
// products.add(stack);
|
||||
// }
|
||||
|
||||
if (products.size() > 0) {
|
||||
if (!products.isEmpty()) {
|
||||
new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.wood.logs")).setColor(getColor());
|
||||
y += 10;
|
||||
int w = products.size() * 18 - 2;
|
||||
// TODO: Is this meant to increment i?
|
||||
int i = 0;
|
||||
for (ItemStack stack : products) {
|
||||
ControlItemDisplay d = new ControlItemDisplay(this, (w() - w) / 2.0f + 18 * i, y);
|
||||
@@ -70,12 +66,12 @@ public class AnalystPageWood extends AnalystPageProduce {
|
||||
|
||||
Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
|
||||
refinedProducts.addAll(getAllProductsAndFluids(allProducts));
|
||||
if (refinedProducts.size() > 0) {
|
||||
if (!refinedProducts.isEmpty()) {
|
||||
y = getRefined(I18N.localise("genetics.gui.analyst.wood.products"), y, refinedProducts);
|
||||
y += 8;
|
||||
}
|
||||
|
||||
if (products.size() == 0) {
|
||||
if (products.isEmpty()) {
|
||||
new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.wood.noFruits")).setColor(getColor());
|
||||
y += 28;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@ public abstract class ControlAnalystPage extends Control {
|
||||
hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public abstract String getTitle();
|
||||
|
||||
protected String getTimeString(float time) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract class ControlToleranceBar<T extends Enum<T>> extends Control imp
|
||||
|
||||
EnumSet<T> tolerated;
|
||||
EnumSet<T> fullSet;
|
||||
private Class<T> enumClass;
|
||||
private final Class<T> enumClass;
|
||||
|
||||
public ControlToleranceBar(IWidget parent, float x, float y, float width, float height, Class<T> clss) {
|
||||
super(parent, x, y, width, height);
|
||||
|
||||
@@ -315,7 +315,7 @@ public class WindowAnalyst extends Window {
|
||||
|
||||
ControlAnalystPage databasePage = null;
|
||||
if (isDatabase && !systemChange) {
|
||||
databasePage = ((analystPages.size() > 0) ? analystPages.get(0) : null);
|
||||
databasePage = ((!analystPages.isEmpty()) ? analystPages.get(0) : null);
|
||||
}
|
||||
|
||||
analystPages.clear();
|
||||
@@ -419,8 +419,8 @@ public class WindowAnalyst extends Window {
|
||||
x += width;
|
||||
}
|
||||
|
||||
if (analystPages.size() > 0) {
|
||||
setPage(leftPage, analystPages.get((oldLeft >= 0) ? oldLeft : 0));
|
||||
if (!analystPages.isEmpty()) {
|
||||
setPage(leftPage, analystPages.get(Math.max(oldLeft, 0)));
|
||||
}
|
||||
if (analystPages.size() > 1) {
|
||||
setPage(rightPage, analystPages.get((oldRight >= 0) ? oldRight : 1));
|
||||
|
||||
Reference in new issue
Block a user