diff --git a/README.md b/README.md index bab8a02e7..d344fb157 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,12 @@ ## Community report exploits). You'll get a far quicker response if you ask the whole community! ## Using -If you want to depend on CC: Tweaked, we have a maven repo. However, you should be wary that some functionality is only -exposed by CC:T's API and not vanilla ComputerCraft. If you wish to support all variations of ComputerCraft, I recommend -using [cc.crzd.me's maven](https://cc.crzd.me/maven/) instead. +CC: Tweaked is hosted on my maven repo, and so is relatively simple to depend on. You may wish to add a soft (or hard) +dependency in your `mods.toml` file, with the appropriate version bounds, to ensure that API functionality you depend +on is present. ```groovy -dependencies { +repositories { maven { url 'https://squiddev.cc/maven/' } } diff --git a/gradle.properties b/gradle.properties index dc94a1f3d..53c207977 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.91.1 +mod_version=1.92.0 # Minecraft properties (update mods.toml when changing) mc_version=1.16.2 diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 6a833d0fb..ab89ba49d 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -39,6 +39,7 @@ public final class ComputerCraft public static final String[] DEFAULT_HTTP_ALLOW = new String[] { "*" }; public static final String[] DEFAULT_HTTP_DENY = new String[] { "127.0.0.0/8", + "0.0.0.0/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", diff --git a/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java b/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java index 40e4634d8..f22e33654 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java @@ -124,7 +124,7 @@ public boolean isDirectory( @Nonnull String path ) throws IOException { try { - return m_filesystem.exists( path ); + return m_filesystem.isDir( path ); } catch( FileSystemException e ) { diff --git a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java index bf9086dc9..7460e5af3 100644 --- a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java +++ b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java @@ -42,8 +42,6 @@ public static void set( Entity entity, Function consumer ) dropEntity = entity; dropWorld = entity.world; dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 ); - - entity.captureDrops( new ArrayList<>() ); } public static void set( World world, BlockPos pos, Function consumer ) @@ -86,7 +84,7 @@ public static void onEntitySpawn( EntityJoinWorldEvent event ) } } - @SubscribeEvent + @SubscribeEvent( priority = EventPriority.LOW ) public static void onLivingDrops( LivingDropsEvent drops ) { if( dropEntity == null || drops.getEntity() != dropEntity ) return; diff --git a/src/main/resources/assets/computercraft/lang/vi.json b/src/main/resources/assets/computercraft/lang/vi.json new file mode 100644 index 000000000..b4261b8cb --- /dev/null +++ b/src/main/resources/assets/computercraft/lang/vi.json @@ -0,0 +1,48 @@ +{ + "gui.computercraft.tooltip.disk_id": "ID của đĩa: %s", + "upgrade.computercraft.speaker.adjective": "Ồn ào", + "upgrade.computercraft.wireless_modem_advanced.adjective": "Ender", + "upgrade.computercraft.wireless_modem_normal.adjective": "Không dây", + "upgrade.minecraft.crafting_table.adjective": "Chế tạo", + "upgrade.minecraft.diamond_hoe.adjective": "Trồng trọt", + "upgrade.minecraft.diamond_axe.adjective": "Đốn", + "upgrade.minecraft.diamond_pickaxe.adjective": "Khai thác", + "upgrade.minecraft.diamond_shovel.adjective": "Đào", + "item.computercraft.pocket_computer_advanced.upgraded": "Máy tính bỏ túi tiên tiến %s", + "item.computercraft.pocket_computer_advanced": "Máy tính bỏ túi tiên tiến", + "item.computercraft.pocket_computer_normal.upgraded": "Máy tính bỏ túi %s", + "item.computercraft.pocket_computer_normal": "Máy tính bỏ túi", + "item.computercraft.printed_book": "Sách in", + "item.computercraft.printed_page": "Trang in", + "item.computercraft.treasure_disk": "Đĩa mềm", + "item.computercraft.disk": "Đĩa mềm", + "block.computercraft.turtle_advanced.upgraded_twice": "Rùa tiên tiến %s %s", + "block.computercraft.turtle_advanced.upgraded": "Rùa tiên tiến %s", + "block.computercraft.turtle_advanced": "Rùa tiên tiến", + "block.computercraft.turtle_normal.upgraded_twice": "Rùa %s %s", + "block.computercraft.turtle_normal.upgraded": "Rùa %s", + "block.computercraft.turtle_normal": "Rùa", + "block.computercraft.wired_modem_full": "Modem có dây", + "block.computercraft.cable": "Dây cáp mạng", + "block.computercraft.wired_modem": "Modem có dây", + "block.computercraft.wireless_modem_advanced": "Modem Ender", + "block.computercraft.wireless_modem_normal": "Modem không dây", + "block.computercraft.monitor_advanced": "Màn hình tiên tiếng", + "block.computercraft.monitor_normal": "Màn hình", + "block.computercraft.speaker": "Loa", + "block.computercraft.printer": "Máy in", + "block.computercraft.disk_drive": "Ỗ đĩa", + "block.computercraft.computer_command": "Máy tính điều khiển", + "block.computercraft.computer_normal": "Máy tính", + "itemGroup.computercraft": "ComputerCraft", + "block.computercraft.computer_advanced": "Máy tính tiên tiến", + "tracking_field.computercraft.websocket_incoming.name": "Websocket đến", + "tracking_field.computercraft.websocket_outgoing.name": "Websocket đi", + "gui.computercraft.tooltip.computer_id": "ID của máy tính: %s", + "tracking_field.computercraft.coroutines_dead.name": "Coroutine bỏ đi", + "tracking_field.computercraft.coroutines_created.name": "Coroutine đã tạo", + "tracking_field.computercraft.http_download.name": "HTTP tải xuống", + "tracking_field.computercraft.http_upload.name": "HTTP tải lên", + "tracking_field.computercraft.http.name": "Yêu cầu HTTP", + "gui.computercraft.tooltip.copy": "Sao chép vào clipboard" +} 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 40de6924b..576c6755e 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -432,7 +432,7 @@ do --- Skip any whitespace local function skip(str, pos) - local _, last = find(str, "^[ \n\r\v]+", pos) + local _, last = find(str, "^[ \n\r\t]+", pos) if last then return last + 1 else return pos end end @@ -472,7 +472,7 @@ do buf[n], n, pos = utf8.char(tonumber(num_str, 16)), n + 1, pos + 6 else local unesc = escapes[c] - if not unesc then error_at(pos + 1, "Unknown escape character %q.", unesc) end + if not unesc then error_at(pos + 1, "Unknown escape character %q.", c) end buf[n], n, pos = unesc, n + 1, pos + 2 end elseif c >= '\x20' then 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 23584df62..e3799d7e0 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,14 @@ +# New features in CC: Tweaked 1.92.0 + +* Bump Cobalt version: + * Add support for the __pairs metamethod. + * string.format now uses the __tostring metamethod. +* Add date-specific MOTDs (MCJack123). + +And several bug fixes: +* Correctly handle tabs within textutils.unserailizeJSON. +* Fix sheep not dropping items when sheered by turtles. + # New features in CC: Tweaked 1.91.1 * Fix crash when turtles interact with an entity. 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 2b24ff7ee..9a79e5602 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,12 @@ -New features in CC: Tweaked 1.91.1 +New features in CC: Tweaked 1.92.0 -* Fix crash when turtles interact with an entity. +* Bump Cobalt version: + * Add support for the __pairs metamethod. + * string.format now uses the __tostring metamethod. +* Add date-specific MOTDs (MCJack123). + +And several bug fixes: +* Correctly handle tabs within textutils.unserailizeJSON. +* Fix sheep not dropping items when sheered by turtles. Type "help changelog" to see the full version history. diff --git a/src/main/resources/data/computercraft/lua/rom/programs/motd.lua b/src/main/resources/data/computercraft/lua/rom/programs/motd.lua index c8c75a40b..57ab7b916 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/motd.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/motd.lua @@ -1,15 +1,24 @@ -local tMotd = {} +local date = os.date("*t") +if date.month == 1 and date.day == 1 then + print("Happy new year!") +elseif date.month == 12 and date.day == 24 then + print("Merry X-mas!") +elseif date.month == 10 and date.day == 31 then + print("OOoooOOOoooo! Spooky!") +else + local tMotd = {} -for sPath in string.gmatch(settings.get("motd.path"), "[^:]+") do - if fs.exists(sPath) then - for sLine in io.lines(sPath) do - table.insert(tMotd, sLine) + for sPath in string.gmatch(settings.get("motd.path"), "[^:]+") do + if fs.exists(sPath) then + for sLine in io.lines(sPath) do + table.insert(tMotd, sLine) + end end end -end -if #tMotd == 0 then - print("missingno") -else - print(tMotd[math.random(1, #tMotd)]) + if #tMotd == 0 then + print("missingno") + else + print(tMotd[math.random(1, #tMotd)]) + end end diff --git a/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json b/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json new file mode 100644 index 000000000..d9a9c8b4d --- /dev/null +++ b/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json @@ -0,0 +1 @@ +[ ] diff --git a/src/test/resources/test-rom/spec/programs/motd_spec.lua b/src/test/resources/test-rom/spec/programs/motd_spec.lua index 72becbf30..d426fb6e7 100644 --- a/src/test/resources/test-rom/spec/programs/motd_spec.lua +++ b/src/test/resources/test-rom/spec/programs/motd_spec.lua @@ -1,14 +1,36 @@ local capture = require "test_helpers".capture_program describe("The motd program", function() + local function setup_date(month, day) + stub(os, "date", function() return { month = month, day = day } end) + end - it("displays MODT", function() - local file = fs.open("/modt_check.txt", "w") + it("displays MOTD", function() + setup_date(0, 0) + local file = fs.open("/motd_check.txt", "w") file.write("Hello World!") file.close() - settings.set("motd.path", "/modt_check.txt") + settings.set("motd.path", "/motd_check.txt") expect(capture(stub, "motd")) :matches { ok = true, output = "Hello World!\n", error = "" } end) + + it("displays date-specific MOTD (1/1)", function() + setup_date(1, 1) + expect(capture(stub, "motd")) + :matches { ok = true, output = "Happy new year!\n", error = "" } + end) + + it("displays date-specific MOTD (10/31)", function() + setup_date(10, 31) + expect(capture(stub, "motd")) + :matches { ok = true, output = "OOoooOOOoooo! Spooky!\n", error = "" } + end) + + it("displays date-specific MOTD (12/24)", function() + setup_date(12, 24) + expect(capture(stub, "motd")) + :matches { ok = true, output = "Merry X-mas!\n", error = "" } + end) end)