mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-26 06:53:26 +00:00
Doc and code style pass
This commit is contained in:
4 files changed
+16
-22
No files matched your search
@@ -9,6 +9,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -537,8 +538,8 @@ public class SubsetWidget extends Button implements ItemFilterProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
final int[] resolved = new int[1];
|
||||
final int[] invalid = new int[1];
|
||||
final AtomicInteger resolved = new AtomicInteger();
|
||||
final AtomicInteger invalid = new AtomicInteger();
|
||||
|
||||
Stream.of(dir.listFiles()).filter(file -> !file.isDirectory()).forEach(file -> {
|
||||
ClientHandler.loadSettingsFile(
|
||||
@@ -546,13 +547,13 @@ public class SubsetWidget extends Button implements ItemFilterProvider {
|
||||
lines -> parseFile(file.getName(), lines.collect(Collectors.toList()), resolved, invalid));
|
||||
});
|
||||
|
||||
if (resolved[0] + invalid[0] > 0) {
|
||||
NEIClientConfig.logger
|
||||
.info("NotEnoughItems: resolved {} MaterialLib entries ({} invalid)", resolved[0], invalid[0]);
|
||||
if (resolved.get() + invalid.get() > 0) {
|
||||
NEIClientConfig.logger.info("Resolved {} MaterialLib entries ({} invalid)", resolved.get(), invalid.get());
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseFile(String resource, List<String> itemStrings, int[] resolved, int[] invalid) {
|
||||
private static void parseFile(String resource, List<String> itemStrings, AtomicInteger resolved,
|
||||
AtomicInteger invalid) {
|
||||
final JsonParser parser = new JsonParser();
|
||||
final int dotIndex = resource.lastIndexOf('.');
|
||||
final String subsetNamespace = dotIndex > 0 ? resource.substring(0, dotIndex) : resource;
|
||||
@@ -585,11 +586,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider {
|
||||
final ItemStack stack = StackInfo.loadFromNBT(tag);
|
||||
|
||||
if (tag.getString("strId").startsWith(StackInfo.MATERIALLIB_PREFIX)) {
|
||||
if (stack != null) {
|
||||
resolved[0]++;
|
||||
} else {
|
||||
invalid[0]++;
|
||||
}
|
||||
(stack != null ? resolved : invalid).incrementAndGet();
|
||||
}
|
||||
|
||||
((ItemStackSet) processedTag.filter).add(stack);
|
||||
|
||||
@@ -27,8 +27,8 @@ import codechicken.nei.util.NBTHelper;
|
||||
|
||||
public class StackInfo {
|
||||
|
||||
/// Prefix of the stable MaterialLib reference form `ml:<MaterialName>:<shapeToken>`, which config entries carry
|
||||
/// in place of an id and metadata.
|
||||
/// Prefix of the MaterialLib reference form `ml:<MaterialName>:<shapeToken>`, which config entries carry in
|
||||
/// place of an id and metadata.
|
||||
public static final String MATERIALLIB_PREFIX = "ml:";
|
||||
|
||||
private static final FluidStack NULL_FLUID = new FluidStack(FluidRegistry.WATER, 0);
|
||||
|
||||
+6
-8
@@ -8,15 +8,13 @@ import com.ruling_0.materiallib.api.StackResolver;
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
/// Reads config entries written in the stable MaterialLib reference form
|
||||
/// `ml:<MaterialName>:<shapeToken>` (see [StackInfo#MATERIALLIB_PREFIX]) and resolves them against the registries,
|
||||
/// so an entry keeps naming the same item across sessions that hand out different metadata.
|
||||
/// Resolves config entries written in the MaterialLib reference form `ml:<MaterialName>:<shapeToken>` (see
|
||||
/// [StackInfo#MATERIALLIB_PREFIX]) through [StackResolver], so an entry keeps naming the same item across sessions
|
||||
/// that renumber item metadata. The resolved stack carries the metadata MaterialLib currently assigns, ignoring any
|
||||
/// `Damage` on the entry. Entries in any other form are left to the other handlers.
|
||||
///
|
||||
/// The resolved stack carries the metadata MaterialLib currently assigns, overriding any `Damage` the entry
|
||||
/// carries alongside the id.
|
||||
///
|
||||
/// This is the only class in NotEnoughItems that references the MaterialLib API, and every reference to it is
|
||||
/// gated on `Loader.isModLoaded("materiallib")` so it never classloads without MaterialLib present.
|
||||
/// Registered only behind a `Loader.isModLoaded("materiallib")` gate, so this class never classloads without
|
||||
/// MaterialLib present.
|
||||
public class MaterialLibStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user