use of arekkuusu.solar.api.entanglement.quantum.data.INBTData in project Solar by ArekkuusuJerii.
the class WorldQuantumData method init.
public static void init(ASMDataTable table) {
Stopwatch stopwatch = Stopwatch.createStarted();
List<ASMDataTable.ASMData> loaders = Lists.newArrayList(table.getAll(NBTHolder.class.getName()));
loaders.sort((l, r) -> l.getObjectName().compareToIgnoreCase(r.getClassName()));
for (ASMDataTable.ASMData loader : loaders) {
try {
Class<?> data = Class.forName(loader.getClassName());
if (INBTData.class.isAssignableFrom(data)) {
if (Stream.of(data.getConstructors()).anyMatch(c -> c.getParameterCount() == 0)) {
NBTHolder nbtData = data.getAnnotation(NBTHolder.class);
String modId = nbtData.modId();
String name = nbtData.name();
ResourceLocation location = new ResourceLocation(modId, name);
// noinspection unchecked
DATA_MAP.put(location, (Class<INBTData<?>>) data);
} else {
Solar.LOG.error("[WorldQuantumData] - Class {} has no empty constructor", data.getName());
}
} else {
Solar.LOG.error("[WorldQuantumData] - Class {} is annotated with @NBTHolder but is not an INBTData", data.getName());
}
} catch (ClassNotFoundException e) {
Solar.LOG.error("[WorldQuantumData] - Failed to find class {}", loader.getClassName());
e.printStackTrace();
}
}
Solar.LOG.info("[Discovered {} NBT data holder(s) in {}]", loaders.size(), stopwatch.stop());
}
Aggregations