More SonarQube fixes.
This commit is contained in:
@@ -111,7 +111,7 @@ public final class IoUtil {
|
||||
boolean success = current == null && stacks.isEmpty();
|
||||
|
||||
if (!success && action == Action.PERFORM) {
|
||||
LOGGER.warn("Inventory unexpectedly didn't accept " + (current != null ? current.getTranslationKey() : null) + ", the remainder has been voided!");
|
||||
LOGGER.warn("Inventory unexpectedly didn't accept {}, the remainder has been voided!", current != null ? current.getTranslationKey() : null);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -123,7 +123,7 @@ public final class IoUtil {
|
||||
|
||||
if (filled != entry.getStack().getAmount()) {
|
||||
if (action == Action.PERFORM) {
|
||||
LOGGER.warn("Inventory unexpectedly didn't accept all of " + entry.getStack().getTranslationKey() + ", the remainder has been voided!");
|
||||
LOGGER.warn("Inventory unexpectedly didn't accept all of {}, the remainder has been voided!", entry.getStack().getTranslationKey());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -21,6 +21,9 @@ public class SerializationUtil {
|
||||
private static final String NBT_PATTERN_STACK = "Stack";
|
||||
private static final String NBT_PATTERN_CONTAINER_POS = "ContainerPos";
|
||||
|
||||
private SerializationUtil() {
|
||||
}
|
||||
|
||||
public static ListNBT writeItemStackList(IStackList<ItemStack> stacks) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
||||
public class CraftingCalculatorException extends Exception {
|
||||
private final CalculationResultType type;
|
||||
@Nullable
|
||||
private final ICraftingPattern recursedPattern;
|
||||
private final transient ICraftingPattern recursedPattern;
|
||||
|
||||
public CraftingCalculatorException(CalculationResultType type) {
|
||||
this.type = type;
|
||||
|
@@ -24,12 +24,12 @@ public abstract class Node {
|
||||
|
||||
protected final NodeRequirements requirements = new NodeRequirements();
|
||||
|
||||
public Node(ICraftingPattern pattern, boolean root) {
|
||||
protected Node(ICraftingPattern pattern, boolean root) {
|
||||
this.pattern = pattern;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public Node(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
protected Node(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
this.quantity = tag.getInt(NBT_QUANTITY);
|
||||
this.totalQuantity = tag.getInt(NBT_QUANTITY_TOTAL);
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
|
||||
|
@@ -40,11 +40,7 @@ public class NodeList {
|
||||
}
|
||||
|
||||
public Node createOrAddToExistingNode(ICraftingPattern pattern, boolean root, NonNullList<ItemStack> recipe, int qty) {
|
||||
Node node = nodes.get(pattern);
|
||||
if (node == null) {
|
||||
nodes.put(pattern, node = createNode(pattern, root, recipe));
|
||||
}
|
||||
|
||||
Node node = nodes.computeIfAbsent(pattern, key -> createNode(key, root, recipe));
|
||||
node.addQuantity(qty);
|
||||
|
||||
return node;
|
||||
|
@@ -35,11 +35,7 @@ public class NodeRequirements {
|
||||
itemsNeededPerCraft.put(ingredientNumber, perCraft);
|
||||
}
|
||||
|
||||
IStackList<ItemStack> list = itemRequirements.get(ingredientNumber);
|
||||
if (list == null) {
|
||||
itemRequirements.put(ingredientNumber, list = API.instance().createItemStackList());
|
||||
}
|
||||
|
||||
IStackList<ItemStack> list = itemRequirements.computeIfAbsent(ingredientNumber, key -> API.instance().createItemStackList());
|
||||
list.add(stack, size);
|
||||
}
|
||||
|
||||
@@ -48,11 +44,7 @@ public class NodeRequirements {
|
||||
fluidsNeededPerCraft.put(ingredientNumber, perCraft);
|
||||
}
|
||||
|
||||
IStackList<FluidStack> list = fluidRequirements.get(ingredientNumber);
|
||||
if (list == null) {
|
||||
fluidRequirements.put(ingredientNumber, list = API.instance().createFluidStackList());
|
||||
}
|
||||
|
||||
IStackList<FluidStack> list = fluidRequirements.computeIfAbsent(ingredientNumber, key -> API.instance().createFluidStackList());
|
||||
list.add(stack, size);
|
||||
}
|
||||
|
||||
@@ -133,41 +125,41 @@ public class NodeRequirements {
|
||||
}
|
||||
|
||||
public void readFromNbt(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
ListNBT itemRequirements = tag.getList(NBT_ITEMS_TO_USE, Constants.NBT.TAG_LIST);
|
||||
for (int i = 0; i < itemRequirements.size(); i++) {
|
||||
this.itemRequirements.put(i, SerializationUtil.readItemStackList(itemRequirements.getList(i)));
|
||||
ListNBT itemRequirementsTag = tag.getList(NBT_ITEMS_TO_USE, Constants.NBT.TAG_LIST);
|
||||
for (int i = 0; i < itemRequirementsTag.size(); i++) {
|
||||
itemRequirements.put(i, SerializationUtil.readItemStackList(itemRequirementsTag.getList(i)));
|
||||
}
|
||||
|
||||
List<Integer> itemsNeededPerCraft = Ints.asList(tag.getIntArray(NBT_ITEMS_NEEDED_PER_CRAFT));
|
||||
for (int i = 0; i < itemsNeededPerCraft.size(); i++) {
|
||||
this.itemsNeededPerCraft.put(i, itemsNeededPerCraft.get(i));
|
||||
List<Integer> itemsNeededPerCraftTag = Ints.asList(tag.getIntArray(NBT_ITEMS_NEEDED_PER_CRAFT));
|
||||
for (int i = 0; i < itemsNeededPerCraftTag.size(); i++) {
|
||||
itemsNeededPerCraft.put(i, itemsNeededPerCraftTag.get(i));
|
||||
}
|
||||
|
||||
ListNBT fluidRequirements = tag.getList(NBT_FLUIDS_TO_USE, Constants.NBT.TAG_LIST);
|
||||
for (int i = 0; i < fluidRequirements.size(); i++) {
|
||||
this.fluidRequirements.put(i, SerializationUtil.readFluidStackList(fluidRequirements.getList(i)));
|
||||
ListNBT fluidRequirementsTag = tag.getList(NBT_FLUIDS_TO_USE, Constants.NBT.TAG_LIST);
|
||||
for (int i = 0; i < fluidRequirementsTag.size(); i++) {
|
||||
fluidRequirements.put(i, SerializationUtil.readFluidStackList(fluidRequirementsTag.getList(i)));
|
||||
}
|
||||
|
||||
List<Integer> fluidsNeededPerCraft = Ints.asList(tag.getIntArray(NBT_FLUIDS_NEEDED_PER_CRAFT));
|
||||
for (int i = 0; i < fluidsNeededPerCraft.size(); i++) {
|
||||
this.fluidsNeededPerCraft.put(i, fluidsNeededPerCraft.get(i));
|
||||
List<Integer> fluidsNeededPerCraftTag = Ints.asList(tag.getIntArray(NBT_FLUIDS_NEEDED_PER_CRAFT));
|
||||
for (int i = 0; i < fluidsNeededPerCraftTag.size(); i++) {
|
||||
fluidsNeededPerCraft.put(i, fluidsNeededPerCraftTag.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
ListNBT itemRequirements = new ListNBT();
|
||||
for (IStackList<ItemStack> list : this.itemRequirements.values()) {
|
||||
itemRequirements.add(SerializationUtil.writeItemStackList(list));
|
||||
ListNBT itemRequirementsTag = new ListNBT();
|
||||
for (IStackList<ItemStack> list : itemRequirements.values()) {
|
||||
itemRequirementsTag.add(SerializationUtil.writeItemStackList(list));
|
||||
}
|
||||
tag.put(NBT_ITEMS_TO_USE, itemRequirements);
|
||||
tag.put(NBT_ITEMS_TO_USE, itemRequirementsTag);
|
||||
|
||||
tag.putIntArray(NBT_ITEMS_NEEDED_PER_CRAFT, Ints.toArray(itemsNeededPerCraft.values()));
|
||||
|
||||
ListNBT fluidRequirements = new ListNBT();
|
||||
for (IStackList<FluidStack> list : this.fluidRequirements.values()) {
|
||||
fluidRequirements.add(SerializationUtil.writeFluidStackList(list));
|
||||
ListNBT fluidRequirementsTag = new ListNBT();
|
||||
for (IStackList<FluidStack> list : fluidRequirements.values()) {
|
||||
fluidRequirementsTag.add(SerializationUtil.writeFluidStackList(list));
|
||||
}
|
||||
tag.put(NBT_FLUIDS_TO_USE, fluidRequirements);
|
||||
tag.put(NBT_FLUIDS_TO_USE, fluidRequirementsTag);
|
||||
|
||||
tag.putIntArray(NBT_FLUIDS_NEEDED_PER_CRAFT, Ints.toArray(fluidsNeededPerCraft.values()));
|
||||
|
||||
|
Reference in New Issue
Block a user