1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-28 00:12:16 +00:00

Don't use apache commons-codec to encode NBT Hex.

Causes NoClassDefFoundError on dedicated server.

I did test this to make sure it output the same format as old
implementation (hex with lowercase alphas).
This commit is contained in:
Toad-Dev 2021-12-17 10:39:16 -08:00
parent 482ed6f6b5
commit 93b45bffed

View File

@ -7,7 +7,6 @@ package dan200.computercraft.shared.util;
import dan200.computercraft.ComputerCraft;
import net.minecraft.nbt.*;
import org.apache.commons.codec.binary.Hex;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -177,7 +176,7 @@ public final class NBTUtil
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
NbtIo.write( tag, output );
byte[] hash = digest.digest();
return new String( Hex.encodeHex( hash ) );
return encodeHex( hash );
}
catch( NoSuchAlgorithmException | IOException e )
{
@ -186,6 +185,13 @@ public final class NBTUtil
}
}
private static String encodeHex( byte[] bytes )
{
StringBuilder result = new StringBuilder();
for ( byte b : bytes ) result.append( String.format( "%02x", b ) );
return result.toString();
}
private static final class DigestOutputStream extends OutputStream
{
private final MessageDigest digest;