This commit is contained in:
GaLicn 2025-09-07 13:58:02 +08:00
parent 6369e2f280
commit be0d548238
4 changed files with 34 additions and 9 deletions

View File

@ -32,7 +32,7 @@ mod_name=ExtendedAE-Plus
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=1.0.0
mod_version=1.4.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View File

@ -31,7 +31,8 @@ public class NetworkPatternControllerBlock extends Block implements EntityBlock
if (!level.isClientSide && player instanceof ServerPlayer sp) {
BlockEntity be = level.getBlockEntity(pos);
if (be instanceof MenuProvider provider) {
sp.openMenu(provider);
// 关键将方块位置写入缓冲客户端菜单读取以便按钮发包附带正确坐标
sp.openMenu(provider, buf -> buf.writeBlockPos(pos));
}
}
return ItemInteractionResult.sidedSuccess(level.isClientSide);
@ -42,7 +43,8 @@ public class NetworkPatternControllerBlock extends Block implements EntityBlock
if (!level.isClientSide && player instanceof ServerPlayer sp) {
BlockEntity be = level.getBlockEntity(pos);
if (be instanceof MenuProvider provider) {
sp.openMenu(provider);
// 同上无手持物品时也写入 BlockPos
sp.openMenu(provider, buf -> buf.writeBlockPos(pos));
}
}
return InteractionResult.sidedSuccess(level.isClientSide);

View File

@ -90,12 +90,26 @@ public final class WrenchHook {
// 未潜行 + 扳手切换锁定状态
BlockEntity be = level.getBlockEntity(hit.getBlockPos());
if (be instanceof WirelessTransceiverBlockEntity te) {
boolean newLocked = !te.isLocked();
te.setLocked(newLocked);
// 提示玩家
player.displayClientMessage(Component.literal(newLocked ? "已锁定收发器" : "已解锁收发器"), true);
// 轻微反馈音效
level.playSound(player, hit.getBlockPos(), SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.5F, newLocked ? 0.6F : 0.9F);
// 仅在服务端切换与同步避免仅客户端生效导致看起来无效果
if (!level.isClientSide) {
boolean newLocked = !te.isLocked();
te.setLocked(newLocked);
// 同步方块更新到客户端
var pos = hit.getBlockPos();
BlockState state = level.getBlockState(pos);
try {
level.sendBlockUpdated(pos, state, state, 3);
} catch (Throwable t) {
ExtendedAEPlus.LOGGER.debug("sendBlockUpdated failed: {}", t.toString());
}
// 提示玩家服务端消息下发到客户端
player.displayClientMessage(Component.literal(newLocked ? "已锁定收发器" : "已解锁收发器"), true);
// 轻微反馈音效
level.playSound(player, hit.getBlockPos(), SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.5F, newLocked ? 0.6F : 0.9F);
ExtendedAEPlus.LOGGER.debug("Wrench toggle lock at {} -> {}", pos, newLocked);
} else {
ExtendedAEPlus.LOGGER.debug("Client received wrench toggle intent (no-op on client)");
}
event.setCanceled(true);
event.setCancellationResult(InteractionResult.sidedSuccess(level.isClientSide));

View File

@ -86,6 +86,15 @@ config="${mod_id}.mixins.json"
ordering="NONE"
side="BOTH"
# Require ExtendedAE (ExtendedAE-1.21-2.2.21-neoforge) to be present
[[dependencies.${mod_id}]]
modId="extendedae"
type="required"
# Use a permissive range to tolerate upstream version string variations (e.g. 1.21-2.2.21-neoforge)
versionRange="*"
ordering="AFTER"
side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.