Code cleanup (#133)

* gradle updateBuildScript

* fix comments and commented-out code

Code deletion, converting comments into javadocs, and refactoring code to not
need comments.

* remove redundant suppressions

* replace C-style array declaration with Java-style

* make private field final

* remove unnecessary semicolon

* extract a common part from an if

* simplify boolean expression

* simplify ternary if

* remove unused imports

* convert escaped characters for clarity

* replace while with for

* replace explicit types with diamond operators

* replace anonymous type with lambda

* enable modern Java syntax

* migrate to enhanced switch

* migrate to pattern variables for instanceof

* remove empty javadoc

* add Nonnull annotation to overrides of Nonnull methods

* replace wailaStack with null

When wailaStack is not null, the flow breaks out of the loop,
so there's no need to confuse the reader with putting wailaStack
both as the result and the parameter of the call - there's no
recursion.

* int cannot be bigger than its max value

* suppress dataflow warning

* remove redundant initializer

The default value of int is 0.

* null check is covered by instanceof

* simplify some calls of addVertexWithUV

* fix typos and add TODOs

* make flipState more understandable
This commit is contained in:
chill authored and GitHub committed 2023-06-18 23:29:57 +02:00
1 parent f87b76347e
commit d5b8ef6ea9
89 files changed
+421 -633

No files matched your search

@@ -50,7 +50,7 @@ public class FluidCraftingTransferHandler implements IOverlayHandler {
Slot slot = (Slot) o;
if (slot.getSlotIndex() == col + row * 3) {
final NBTTagList tags = new NBTTagList();
final List<ItemStack> list = new LinkedList<ItemStack>();
final List<ItemStack> list = new LinkedList<>();
// prefer pure crystals.
for (int x = 0; x < positionedStack.items.length; x++) {
if (Platform.isRecipePrioritized(positionedStack.items[x])) {
@@ -41,8 +41,7 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
if (itemStack.getItem() instanceof IStorageFluidCell) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
for (IAEFluidStack fluid : cellInventory.getContents()) {
@@ -23,8 +23,7 @@ public class NEIUtils {
if (currentStack.stackSize == 0) continue;
boolean find = false;
for (OrderStack<?> storedStack : comp) {
if (storedStack == null || !(storedStack.getStack() instanceof ItemStack)) continue;
ItemStack firstStack = (ItemStack) storedStack.getStack();
if (storedStack == null || !(storedStack.getStack() instanceof ItemStack firstStack)) continue;
boolean areItemStackEqual = firstStack.isItemEqual(currentStack)
&& ItemStack.areItemStackTagsEqual(firstStack, currentStack);
if (areItemStackEqual
@@ -124,7 +124,7 @@ public class OrderStack<T> {
NBTTagCompound info = buf.getCompoundTag(index + ":");
byte id = info.getByte("t");
switch (id) {
case ITEM:
case ITEM -> {
List<ItemStack> list = new ArrayList<>();
if (info.hasKey(index + ":")) {
NBTTagList items = info.getTagList(index + ":", 10);
@@ -134,13 +134,15 @@ public class OrderStack<T> {
}
}
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
case FLUID:
}
case FLUID -> {
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
case CUSTOM:
}
case CUSTOM -> {
if (dummy == null) throw new IllegalOrderStackID(id);
return new OrderStack<>(dummy.customNBTReader(buf), index);
default:
throw new IllegalOrderStackID(id);
}
default -> throw new IllegalOrderStackID(id);
}
}
}
@@ -35,8 +35,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor {
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp;
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
ArrayList<PositionedStack> inputs = ReflectEIO.getInputs(vatRecipe);
tmp = ExtractorUtil.packItemStack(inputs);
FluidStack in = ReflectEIO.getInputFluid(vatRecipe);
@@ -63,8 +62,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor {
int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp = new LinkedList<>();
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
FluidStack result = ReflectEIO.getResult(vatRecipe);
if (result != null) {
tmp.add(new OrderStack<>(result, 0));