From e191b08eb559a97365b9c225fc63243c74036ef7 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Fri, 14 Jan 2022 15:33:47 +0000 Subject: [PATCH] Use Guava instead of commons-codec for hex encoding The latter was removed in 1.18 on the server side. Fixes #1011. --- src/main/java/dan200/computercraft/shared/util/NBTUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java index de0250aa6..c1686aa77 100644 --- a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java @@ -5,10 +5,10 @@ */ package dan200.computercraft.shared.util; +import com.google.common.io.BaseEncoding; import dan200.computercraft.ComputerCraft; import net.minecraft.nbt.*; import net.minecraftforge.common.util.Constants; -import org.apache.commons.codec.binary.Hex; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,6 +25,8 @@ import static net.minecraftforge.common.util.Constants.NBT.*; public final class NBTUtil { + private static final BaseEncoding ENCODING = BaseEncoding.base16().lowerCase(); + private NBTUtil() {} private static INBT toNBTTag( Object object ) @@ -181,7 +183,7 @@ public final class NBTUtil DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) ); CompressedStreamTools.write( tag, output ); byte[] hash = digest.digest(); - return new String( Hex.encodeHex( hash ) ); + return ENCODING.encode( hash ); } catch( NoSuchAlgorithmException | IOException e ) {