1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-31 13:42:59 +00:00

Merge branch 'mc-1.20.x' into mc-1.20.y

This commit is contained in:
Jonathan Coates
2024-06-21 08:36:18 +01:00
18 changed files with 184 additions and 51 deletions

View File

@@ -36,13 +36,13 @@ public final class ItemModelProvider {
}
private static void registerPocketComputer(ItemModelGenerators generators, ResourceLocation id, boolean off) {
createFlatItem(generators, addSuffix(id, "_blinking"),
createFlatItem(generators, id.withSuffix("_blinking"),
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_blink"),
id,
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
);
createFlatItem(generators, addSuffix(id, "_on"),
createFlatItem(generators, id.withSuffix("_on"),
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_on"),
id,
new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
@@ -94,8 +94,4 @@ public final class ItemModelProvider {
new ModelTemplate(Optional.of(new ResourceLocation("item/generated")), Optional.empty(), slots)
.create(model, mapping, generators.output);
}
private static ResourceLocation addSuffix(ResourceLocation location, String suffix) {
return new ResourceLocation(location.getNamespace(), location.getPath() + suffix);
}
}

View File

@@ -180,7 +180,7 @@ public class CommandAPI implements ILuaAPI {
* blocks at once.
* <p>
* Blocks are traversed by ascending y level, followed by z and x - the returned
* table may be indexed using `x + z*width + y*depth*depth`.
* table may be indexed using `x + z*width + y*width*depth + 1`.
*
* @param minX The start x coordinate of the range to query.
* @param minY The start y coordinate of the range to query.
@@ -194,6 +194,25 @@ public class CommandAPI implements ILuaAPI {
* @throws LuaException If trying to get information about more than 4096 blocks.
* @cc.since 1.76
* @cc.changed 1.99 Added {@code dimension} argument.
*
* @cc.usage Print out all blocks in a cube around the computer.
*
* <pre>{@code
* -- Get a 3x3x3 cube around the computer
* local x, y, z = commands.getBlockPosition()
* local min_x, min_y, min_z, max_x, max_y, max_z = x - 1, y - 1, z - 1, x + 1, y + 1, z + 1
* local blocks = commands.getBlockInfos(min_x, min_y, min_z, max_x, max_y, max_z)
*
* -- Then loop over all blocks and print them out.
* local width, height, depth = max_x - min_x + 1, max_y - min_y + 1, max_z - min_z + 1
* for x = min_x, max_x do
* for y = min_y, max_y do
* for z = min_z, max_z do
* print(("%d, %d %d => %s"):format(x, y, z, blocks[(x - min_x) + (z - min_z) * width + (y - min_y) * width * depth + 1].name))
* end
* end
* end
* }</pre>
*/
@LuaFunction(mainThread = true)
public final List<Map<?, ?>> getBlockInfos(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Optional<String> dimension) throws LuaException {

View File

@@ -129,7 +129,8 @@ public class DiskDrivePeripheral implements IPeripheral {
@LuaFunction
@Nullable
public final Object getAudioTitle() {
return diskDrive.getMedia().getAudioTitle();
var stack = diskDrive.getMedia();
return stack.media() != null ? stack.getAudioTitle() : false;
}
/**

View File

@@ -130,5 +130,18 @@
"upgrade.minecraft.diamond_hoe.adjective": "Ackerbau",
"upgrade.minecraft.diamond_pickaxe.adjective": "Bergbau",
"upgrade.minecraft.diamond_shovel.adjective": "Graben",
"upgrade.minecraft.diamond_sword.adjective": "Nahkampf"
"upgrade.minecraft.diamond_sword.adjective": "Nahkampf",
"argument.computercraft.computer.id": "Computer ID",
"argument.computercraft.computer.instance": "einzigartige Instanz ID",
"argument.computercraft.computer.label": "Computer name",
"argument.computercraft.unknown_computer_family": "Unbekannte computer familie '%s'",
"gui.computercraft.config.floppy_space_limit.tooltip": "Die maximale Dateisystem Größe von Disketten (in bytes).",
"gui.computercraft.config.http.bandwidth": "Bandbreite",
"gui.computercraft.config.http.bandwidth.global_upload": "Globales upload limit",
"gui.computercraft.config.http.bandwidth.global_download.tooltip": "Die maximale Geschwindigkeit aller Computer in bytes/s mit der Heruntergeladen werden kann.\nBereich: > 1",
"gui.computercraft.config.http.bandwidth.global_download": "Globales download limit",
"gui.computercraft.config.http.bandwidth.tooltip": "Limitiert die Bandbreite der Computer.",
"argument.computercraft.computer.family": "Computer familie",
"gui.computercraft.config.execution.max_main_global_time.tooltip": "Die maximale Zeit in millisekunden, in der Aufgaben ausgeführt werden.\nAnmerkung: Diese Zeit wird höchstwarscheinlich überschritten und dient nur als ungefähre Grenze.\nLimit: > 1",
"gui.computercraft.config.http.bandwidth.global_upload.tooltip": "Die maximale Hochladungs Geschwindigkeit aller Computer in bytes/s.\nBereich: > 1"
}

View File

@@ -102,7 +102,7 @@
"item.computercraft.pocket_computer_normal.upgraded": "%s手提计算机",
"item.computercraft.printed_book": "打印书",
"item.computercraft.printed_page": "打印纸",
"item.computercraft.printed_pages": "打印纸",
"item.computercraft.printed_pages": "打印纸",
"item.computercraft.treasure_disk": "软盘",
"itemGroup.computercraft": "ComputerCraft",
"tracking_field.computercraft.fs.name": "文件系统操作",
@@ -120,5 +120,41 @@
"upgrade.minecraft.diamond_hoe.adjective": "耕种",
"upgrade.minecraft.diamond_pickaxe.adjective": "采掘",
"upgrade.minecraft.diamond_shovel.adjective": "挖掘",
"upgrade.minecraft.diamond_sword.adjective": "战斗"
"upgrade.minecraft.diamond_sword.adjective": "战斗",
"argument.computercraft.computer.instance": "唯一实例ID",
"commands.computercraft.dump.open_path": "查看该电脑的文件",
"gui.computercraft.config.command_require_creative": "命令电脑需要创造模式",
"gui.computercraft.config.command_require_creative.tooltip": "玩家需要处于创造模式并为管理员才能与命令计算机交互。\n这是原版命令方块的默认行为。",
"gui.computercraft.config.http.bandwidth": "带宽",
"gui.computercraft.config.http.bandwidth.global_download.tooltip": "每秒钟可以下载的字节数. 所有电脑共享该设置 (bytes/s).\n范围: > 1",
"gui.computercraft.config.http.proxy.type.tooltip": "代理使用的协议.\n允许: HTTP, HTTPS, SOCKS4, SOCKS5",
"argument.computercraft.computer.id": "电脑ID",
"argument.computercraft.computer.distance": "实体距离",
"argument.computercraft.computer.family": "电脑类别",
"argument.computercraft.computer.label": "电脑标签",
"argument.computercraft.unknown_computer_family": "未知电脑类别 '%s'",
"commands.computercraft.help.desc": "显示该帮助信息",
"gui.computercraft.config.computer_space_limit.tooltip": "计算机和海龟的磁盘空间限制,以字节为单位。",
"gui.computercraft.config.disabled_generic_methods": "禁用的通用方法",
"gui.computercraft.config.http.bandwidth.global_upload": "全局上传限速",
"gui.computercraft.config.http.bandwidth.global_download": "全局下载限速",
"gui.computercraft.config.http.bandwidth.global_upload.tooltip": "每秒钟可以上传的字节数. 所有电脑共享该设置 (bytes/s).\n范围: > 1",
"gui.computercraft.config.http.bandwidth.tooltip": "限制电脑可以使用的带宽.",
"gui.computercraft.config.http.proxy": "代理",
"gui.computercraft.config.http.proxy.host": "主机名",
"gui.computercraft.config.http.proxy.host.tooltip": "代理服务器的主机名或IP地址.",
"gui.computercraft.config.http.proxy.port": "端口",
"gui.computercraft.config.http.proxy.port.tooltip": "代理服务器的端口.\n范围: 1 ~ 65536",
"gui.computercraft.config.http.proxy.type": "代理类型",
"gui.computercraft.config.http.rules": "允许/阻止规则",
"gui.computercraft.config.http.tooltip": "控制HTTP API",
"tracking_field.computercraft.java_allocation.name": "Java分配",
"tracking_field.computercraft.max": "%s (最大)",
"tracking_field.computercraft.server_tasks.name": "服务器任务",
"tag.item.computercraft.turtle": "海龟",
"tag.item.computercraft.wired_modem": "有线调制解调器",
"tracking_field.computercraft.avg": "%s (平均)",
"tracking_field.computercraft.computer_tasks.name": "任务",
"tracking_field.computercraft.count": "%s (计数)",
"tracking_field.computercraft.http_requests.name": "HTTP请求"
}

View File

@@ -8,6 +8,7 @@ import dan200.computercraft.core.apis.FSAPI
import dan200.computercraft.gametest.api.*
import dan200.computercraft.shared.ModRegistry
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveBlock
import dan200.computercraft.shared.peripheral.diskdrive.DiskDrivePeripheral
import dan200.computercraft.shared.peripheral.diskdrive.DiskDriveState
import dan200.computercraft.shared.util.DataComponentUtil
import dan200.computercraft.test.core.assertArrayEquals
@@ -42,6 +43,17 @@ class Disk_Drive_Test {
}
}
/**
* [DiskDrivePeripheral] returns `false` when the item is not a disk (or is absent).
*/
@GameTest
fun Audio_title_when_empty(helper: GameTestHelper) = helper.sequence {
thenOnComputer {
callPeripheral("right", "getAudioTitle")
.assertArrayEquals(false, message = "Correct audio title")
}
}
@GameTest
fun Ejects_disk(helper: GameTestHelper) = helper.sequence {
val stackAt = BlockPos(2, 2, 2)

View File

@@ -0,0 +1,40 @@
{
DataVersion: 2730,
size: [3, 3, 3],
data: [
{pos: [0, 0, 0], state: "minecraft:polished_andesite"},
{pos: [0, 0, 1], state: "minecraft:polished_andesite"},
{pos: [0, 0, 2], state: "minecraft:polished_andesite"},
{pos: [1, 0, 0], state: "minecraft:polished_andesite"},
{pos: [1, 0, 1], state: "minecraft:polished_andesite"},
{pos: [1, 0, 2], state: "minecraft:polished_andesite"},
{pos: [2, 0, 0], state: "minecraft:polished_andesite"},
{pos: [2, 0, 1], state: "minecraft:polished_andesite"},
{pos: [2, 0, 2], state: "minecraft:polished_andesite"},
{pos: [0, 1, 0], state: "minecraft:air"},
{pos: [0, 1, 1], state: "computercraft:disk_drive{facing:north,state:full}", nbt: {id: "computercraft:disk_drive"}},
{pos: [0, 1, 2], state: "minecraft:air"},
{pos: [1, 1, 0], state: "minecraft:air"},
{pos: [1, 1, 1], state: "computercraft:computer_advanced{facing:north,state:blinking}", nbt: {ComputerId: 1, Label: "disk_drive_test.audio_title_when_empty", On: 1b, id: "computercraft:computer_advanced"}},
{pos: [1, 1, 2], state: "minecraft:air"},
{pos: [2, 1, 0], state: "minecraft:air"},
{pos: [2, 1, 1], state: "minecraft:air"},
{pos: [2, 1, 2], state: "minecraft:air"},
{pos: [0, 2, 0], state: "minecraft:air"},
{pos: [0, 2, 1], state: "minecraft:air"},
{pos: [0, 2, 2], state: "minecraft:air"},
{pos: [1, 2, 0], state: "minecraft:air"},
{pos: [1, 2, 1], state: "minecraft:air"},
{pos: [1, 2, 2], state: "minecraft:air"},
{pos: [2, 2, 0], state: "minecraft:air"},
{pos: [2, 2, 1], state: "minecraft:air"},
{pos: [2, 2, 2], state: "minecraft:air"}
],
entities: [],
palette: [
"minecraft:polished_andesite",
"minecraft:air",
"computercraft:disk_drive{facing:north,state:full}",
"computercraft:computer_advanced{facing:north,state:blinking}"
]
}