[1.21.1] ModLoading cleanup and optimisations (#10052)

This commit is contained in:
Paint_Ninja authored and GitHub committed 2024-08-16 22:49:11 +01:00
1 parent f106ff0c21
commit 9714512c31
101 files changed
+837 -841

No files matched your search

@@ -11,8 +11,8 @@ import net.minecraft.world.level.ChunkPos;
// Sorter to load nearby chunks first
public class CenterChunkPosComparator implements java.util.Comparator<ChunkPos>
{
private int x;
private int z;
private final int x;
private final int z;
public CenterChunkPosComparator(ServerPlayer entityplayer)
{
@@ -30,7 +30,7 @@ public class ConcatenatedListView<T> implements List<T>
{
return switch (members.size()) {
case 0 -> List.of();
case 1 -> Collections.unmodifiableList(members.get(0));
case 1 -> Collections.unmodifiableList(members.getFirst());
default -> new ConcatenatedListView<>(members);
};
}
@@ -46,7 +46,7 @@ public class HexDumper {
private static final String HEX = "0123456789ABCDEF";
private final int marked;
private final StringBuilder buf;
private char[] ascii = new char[16];
private final char[] ascii = new char[16];
private int index = 0;
private Instance(int marked, int size) {
@@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable;
public class LevelCapabilityData extends SavedData {
public static final String ID = "capabilities";
private INBTSerializable<CompoundTag> serializable;
private final INBTSerializable<CompoundTag> serializable;
private CompoundTag capNBT = null;
public LevelCapabilityData(@Nullable INBTSerializable<CompoundTag> serializable) {
@@ -325,7 +325,7 @@ public class MutableHashedLinkedMap<K, V> implements Iterable<Map.Entry<K, V>>
Value apply(Key key, Value left, Value right);
}
private class Entry implements Map.Entry<K, V>
private final class Entry implements Map.Entry<K, V>
{
private final K key;
private V value;
@@ -374,7 +374,7 @@ public class MutableHashedLinkedMap<K, V> implements Iterable<Map.Entry<K, V>>
}
}
private static class BasicStrategy implements Strategy<Object> {
private static final class BasicStrategy implements Strategy<Object> {
@Override
public int hashCode(Object o) {
return Objects.hashCode(o);
@@ -386,7 +386,7 @@ public class MutableHashedLinkedMap<K, V> implements Iterable<Map.Entry<K, V>>
}
}
private static class IdentityStrategy implements Strategy<Object> {
private static final class IdentityStrategy implements Strategy<Object> {
@Override
public int hashCode(Object o) {
return System.identityHashCode(o);
@@ -8,6 +8,7 @@ package net.minecraftforge.common.util;
import java.io.IOException;
import java.io.Writer;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
@@ -25,7 +26,7 @@ public class SortedProperties extends Properties {
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
Set<Map.Entry<Object, Object>> ret = new TreeSet<>((left, right) -> left.getKey().toString().compareTo(right.getKey().toString()));
Set<Map.Entry<Object, Object>> ret = new TreeSet<>(Comparator.comparing(entry -> entry.getKey().toString()));
ret.addAll(super.entrySet());
return ret;
}
@@ -125,9 +125,9 @@ public class TextTable
public static class Column
{
private String header;
private final String header;
private int width;
private Alignment alignment;
private final Alignment alignment;
public Column(String header)
{
@@ -302,19 +302,12 @@ public final class TransformationHelper
Quaternionf ret;
try
{
if (entry.getKey().equals("x"))
{
ret = Axis.XP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
}
else if (entry.getKey().equals("y"))
{
ret = Axis.YP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
}
else if (entry.getKey().equals("z"))
{
ret = Axis.ZP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
}
else throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey());
ret = switch (entry.getKey()) {
case "x" -> Axis.XP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
case "y" -> Axis.YP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
case "z" -> Axis.ZP.rotationDegrees(entry.getValue().getAsNumber().floatValue());
default -> throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey());
};
}
catch(ClassCastException ex)
{