添加无线收发器频道设置、样板供应器状态控制提示、映射文件、命令翻译键
This commit is contained in:
parent
19cf58a7e4
commit
85b85aed73
|
|
@ -14,69 +14,69 @@ import java.util.function.Supplier;
|
|||
* 客户端发送到服务端,用于通过输入框设置频率
|
||||
*/
|
||||
public class SetWirelessFrequencyC2SPacket {
|
||||
|
||||
|
||||
private final BlockPos pos;
|
||||
private final long frequency;
|
||||
|
||||
|
||||
public SetWirelessFrequencyC2SPacket(BlockPos pos, long frequency) {
|
||||
this.pos = pos;
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
|
||||
public static void encode(SetWirelessFrequencyC2SPacket packet, FriendlyByteBuf buf) {
|
||||
buf.writeBlockPos(packet.pos);
|
||||
buf.writeLong(packet.frequency);
|
||||
}
|
||||
|
||||
|
||||
public static SetWirelessFrequencyC2SPacket decode(FriendlyByteBuf buf) {
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
long frequency = buf.readLong();
|
||||
return new SetWirelessFrequencyC2SPacket(pos, frequency);
|
||||
}
|
||||
|
||||
|
||||
public static void handle(SetWirelessFrequencyC2SPacket packet, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 检查方块实体是否存在
|
||||
var level = player.serverLevel();
|
||||
if (!level.hasChunkAt(packet.pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var blockEntity = level.getBlockEntity(packet.pos);
|
||||
if (!(blockEntity instanceof WirelessTransceiverBlockEntity te)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 通过GUI设置频率时,忽略锁定状态
|
||||
// 临时保存锁定状态
|
||||
boolean wasLocked = te.isLocked();
|
||||
|
||||
|
||||
// 临时解锁以允许设置
|
||||
if (wasLocked) {
|
||||
te.setLocked(false);
|
||||
}
|
||||
|
||||
|
||||
// 设置频率
|
||||
long newFreq = packet.frequency;
|
||||
if (newFreq < 0) {
|
||||
newFreq = 0;
|
||||
}
|
||||
te.setFrequency(newFreq);
|
||||
|
||||
|
||||
// 恢复锁定状态
|
||||
if (wasLocked) {
|
||||
te.setLocked(true);
|
||||
}
|
||||
|
||||
|
||||
// 发送反馈消息
|
||||
player.displayClientMessage(
|
||||
Component.literal("频道已设置为:" + te.getFrequency()),
|
||||
true
|
||||
Component.translatable("extendedae_plus.chat.wireless_transceiver.channel_set", te.getFrequency()),
|
||||
true
|
||||
);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
|
|
|||
|
|
@ -90,8 +90,7 @@ public class GlobalToggleProviderModesC2SPacket {
|
|||
|
||||
int affected = applyToAllProviders(grid, msg);
|
||||
// 向发起玩家反馈影响数量,便于判断按钮是否生效
|
||||
player.displayClientMessage(Component.literal("E+ 全局切换已应用到 " + affected + " 个样板供应器"), true);
|
||||
});
|
||||
player.displayClientMessage(Component.translatable("extendedae_plus.chat.pattern_provider.global_toggle_applied", affected), true); });
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ public class InfinityDiskGiveCommand {
|
|||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
if (player.level() == null || !(player.level() instanceof ServerLevel)) {
|
||||
source.sendFailure(Component.literal("This command must be run on server side."));
|
||||
source.sendFailure(Component.translatable("extendedae_plus.command.server_side_only"));
|
||||
return 0;
|
||||
}
|
||||
InfinityStorageManager mgr = ExtendedAEPlus.STORAGE_INSTANCE;
|
||||
if (mgr == null) {
|
||||
source.sendFailure(Component.literal("InfinityStorageManager is not initialized."));
|
||||
source.sendFailure(Component.translatable("extendedae_plus.command.storage_manager_not_initialized"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -50,13 +50,11 @@ public class InfinityDiskGiveCommand {
|
|||
given++;
|
||||
}
|
||||
final int finalGiven = given;
|
||||
source.sendSuccess(() -> Component.literal("Gave " + finalGiven + " infinity disks."), false);
|
||||
source.sendSuccess(() -> Component.translatable("extendedae_plus.command.gave_infinity_disks", finalGiven), false);
|
||||
return given;
|
||||
} catch (Exception ex) {
|
||||
source.sendFailure(Component.literal("Error: " + ex.getMessage()));
|
||||
source.sendFailure(Component.translatable("extendedae_plus.command.error", ex.getMessage()));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -181,8 +181,7 @@ public final class RecipeTypeNameConfig {
|
|||
}
|
||||
return true;
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
sendPlayerMessage(Component.literal("ExtendedAE_Plus: 配置文件更新失败: " + e.getMessage()));
|
||||
return false;
|
||||
sendPlayerMessage(Component.translatable("extendedae_plus.message.config_update_failed", e.getMessage())); return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +229,7 @@ public final class RecipeTypeNameConfig {
|
|||
}
|
||||
return toRemove.size();
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
sendPlayerMessage(Component.literal("ExtendedAE_Plus: 配置文件删除失败: " + e.getMessage()));
|
||||
sendPlayerMessage(Component.translatable("extendedae_plus.message.config_delete_failed", e.getMessage()));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,10 @@
|
|||
"extendedae_plus.chat.wireless_transceiver.mode_slave": "Slave",
|
||||
"extendedae_plus.chat.wireless_transceiver.locked_status": "Transceiver Locked",
|
||||
"extendedae_plus.chat.wireless_transceiver.unlocked_status": "Transceiver Unlocked",
|
||||
"extendedae_plus.chat.wireless_transceiver.channel_set": "Channel set to: %s",
|
||||
"extendedae_plus.chat.pattern_provider.global_toggle_applied": "Global toggle applied to %s pattern providers",
|
||||
"extendedae_plus.message.config_update_failed": "Mapping file update failed: %s",
|
||||
"extendedae_plus.message.config_delete_failed": "Mapping file delete failed: %s",
|
||||
|
||||
"config.jade.plugin_extendedae_plus.wireless_transceiver_info": "Wireless Transceiver Info",
|
||||
"config.jade.plugin_extendedae_plus.wt_frequency": "Show Frequency",
|
||||
|
|
@ -172,5 +176,10 @@
|
|||
"extendedae_plus.jade.channels": "Channels: %s",
|
||||
"extendedae_plus.jade.channels_of": "Channels: %s/%s",
|
||||
"extendedae_plus.jade.owner": "Owner: %s",
|
||||
"extendedae_plus.jade.owner.public": "Owner: Public"
|
||||
"extendedae_plus.jade.owner.public": "Owner: Public",
|
||||
|
||||
"extendedae_plus.command.server_side_only": "This command must be run on server side",
|
||||
"extendedae_plus.command.storage_manager_not_initialized": "InfinityStorageManager is not initialized",
|
||||
"extendedae_plus.command.gave_infinity_disks": "Gave %s infinity disks",
|
||||
"extendedae_plus.command.error": "Error: %s"
|
||||
}
|
||||
|
|
@ -148,6 +148,10 @@
|
|||
"extendedae_plus.chat.wireless_transceiver.mode_slave": "从端",
|
||||
"extendedae_plus.chat.wireless_transceiver.locked_status": "已锁定收发器",
|
||||
"extendedae_plus.chat.wireless_transceiver.unlocked_status": "已解锁收发器",
|
||||
"extendedae_plus.chat.wireless_transceiver.channel_set": "频道已设置为:%s",
|
||||
"extendedae_plus.chat.pattern_provider.global_toggle_applied": "全局切换已应用到 %s 个样板供应器",
|
||||
"extendedae_plus.message.config_update_failed": "映射文件更新失败: %s",
|
||||
"extendedae_plus.message.config_delete_failed": "映射文件删除失败: %s",
|
||||
|
||||
"config.jade.plugin_extendedae_plus.wireless_transceiver_info": "无线收发器信息",
|
||||
"config.jade.plugin_extendedae_plus.wt_frequency": "显示频率",
|
||||
|
|
@ -172,5 +176,10 @@
|
|||
"extendedae_plus.jade.channels": "频道: %s",
|
||||
"extendedae_plus.jade.channels_of": "频道: %s/%s",
|
||||
"extendedae_plus.jade.owner": "所有者: %s",
|
||||
"extendedae_plus.jade.owner.public": "所有者: 公共"
|
||||
"extendedae_plus.jade.owner.public": "所有者: 公共",
|
||||
|
||||
"extendedae_plus.command.server_side_only": "此命令必须在服务器端执行",
|
||||
"extendedae_plus.command.storage_manager_not_initialized": "InfinityStorageManager未初始化",
|
||||
"extendedae_plus.command.gave_infinity_disks": "已发放 %s 个无限磁盘",
|
||||
"extendedae_plus.command.error": "错误: %s"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user