Use collection copies

This commit is contained in:
themode 2021-12-19 00:26:20 +01:00 committed by TheMode
parent ba8667a361
commit 089a90df52
2 changed files with 3 additions and 4 deletions

View File

@ -20,7 +20,7 @@ final class BlockImpl implements Block {
private static final ObjectArray<Block> BLOCK_STATE_MAP = new ObjectArray<>();
private static final Registry.Container<Block> CONTAINER = new Registry.Container<>(Registry.Resource.BLOCKS,
(container, namespace, object) -> {
final var stateObject = (Map<String, Object>) object.remove("states");
final var stateObject = (Map<String, Object>) object.get("states");
// Loop each state
var propertyEntry = new HashMap<Map<String, String>, Block>();
var unmodifiableEntries = Collections.unmodifiableMap(propertyEntry);

View File

@ -537,15 +537,14 @@ public final class Registry {
reader.beginArray();
while (reader.hasNext()) list.add(readObject(reader));
reader.endArray();
list.trimToSize();
yield list;
yield List.copyOf(list);
}
case BEGIN_OBJECT -> {
Map<String, Object> map = new HashMap<>();
reader.beginObject();
while (reader.hasNext()) map.put(reader.nextName().intern(), readObject(reader));
reader.endObject();
yield map;
yield Map.copyOf(map);
}
case STRING -> reader.nextString().intern();
case NUMBER -> ToNumberPolicy.LONG_OR_DOUBLE.readNumber(reader);