From 053cb1b53c35bf15b419e95cd5283989a7c9b54b Mon Sep 17 00:00:00 2001 From: neumond Date: Sat, 18 Jul 2020 16:58:36 +0300 Subject: [PATCH 01/12] Fix JSON serialization of strings Control characters become escaped as JSON requires Non-ASCII characters get escaped as well for better interoperability We assume here that lua strings represent only first 256 code points of unicode --- .../computercraft/lua/rom/apis/textutils.lua | 29 +++++++++++++++++-- .../test-rom/spec/apis/textutils_spec.lua | 14 +++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua index 0e96a287d..0f191e522 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -335,6 +335,31 @@ empty_json_array = mk_tbl("[]", "empty_json_array") -- @see textutils.unserialiseJSON json_null = mk_tbl("null", "json_null") +local serializeJSONString +do + local function hexify(c) + return ("\\u00%02X"):format(c:byte()) + end + + local map = { + ["\""] = "\\\"", + ["\\"] = "\\\\", + ["\b"] = "\\b", + ["\f"] = "\\f", + ["\n"] = "\\n", + ["\r"] = "\\r", + ["\t"] = "\\t", + } + for i = 0, 0x1f do + local c = string.char(i) + if map[c] == nil then map[c] = hexify(c) end + end + + serializeJSONString = function(s) + return ('"%s"'):format(s:gsub("[\0-\x1f\"\\]", map):gsub("[\x7f-\xff]", hexify)) + end +end + local function serializeJSONImpl(t, tTracking, bNBTStyle) local sType = type(t) if t == empty_json_array then return "[]" @@ -361,7 +386,7 @@ local function serializeJSONImpl(t, tTracking, bNBTStyle) if bNBTStyle then sEntry = tostring(k) .. ":" .. serializeJSONImpl(v, tTracking, bNBTStyle) else - sEntry = string.format("%q", k) .. ":" .. serializeJSONImpl(v, tTracking, bNBTStyle) + sEntry = serializeJSONString(k) .. ":" .. serializeJSONImpl(v, tTracking, bNBTStyle) end if nObjectSize == 0 then sObjectResult = sObjectResult .. sEntry @@ -390,7 +415,7 @@ local function serializeJSONImpl(t, tTracking, bNBTStyle) end elseif sType == "string" then - return string.format("%q", t) + return serializeJSONString(t) elseif sType == "number" or sType == "boolean" then return tostring(t) diff --git a/src/test/resources/test-rom/spec/apis/textutils_spec.lua b/src/test/resources/test-rom/spec/apis/textutils_spec.lua index 94e243afc..d60d30f47 100644 --- a/src/test/resources/test-rom/spec/apis/textutils_spec.lua +++ b/src/test/resources/test-rom/spec/apis/textutils_spec.lua @@ -78,6 +78,20 @@ describe("The textutils library", function() it("serializes null", function() expect(textutils.serializeJSON(textutils.json_null)):eq("null") end) + + it("serializes strings", function() + expect(textutils.serializeJSON('a')):eq('"a"') + expect(textutils.serializeJSON('"')):eq('"\\""') + expect(textutils.serializeJSON('\\')):eq('"\\\\"') + expect(textutils.serializeJSON('/')):eq('"/"') + expect(textutils.serializeJSON('\b')):eq('"\\b"') + expect(textutils.serializeJSON('\n')):eq('"\\n"') + expect(textutils.serializeJSON(string.char(0))):eq('"\\u0000"') + expect(textutils.serializeJSON(string.char(0x0A))):eq('"\\n"') + expect(textutils.serializeJSON(string.char(0x1D))):eq('"\\u001D"') + expect(textutils.serializeJSON(string.char(0x81))):eq('"\\u0081"') + expect(textutils.serializeJSON(string.char(0xFF))):eq('"\\u00FF"') + end) end) describe("textutils.unserializeJSON", function() From fe00e00537a21520934988e40a8960d49d6f5665 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 31 Jul 2020 18:30:53 +0100 Subject: [PATCH 02/12] Mention people should include logs --- .github/ISSUE_TEMPLATE/bug_report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 064fbc389..f9cee6d08 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -12,4 +12,5 @@ ## Before reporting ## Useful information to include: - Minecraft version - CC: Tweaked version + - Logs: These will be located in the `logs/` directory of your Minecraft instance. Please upload them as a gist or directly into this editor. - Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed. From 0e2ce3c63496dba032c5c5c65aa5f472e49bdab6 Mon Sep 17 00:00:00 2001 From: hydraz Date: Fri, 31 Jul 2020 14:39:09 -0300 Subject: [PATCH 03/12] Make the key for mtime "modified" in fs.attributes (#512) --- src/main/java/dan200/computercraft/core/apis/FSAPI.java | 1 + src/test/resources/test-rom/spec/apis/fs_spec.lua | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index fc909c683..4f122ae4c 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -479,6 +479,7 @@ public final Map attributes( String path ) throws LuaException BasicFileAttributes attributes = fileSystem.getAttributes( path ); Map result = new HashMap<>(); result.put( "modification", getFileTime( attributes.lastModifiedTime() ) ); + result.put( "modified", getFileTime( attributes.lastModifiedTime() ) ); result.put( "created", getFileTime( attributes.creationTime() ) ); result.put( "size", attributes.isDirectory() ? 0 : attributes.size() ); result.put( "isDir", attributes.isDirectory() ); diff --git a/src/test/resources/test-rom/spec/apis/fs_spec.lua b/src/test/resources/test-rom/spec/apis/fs_spec.lua index a593cfcd9..58db9e566 100644 --- a/src/test/resources/test-rom/spec/apis/fs_spec.lua +++ b/src/test/resources/test-rom/spec/apis/fs_spec.lua @@ -208,9 +208,11 @@ describe("The fs library", function() fail(("Expected created time (%d) to be within 1000ms of now (%d"):format(attributes.created, now)) end - if attributes.modification - now >= 1000 then - fail(("Expected modification time (%d) to be within 1000ms of now (%d"):format(attributes.modification, now)) + if attributes.modified - now >= 1000 then + fail(("Expected modified time (%d) to be within 1000ms of now (%d"):format(attributes.modified, now)) end + + expect(attributes.modification):eq(attributes.modified) end) end) end) From 3da3f16debaa3472c4f6f3699e980d0bf9999e2b Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 4 Aug 2020 18:30:22 +0100 Subject: [PATCH 04/12] Fix link to logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3488c58b0..bab8a02e7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ![CC: Tweaked](logo.png) +# ![CC: Tweaked](doc/logo.png) [![Current build status](https://github.com/SquidDev-CC/CC-Tweaked/workflows/Build/badge.svg)](https://github.com/SquidDev-CC/CC-Tweaked/actions "Current build status") [![Download CC: Tweaked on CurseForge](http://cf.way2muchnoise.eu/title/cc-tweaked.svg)](https://minecraft.curseforge.com/projects/cc-tweaked "Download CC: Tweaked on CurseForge") CC: Tweaked is a fork of [ComputerCraft](https://github.com/dan200/ComputerCraft), adding programmable computers, From 9f72448ecd960800caf48f343a8686033d5995f1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 4 Aug 2020 19:50:36 +0100 Subject: [PATCH 05/12] Properly deprecate colors.rgb8 --- illuaminate.sexp | 3 +++ src/main/resources/data/computercraft/lua/rom/apis/colors.lua | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/illuaminate.sexp b/illuaminate.sexp index 2c2ebdc84..d28a3fd44 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -101,6 +101,9 @@ (linters -doc:unresolved-reference)) (at /src/test/resources/test-rom + ; We should still be able to test deprecated members. + (linters -var:deprecated) + (lint (globals :max sleep write diff --git a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua index b821c38d3..a941fa287 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua @@ -181,9 +181,6 @@ end --- Either calls @{colors.packRGB} or @{colors.unpackRGB}, depending on how many -- arguments it receives. -- --- **Note:** This function is deprecated, and it is recommended you use the --- specific pack/unpack function directly. --- -- @tparam[1] number r The red channel, as an argument to @{colors.packRGB}. -- @tparam[1] number g The green channel, as an argument to @{colors.packRGB}. -- @tparam[1] number b The blue channel, as an argument to @{colors.packRGB}. @@ -192,6 +189,7 @@ end -- @treturn[2] number The red channel, as returned by @{colors.unpackRGB} -- @treturn[2] number The green channel, as returned by @{colors.unpackRGB} -- @treturn[2] number The blue channel, as returned by @{colors.unpackRGB} +-- @deprecated Use @{packRGB} or @{unpackRGB} directly. -- @usage -- ```lua -- colors.rgb(0xb23399) From e8e2ed9fe521b4b420c5eb93190fa3f1f6f58686 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sun, 9 Aug 2020 21:50:58 +0100 Subject: [PATCH 06/12] Fix incorrect lower bound in mods.toml It appears I had failed to update this when last bumping the Forge version. Closes #521 - we're relying on a feature only added in Forge 31.1.16, and they're using 3.1.14. --- src/main/resources/META-INF/mods.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 94b6f2073..451828625 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,6 +19,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a [[dependencies.computercraft]] modId="forge" mandatory=true - versionRange="[31.0.13,32)" + versionRange="[31.1.41,32)" ordering="NONE" side="BOTH" From 0faf76e4bd2e2f43033984c49b0abedd8e403c24 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 22 Aug 2020 15:03:38 +0100 Subject: [PATCH 07/12] Fix if statement never being hit Let's been honest, this bit's probably never been tested, because it should never happen. Fixes #528. --- .../core/computer/ComputerThread.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index ed6a903cb..66ea9e644 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -395,14 +395,7 @@ public void run() executor.timeout.hardAbort(); executor.abort(); - if( afterHardAbort >= ABORT_TIMEOUT ) - { - // If we've hard aborted but we're still not dead, dump the stack trace and interrupt - // the task. - timeoutTask( executor, runner.owner, afterStart ); - runner.owner.interrupt(); - } - else if( afterHardAbort >= ABORT_TIMEOUT * 2 ) + if( afterHardAbort >= ABORT_TIMEOUT * 2 ) { // If we've hard aborted and interrupted, and we're still not dead, then mark the runner // as dead, finish off the task, and spawn a new runner. @@ -421,6 +414,13 @@ else if( afterHardAbort >= ABORT_TIMEOUT * 2 ) } } } + else if( afterHardAbort >= ABORT_TIMEOUT ) + { + // If we've hard aborted but we're still not dead, dump the stack trace and interrupt + // the task. + timeoutTask( executor, runner.owner, afterStart ); + runner.owner.interrupt(); + } } } } From d5de39ebd47c6ec472104a0d8e72f4ec4516f3d5 Mon Sep 17 00:00:00 2001 From: R93950X <39017175+R93950X@users.noreply.github.com> Date: Sat, 22 Aug 2020 07:17:12 -0700 Subject: [PATCH 08/12] Fix time formatting (#527) Fixes #525. Co-authored-by: R93950X --- .../data/computercraft/lua/rom/apis/textutils.lua | 2 +- .../resources/test-rom/spec/apis/textutils_spec.lua | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua index 0f191e522..40de6924b 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -77,7 +77,7 @@ function formatTime(nTime, bTwentyFourHour) local nHour = math.floor(nTime) local nMinute = math.floor((nTime - nHour) * 60) if sTOD then - return string.format("%d:%02d %s", nHour, nMinute, sTOD) + return string.format("%d:%02d %s", nHour == 0 and 12 or nHour, nMinute, sTOD) else return string.format("%d:%02d", nHour, nMinute) end diff --git a/src/test/resources/test-rom/spec/apis/textutils_spec.lua b/src/test/resources/test-rom/spec/apis/textutils_spec.lua index d60d30f47..e83746ecf 100644 --- a/src/test/resources/test-rom/spec/apis/textutils_spec.lua +++ b/src/test/resources/test-rom/spec/apis/textutils_spec.lua @@ -12,6 +12,14 @@ describe("The textutils library", function() expect.error(textutils.formatTime, nil):eq("bad argument #1 (expected number, got nil)") expect.error(textutils.formatTime, 1, 1):eq("bad argument #2 (expected boolean, got number)") end) + + it("correctly formats 12 o'clock", function() + expect(textutils.formatTime(0, false)):eq("12:00 AM") + expect(textutils.formatTime(0.1, false)):eq("12:06 AM") + + expect(textutils.formatTime(0, true)):eq("0:00") + expect(textutils.formatTime(0.1, true)):eq("0:06") + end) end) describe("textutils.pagedPrint", function() @@ -49,7 +57,7 @@ describe("The textutils library", function() describe("textutils.empty_json_array", function() it("is immutable", function() expect.error(function() textutils.empty_json_array[1] = true end) - :str_match("^[^:]+:51: attempt to mutate textutils.empty_json_array$") + :str_match("^[^:]+:%d+: attempt to mutate textutils.empty_json_array$") end) end) From 29fb0baa09055653818c7e55be8138528ba1bc4c Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 22 Aug 2020 15:31:48 +0100 Subject: [PATCH 09/12] Use Forge's packet methods for sending SoundEvents Doesn't fix #515 (arguably makes it worse in the sense that it's more likely to throw). However it should provide better error reporting, and make it more clear that it's not CC:T's fault. --- .../shared/network/client/PlayRecordClientMessage.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java index 9ba8d2021..ce1851c85 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java @@ -13,10 +13,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; -import java.util.Objects; /** * Starts or stops a record on the client, depending on if {@link #soundEvent} is {@code null}. @@ -51,7 +49,7 @@ public PlayRecordClientMessage( PacketBuffer buf ) if( buf.readBoolean() ) { name = buf.readString( Short.MAX_VALUE ); - soundEvent = ForgeRegistries.SOUND_EVENTS.getValue( buf.readResourceLocation() ); + soundEvent = buf.readRegistryIdSafe( SoundEvent.class ); } else { @@ -72,7 +70,7 @@ public void toBytes( @Nonnull PacketBuffer buf ) { buf.writeBoolean( true ); buf.writeString( name ); - buf.writeResourceLocation( Objects.requireNonNull( soundEvent.getRegistryName(), "Sound is not registered" ) ); + buf.writeRegistryId( soundEvent ); } } From 9acfc0316fdb13b81bb4b63233d2db21f8a29ccd Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 22 Aug 2020 16:09:35 +0100 Subject: [PATCH 10/12] Expose NBT hashes of items to users This just uses the same approach as Plethora, so we should have aparity for .list() now. --- .../peripheral/generic/data/ItemData.java | 22 +++++++- .../shared/turtle/apis/TurtleAPI.java | 2 +- .../computercraft/shared/util/NBTUtil.java | 52 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java index 1a422487e..a2a39f599 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java @@ -7,6 +7,8 @@ package dan200.computercraft.shared.peripheral.generic.data; import com.google.gson.JsonParseException; +import dan200.computercraft.ComputerCraft; +import dan200.computercraft.shared.util.NBTUtil; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.EnchantedBookItem; @@ -22,13 +24,29 @@ import java.util.*; import java.util.stream.Collectors; +/** + * Data providers for items. + * + * We guard using {@link ComputerCraft#genericPeripheral} in several places, as advanced functionality should not be + * exposed for {@code turtle.getItemDetail} when generic peripehrals are disabled. + */ public class ItemData { @Nonnull - public static > T fillBasic( @Nonnull T data, @Nonnull ItemStack stack ) + public static > T fillBasicSafe( @Nonnull T data, @Nonnull ItemStack stack ) { data.put( "name", DataHelpers.getId( stack.getItem() ) ); data.put( "count", stack.getCount() ); + + return data; + } + + @Nonnull + public static > T fillBasic( @Nonnull T data, @Nonnull ItemStack stack ) + { + fillBasicSafe( data, stack ); + String hash = NBTUtil.getNBTHash( stack.getTag() ); + if( hash != null ) data.put( "nbt", hash ); return data; } @@ -55,6 +73,8 @@ public static > T fill( @Nonnull T data, @ data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) ); + if( !ComputerCraft.genericPeripheral ) return data; + CompoundNBT tag = stack.getTag(); if( tag != null && tag.contains( "display", Constants.NBT.TAG_COMPOUND ) ) { diff --git a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index 260c9423f..57040804c 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -605,7 +605,7 @@ private Object[] getItemDetail( int slot, boolean detailed ) Map table = detailed ? ItemData.fill( new HashMap<>(), stack ) - : ItemData.fillBasic( new HashMap<>(), stack ); + : ItemData.fillBasicSafe( new HashMap<>(), stack ); TurtleActionEvent event = new TurtleInspectItemEvent( turtle, stack, table, detailed ); if( MinecraftForge.EVENT_BUS.post( event ) ) return new Object[] { false, event.getFailureMessage() }; diff --git a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java index 4f4b9cfba..006effe07 100644 --- a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java @@ -5,9 +5,19 @@ */ package dan200.computercraft.shared.util; +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; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; @@ -159,4 +169,46 @@ public static Object[] decodeObjects( CompoundNBT tag ) } return objects; } + + @Nullable + public static String getNBTHash( @Nullable CompoundNBT tag ) + { + if( tag == null ) return null; + + try + { + MessageDigest digest = MessageDigest.getInstance( "MD5" ); + DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) ); + CompressedStreamTools.write( tag, output ); + byte[] hash = digest.digest(); + return new String( Hex.encodeHex( hash ) ); + } + catch( NoSuchAlgorithmException | IOException e ) + { + ComputerCraft.log.error( "Cannot hash NBT", e ); + return null; + } + } + + private static class DigestOutputStream extends OutputStream + { + private final MessageDigest digest; + + private DigestOutputStream( MessageDigest digest ) + { + this.digest = digest; + } + + @Override + public void write( @Nonnull byte[] b, int off, int len ) + { + digest.update( b, off, len ); + } + + @Override + public void write( int b ) + { + digest.update( (byte) b ); + } + } } From 0bb5515055441e891adc133f4864a81dfde260ac Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 22 Aug 2020 19:31:49 +0100 Subject: [PATCH 11/12] Fix checkstyle problems --- src/main/java/dan200/computercraft/shared/util/NBTUtil.java | 4 ++-- 1 file changed, 2 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 006effe07..97879a497 100644 --- a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java @@ -190,11 +190,11 @@ public static String getNBTHash( @Nullable CompoundNBT tag ) } } - private static class DigestOutputStream extends OutputStream + private static final class DigestOutputStream extends OutputStream { private final MessageDigest digest; - private DigestOutputStream( MessageDigest digest ) + DigestOutputStream( MessageDigest digest ) { this.digest = digest; } From 183b34207197df7118a751fb333efbe969a21ba1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sun, 23 Aug 2020 15:35:58 +0100 Subject: [PATCH 12/12] Bump for 1.91.0 --- gradle.properties | 2 +- .../computercraft/core/lua/VarargArguments.java | 8 ++++---- .../data/computercraft/lua/rom/help/changelog.txt | 12 ++++++++++++ .../data/computercraft/lua/rom/help/whatsnew.txt | 12 ++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 106c54e9c..6a2a622b9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.90.2 +mod_version=1.91.0 # Minecraft properties (update mods.toml when changing) mc_version=1.15.2 diff --git a/src/main/java/dan200/computercraft/core/lua/VarargArguments.java b/src/main/java/dan200/computercraft/core/lua/VarargArguments.java index 4ad8d58a4..cedba0a80 100644 --- a/src/main/java/dan200/computercraft/core/lua/VarargArguments.java +++ b/src/main/java/dan200/computercraft/core/lua/VarargArguments.java @@ -83,9 +83,9 @@ public long getLong( int index ) throws LuaException public ByteBuffer getBytes( int index ) throws LuaException { LuaValue value = varargs.arg( index + 1 ); - if( !(value instanceof LuaString) ) throw LuaValues.badArgument( index, "string", value.typeName() ); + if( !(value instanceof LuaBaseString) ) throw LuaValues.badArgument( index, "string", value.typeName() ); - LuaString str = (LuaString) value; + LuaString str = ((LuaBaseString) value).strvalue(); return ByteBuffer.wrap( str.bytes, str.offset, str.length ).asReadOnlyBuffer(); } @@ -94,9 +94,9 @@ public Optional optBytes( int index ) throws LuaException { LuaValue value = varargs.arg( index + 1 ); if( value.isNil() ) return Optional.empty(); - if( !(value instanceof LuaString) ) throw LuaValues.badArgument( index, "string", value.typeName() ); + if( !(value instanceof LuaBaseString) ) throw LuaValues.badArgument( index, "string", value.typeName() ); - LuaString str = (LuaString) value; + LuaString str = ((LuaBaseString) value).strvalue(); return Optional.of( ByteBuffer.wrap( str.bytes, str.offset, str.length ).asReadOnlyBuffer() ); } } diff --git a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt index 08e8327a3..fbb88d766 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt @@ -1,3 +1,15 @@ +# New features in CC: Tweaked 1.91.0 + +* [Generic peripherals] Expose NBT hashes of items to inventory methods. +* Bump Cobalt version + * Optimise handling of string concatenation. + * Add string.{pack,unpack,packsize} (MCJack123) + +And several bug fixes: +* Escape non-ASCII characters in JSON strings (neumond) +* Make field names in fs.attributes more consistent (abby) +* Fix textutils.formatTime correctly handle 12 AM (R93950X) + # New features in CC: Tweaked 1.90.2 * Fix generic peripherals not being registered outside a dev environment. diff --git a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt index 8135e4db6..1ad4527c2 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt @@ -1,5 +1,13 @@ -New features in CC: Tweaked 1.90.2 +New features in CC: Tweaked 1.91.0 -* Fix generic peripherals not being registered outside a dev environment. +* [Generic peripherals] Expose NBT hashes of items to inventory methods. +* Bump Cobalt version + * Optimise handling of string concatenation. + * Add string.{pack,unpack,packsize} (MCJack123) + +And several bug fixes: +* Escape non-ASCII characters in JSON strings (neumond) +* Make field names in fs.attributes more consistent (abby) +* Fix textutils.formatTime correctly handle 12 AM (R93950X) Type "help changelog" to see the full version history.