mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-20 16:37:39 +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:
@@ -7,7 +7,6 @@ package dan200.computercraft.shared.util;
|
|||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -177,7 +176,7 @@ public final class NBTUtil
|
|||||||
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
|
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
|
||||||
NbtIo.write( tag, output );
|
NbtIo.write( tag, output );
|
||||||
byte[] hash = digest.digest();
|
byte[] hash = digest.digest();
|
||||||
return new String( Hex.encodeHex( hash ) );
|
return encodeHex( hash );
|
||||||
}
|
}
|
||||||
catch( NoSuchAlgorithmException | IOException e )
|
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 static final class DigestOutputStream extends OutputStream
|
||||||
{
|
{
|
||||||
private final MessageDigest digest;
|
private final MessageDigest digest;
|
||||||
|
Reference in New Issue
Block a user