Complain once per mod ID if an outdated structure is found
This commit is contained in:
parent
4796af2094
commit
270fec309e
|
|
@ -1,6 +1,7 @@
|
|||
package org.embeddedt.modernfix.structure;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
|
|
@ -15,6 +16,7 @@ import org.embeddedt.modernfix.util.FileUtil;
|
|||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Set;
|
||||
|
||||
public class CachingStructureManager {
|
||||
private static ThreadLocal<MessageDigest> digestThreadLocal = ThreadLocal.withInitial(() -> {
|
||||
|
|
@ -45,6 +47,8 @@ public class CachingStructureManager {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private static final Set<String> laggyStructureMods = new ObjectOpenHashSet<>();
|
||||
|
||||
public static CompoundTag readStructureTag(ResourceLocation location, DataFixer datafixer, InputStream stream) throws IOException {
|
||||
byte[] structureBytes = toBytes(stream);
|
||||
CompoundTag currentTag = NbtIo.readCompressed(new ByteArrayInputStream(structureBytes));
|
||||
|
|
@ -53,6 +57,11 @@ public class CachingStructureManager {
|
|||
}
|
||||
int currentDataVersion = currentTag.getInt("DataVersion");
|
||||
if(currentDataVersion < SharedConstants.getCurrentVersion().getWorldVersion()) {
|
||||
synchronized (laggyStructureMods) {
|
||||
if(laggyStructureMods.add(location.getNamespace())) {
|
||||
ModernFix.LOGGER.warn("Mod {} is shipping outdated structure files; please report this to them.", location.getNamespace());
|
||||
}
|
||||
}
|
||||
/* Needs upgrade, try looking up from cache */
|
||||
MessageDigest hasher = digestThreadLocal.get();
|
||||
hasher.reset();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user