修复iobus初始化
This commit is contained in:
parent
fd075c76f4
commit
7f704e2a9c
|
|
@ -4,19 +4,19 @@ package com.extendedae_plus.bridge;
|
|||
* 非 mixin 包下的桥接接口,供 mixin 进行 instanceof 检测和回调。
|
||||
*/
|
||||
public interface InterfaceWirelessLinkBridge {
|
||||
void extendedae_plus$updateWirelessLink();
|
||||
void eap$updateWirelessLink();
|
||||
|
||||
/**
|
||||
* 获取无线连接状态(服务端返回真实状态,客户端返回同步状态)
|
||||
*/
|
||||
default boolean extendedae_plus$isWirelessConnected() {
|
||||
default boolean eap$isWirelessConnected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置客户端的无线连接状态(仅在客户端使用)
|
||||
*/
|
||||
default void extendedae_plus$setClientWirelessState(boolean connected) {
|
||||
default void eap$setClientWirelessState(boolean connected) {
|
||||
// 默认实现为空
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,17 +25,17 @@ import java.util.List;
|
|||
public abstract class PatternProviderScreenUpgradesMixin<C extends PatternProviderMenu> extends AEBaseScreen<C> {
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void extendedae_plus$initUpgrades(PatternProviderMenu menu, Inventory playerInventory, Component title, ScreenStyle style, CallbackInfo ci) {
|
||||
private void eap$initUpgrades(PatternProviderMenu menu, Inventory playerInventory, Component title, ScreenStyle style, CallbackInfo ci) {
|
||||
this.widgets.add("upgrades", new UpgradesPanel(
|
||||
menu.getSlots(SlotSemantics.UPGRADE),
|
||||
this::extendedae_plus$getCompatibleUpgrades));
|
||||
this::eap$getCompatibleUpgrades));
|
||||
if (((IUpgradableMenu) menu).getToolbox().isPresent()) {
|
||||
this.widgets.add("toolbox", new ToolboxPanel(style, ((IUpgradableMenu) menu).getToolbox().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private List<Component> extendedae_plus$getCompatibleUpgrades() {
|
||||
private List<Component> eap$getCompatibleUpgrades() {
|
||||
var list = new ArrayList<Component>();
|
||||
list.add(GuiText.CompatibleUpgrades.text());
|
||||
list.addAll(Upgrades.getTooltipLinesForMachine(((IUpgradableMenu) menu).getUpgrades().getUpgradableItem()));
|
||||
|
|
|
|||
|
|
@ -28,23 +28,23 @@ public abstract class InterfaceLogicChannelCardMixin implements InterfaceWireles
|
|||
@Shadow(remap = false) protected InterfaceLogicHost host;
|
||||
|
||||
@Unique
|
||||
private WirelessSlaveLink extendedae_plus$link;
|
||||
private WirelessSlaveLink eap$link;
|
||||
|
||||
@Inject(method = "onUpgradesChanged", at = @At("TAIL"), remap = false)
|
||||
private void extendedae_plus$onUpgradesChangedTail(CallbackInfo ci) {
|
||||
private void eap$onUpgradesChangedTail(CallbackInfo ci) {
|
||||
handleChannelCardChange();
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"), remap = false)
|
||||
private void extendedae_plus$afterReadNBT(net.minecraft.nbt.CompoundTag tag, CallbackInfo ci) {
|
||||
private void eap$afterReadNBT(net.minecraft.nbt.CompoundTag tag, CallbackInfo ci) {
|
||||
// 重载后根据卡状态恢复连接
|
||||
handleChannelCardChange();
|
||||
}
|
||||
|
||||
@Inject(method = "clearContent", at = @At("HEAD"), remap = false)
|
||||
private void extendedae_plus$onClearContent(CallbackInfo ci) {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.onUnloadOrRemove();
|
||||
private void eap$onClearContent(CallbackInfo ci) {
|
||||
if (eap$link != null) {
|
||||
eap$link.onUnloadOrRemove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,17 +58,17 @@ public abstract class InterfaceLogicChannelCardMixin implements InterfaceWireles
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (extendedae_plus$link == null) {
|
||||
if (eap$link == null) {
|
||||
IWirelessEndpoint endpoint = new InterfaceNodeEndpointImpl(host, this::getActionableNode);
|
||||
extendedae_plus$link = new WirelessSlaveLink(endpoint);
|
||||
eap$link = new WirelessSlaveLink(endpoint);
|
||||
}
|
||||
extendedae_plus$link.setFrequency(channel);
|
||||
eap$link.setFrequency(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$updateWirelessLink() {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.updateStatus();
|
||||
public void eap$updateWirelessLink() {
|
||||
if (eap$link != null) {
|
||||
eap$link.updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ package com.extendedae_plus.bridge;
|
|||
* 旧名兼容:已迁移到非 mixin 包,避免 Mixin 处理器禁止直接引用。
|
||||
*/
|
||||
public interface InterfaceLogicChannelLinkBridge {
|
||||
void extendedae_plus$updateWirelessLink();
|
||||
void eap$updateWirelessLink();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ public abstract class InterfaceLogicTickerMixin {
|
|||
private InterfaceLogic this$0;
|
||||
|
||||
@Inject(method = "tickingRequest", at = @At("TAIL"), remap = false)
|
||||
private void extendedae_plus$tickTail(appeng.api.networking.IGridNode node, int ticksSinceLastCall,
|
||||
private void eap$tickTail(appeng.api.networking.IGridNode node, int ticksSinceLastCall,
|
||||
CallbackInfoReturnable<appeng.api.networking.ticking.TickRateModulation> cir) {
|
||||
if (this$0 instanceof InterfaceWirelessLinkBridge bridge) {
|
||||
bridge.extendedae_plus$updateWirelessLink();
|
||||
bridge.eap$updateWirelessLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ public abstract class PatternProviderLogicTickerMixin {
|
|||
private PatternProviderLogic this$0;
|
||||
|
||||
@Inject(method = "tickingRequest", at = @At("TAIL"))
|
||||
private void extendedae_plus$tickTail(appeng.api.networking.IGridNode node, int ticksSinceLastCall,
|
||||
private void eap$tickTail(appeng.api.networking.IGridNode node, int ticksSinceLastCall,
|
||||
CallbackInfoReturnable<appeng.api.networking.ticking.TickRateModulation> cir) {
|
||||
if (this$0 instanceof InterfaceWirelessLinkBridge bridge) {
|
||||
bridge.extendedae_plus$updateWirelessLink();
|
||||
bridge.eap$updateWirelessLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ import java.util.List;
|
|||
@Mixin(value = PatternProviderLogic.class, remap = false)
|
||||
public abstract class PatternProviderLogicUpgradesMixin implements IUpgradeableObject, InterfaceWirelessLinkBridge {
|
||||
@Unique
|
||||
private IUpgradeInventory extendedae_plus$upgrades = UpgradeInventories.empty();
|
||||
private IUpgradeInventory eap$upgrades = UpgradeInventories.empty();
|
||||
|
||||
@Unique
|
||||
private WirelessSlaveLink extendedae_plus$link;
|
||||
private WirelessSlaveLink eap$link;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
|
|
@ -50,48 +50,48 @@ public abstract class PatternProviderLogicUpgradesMixin implements IUpgradeableO
|
|||
private IActionSource actionSource;
|
||||
|
||||
@Unique
|
||||
private void extendedae_plus$onUpgradesChanged() {
|
||||
private void eap$onUpgradesChanged() {
|
||||
this.host.saveChanges();
|
||||
// 读取频道卡,更新无线链接频率
|
||||
long channel = 0L;
|
||||
for (var stack : this.extendedae_plus$upgrades) {
|
||||
for (var stack : this.eap$upgrades) {
|
||||
if (!stack.isEmpty() && stack.getItem() == ModItems.CHANNEL_CARD.get()) {
|
||||
channel = ChannelCardItem.getChannel(stack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (extendedae_plus$link == null) {
|
||||
if (eap$link == null) {
|
||||
var endpoint = new GenericNodeEndpointImpl(() -> host.getBlockEntity(), () -> this.mainNode.getNode());
|
||||
extendedae_plus$link = new WirelessSlaveLink(endpoint);
|
||||
eap$link = new WirelessSlaveLink(endpoint);
|
||||
}
|
||||
extendedae_plus$link.setFrequency(channel);
|
||||
extendedae_plus$link.updateStatus();
|
||||
eap$link.setFrequency(channel);
|
||||
eap$link.updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUpgradeInventory getUpgrades() {
|
||||
return this.extendedae_plus$upgrades;
|
||||
return this.eap$upgrades;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lappeng/api/networking/IManagedGridNode;Lappeng/helpers/patternprovider/PatternProviderLogicHost;I)V",
|
||||
at = @At("TAIL"))
|
||||
private void extendedae_plus$initUpgrades(IManagedGridNode mainNode, PatternProviderLogicHost host, int patternInventorySize, CallbackInfo ci) {
|
||||
this.extendedae_plus$upgrades = UpgradeInventories.forMachine(host.getTerminalIcon().getItem(), 1, this::extendedae_plus$onUpgradesChanged);
|
||||
private void eap$initUpgrades(IManagedGridNode mainNode, PatternProviderLogicHost host, int patternInventorySize, CallbackInfo ci) {
|
||||
this.eap$upgrades = UpgradeInventories.forMachine(host.getTerminalIcon().getItem(), 1, this::eap$onUpgradesChanged);
|
||||
}
|
||||
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"))
|
||||
private void extendedae_plus$saveUpgrades(CompoundTag tag, CallbackInfo ci) {
|
||||
this.extendedae_plus$upgrades.writeToNBT(tag, "upgrades");
|
||||
private void eap$saveUpgrades(CompoundTag tag, CallbackInfo ci) {
|
||||
this.eap$upgrades.writeToNBT(tag, "upgrades");
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"))
|
||||
private void extendedae_plus$loadUpgrades(CompoundTag tag, CallbackInfo ci) {
|
||||
this.extendedae_plus$upgrades.readFromNBT(tag, "upgrades");
|
||||
private void eap$loadUpgrades(CompoundTag tag, CallbackInfo ci) {
|
||||
this.eap$upgrades.readFromNBT(tag, "upgrades");
|
||||
}
|
||||
|
||||
@Inject(method = "addDrops", at = @At("TAIL"))
|
||||
private void extendedae_plus$dropUpgrades(List<ItemStack> drops, CallbackInfo ci) {
|
||||
for (var stack : this.extendedae_plus$upgrades) {
|
||||
private void eap$dropUpgrades(List<ItemStack> drops, CallbackInfo ci) {
|
||||
for (var stack : this.eap$upgrades) {
|
||||
if (!stack.isEmpty()) {
|
||||
drops.add(stack);
|
||||
}
|
||||
|
|
@ -99,14 +99,14 @@ public abstract class PatternProviderLogicUpgradesMixin implements IUpgradeableO
|
|||
}
|
||||
|
||||
@Inject(method = "clearContent", at = @At("TAIL"))
|
||||
private void extendedae_plus$clearUpgrades(CallbackInfo ci) {
|
||||
this.extendedae_plus$upgrades.clear();
|
||||
private void eap$clearUpgrades(CallbackInfo ci) {
|
||||
this.eap$upgrades.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$updateWirelessLink() {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.updateStatus();
|
||||
public void eap$updateWirelessLink() {
|
||||
if (eap$link != null) {
|
||||
eap$link.updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ public abstract class PatternProviderMenuUpgradesMixin extends AEBaseMenu implem
|
|||
@Shadow protected PatternProviderLogic logic;
|
||||
|
||||
@Unique
|
||||
private ToolboxMenu extendedae_plus$toolbox;
|
||||
private ToolboxMenu eap$toolbox;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/inventory/MenuType;ILnet/minecraft/world/entity/player/Inventory;Lappeng/helpers/patternprovider/PatternProviderLogicHost;)V",
|
||||
at = @At("TAIL"))
|
||||
private void extendedae_plus$initUpgrades(MenuType<?> menuType, int id, Inventory playerInventory, PatternProviderLogicHost host, CallbackInfo ci) {
|
||||
this.extendedae_plus$toolbox = new ToolboxMenu(this);
|
||||
private void eap$initUpgrades(MenuType<?> menuType, int id, Inventory playerInventory, PatternProviderLogicHost host, CallbackInfo ci) {
|
||||
this.eap$toolbox = new ToolboxMenu(this);
|
||||
this.setupUpgrades(((IUpgradeableObject) host).getUpgrades());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolboxMenu getToolbox() {
|
||||
return this.extendedae_plus$toolbox;
|
||||
return this.eap$toolbox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
public class AEBasePartClientSyncMixin {
|
||||
|
||||
@Inject(method = "writeToStream", at = @At("TAIL"))
|
||||
private void extendedae_plus$writeWirelessState(FriendlyByteBuf data, CallbackInfo ci) {
|
||||
private void eap$writeWirelessState(FriendlyByteBuf data, CallbackInfo ci) {
|
||||
// 检查是否实现了无线链接桥接接口
|
||||
if (this instanceof InterfaceWirelessLinkBridge) {
|
||||
InterfaceWirelessLinkBridge bridge = (InterfaceWirelessLinkBridge) this;
|
||||
|
|
@ -26,15 +26,10 @@ public class AEBasePartClientSyncMixin {
|
|||
// 只在服务端获取真实连接状态
|
||||
AEBasePart part = (AEBasePart)(Object)this;
|
||||
if (!part.isClientSide()) {
|
||||
connected = bridge.extendedae_plus$isWirelessConnected();
|
||||
// 调试日志:记录写入的状态
|
||||
if (part.getClass().getSimpleName().contains("IOBus")) {
|
||||
System.out.println("[写入状态] IOBus 无线连接状态: " + connected);
|
||||
}
|
||||
connected = bridge.eap$isWirelessConnected();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 忽略异常,默认为false
|
||||
System.err.println("获取无线连接状态失败: " + e.getMessage());
|
||||
}
|
||||
data.writeBoolean(connected);
|
||||
} else {
|
||||
|
|
@ -44,7 +39,7 @@ public class AEBasePartClientSyncMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "readFromStream", at = @At("TAIL"))
|
||||
private void extendedae_plus$readWirelessState(FriendlyByteBuf data, CallbackInfoReturnable<Boolean> cir) {
|
||||
private void eap$readWirelessState(FriendlyByteBuf data, CallbackInfoReturnable<Boolean> cir) {
|
||||
// 读取无线连接状态
|
||||
boolean connected = data.readBoolean();
|
||||
|
||||
|
|
@ -52,16 +47,10 @@ public class AEBasePartClientSyncMixin {
|
|||
if (this instanceof InterfaceWirelessLinkBridge) {
|
||||
InterfaceWirelessLinkBridge bridge = (InterfaceWirelessLinkBridge) this;
|
||||
try {
|
||||
// 调试日志:记录读取的状态
|
||||
AEBasePart part = (AEBasePart)(Object)this;
|
||||
if (part.getClass().getSimpleName().contains("IOBus")) {
|
||||
System.out.println("[读取状态] IOBus 无线连接状态: " + connected);
|
||||
}
|
||||
// 更新客户端状态
|
||||
bridge.extendedae_plus$setClientWirelessState(connected);
|
||||
bridge.eap$setClientWirelessState(connected);
|
||||
} catch (Exception e) {
|
||||
// 忽略异常
|
||||
System.err.println("设置客户端无线连接状态失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,45 +26,45 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
public abstract class IOBusPartChannelCardMixin implements InterfaceWirelessLinkBridge, IUpgradeableObject {
|
||||
|
||||
@Unique
|
||||
private WirelessSlaveLink extendedae_plus$link;
|
||||
private WirelessSlaveLink eap$link;
|
||||
|
||||
@Unique
|
||||
private long extendedae_plus$lastChannel = -1;
|
||||
private long eap$lastChannel = -1;
|
||||
|
||||
@Unique
|
||||
private boolean extendedae_plus$clientConnected = false;
|
||||
private boolean eap$clientConnected = false;
|
||||
|
||||
@Unique
|
||||
private boolean extendedae_plus$hasTickInitialized = false;
|
||||
private boolean eap$hasTickInitialized = false;
|
||||
|
||||
@Inject(method = "upgradesChanged", at = @At("TAIL"))
|
||||
private void extendedae_plus$onUpgradesChanged(CallbackInfo ci) {
|
||||
private void eap$onUpgradesChanged(CallbackInfo ci) {
|
||||
// 只在服务端初始化频道链接
|
||||
if (!((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
extendedae_plus$initializeChannelLink();
|
||||
eap$initializeChannelLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickingRequest", at = @At("HEAD"))
|
||||
private void extendedae_plus$beforeTick(appeng.api.networking.IGridNode node, int ticksSinceLastCall, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<appeng.api.networking.ticking.TickRateModulation> cir) {
|
||||
private void eap$beforeTick(appeng.api.networking.IGridNode node, int ticksSinceLastCall, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<appeng.api.networking.ticking.TickRateModulation> cir) {
|
||||
// 在第一次tick时初始化频道链接(此时网格节点已经在线)
|
||||
if (!extendedae_plus$hasTickInitialized && !((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
extendedae_plus$hasTickInitialized = true;
|
||||
extendedae_plus$initializeChannelLink();
|
||||
if (!eap$hasTickInitialized && !((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
eap$hasTickInitialized = true;
|
||||
eap$initializeChannelLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"))
|
||||
private void extendedae_plus$afterReadFromNBT(CompoundTag extra, CallbackInfo ci) {
|
||||
private void eap$afterReadFromNBT(CompoundTag extra, CallbackInfo ci) {
|
||||
// 从NBT加载时重置频道缓存和tick初始化标志
|
||||
if (!((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
extendedae_plus$lastChannel = -1;
|
||||
extendedae_plus$hasTickInitialized = false; // 重置标志,允许再次初始化
|
||||
eap$lastChannel = -1;
|
||||
eap$hasTickInitialized = false; // 重置标志,允许再次初始化
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void extendedae_plus$initializeChannelLink() {
|
||||
private void eap$initializeChannelLink() {
|
||||
// 防止重复调用
|
||||
if (((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
return;
|
||||
|
|
@ -83,18 +83,18 @@ public abstract class IOBusPartChannelCardMixin implements InterfaceWirelessLink
|
|||
}
|
||||
|
||||
// 频道没有变化则跳过
|
||||
if (extendedae_plus$lastChannel == channel) {
|
||||
if (eap$lastChannel == channel) {
|
||||
return;
|
||||
}
|
||||
extendedae_plus$lastChannel = channel;
|
||||
eap$lastChannel = channel;
|
||||
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] IOBus 初始化频道链接: found={}, channel={}", found, channel);
|
||||
|
||||
if (!found) {
|
||||
// 无频道卡则断开
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.setFrequency(0L);
|
||||
extendedae_plus$link.updateStatus();
|
||||
if (eap$link != null) {
|
||||
eap$link.setFrequency(0L);
|
||||
eap$link.updateStatus();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] IOBus 断开频道链接");
|
||||
// 立即通知客户端状态变化(断开连接无需延迟)
|
||||
((appeng.parts.AEBasePart)(Object)this).getHost().markForUpdate();
|
||||
|
|
@ -102,24 +102,18 @@ public abstract class IOBusPartChannelCardMixin implements InterfaceWirelessLink
|
|||
return;
|
||||
}
|
||||
|
||||
if (extendedae_plus$link == null) {
|
||||
if (eap$link == null) {
|
||||
var endpoint = new GenericNodeEndpointImpl(
|
||||
() -> ((appeng.parts.AEBasePart)(Object)this).getHost().getBlockEntity(),
|
||||
() -> ((IActionHost)(Object)this).getActionableNode()
|
||||
);
|
||||
extendedae_plus$link = new WirelessSlaveLink(endpoint);
|
||||
eap$link = new WirelessSlaveLink(endpoint);
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] IOBus 创建新的无线链接");
|
||||
}
|
||||
|
||||
extendedae_plus$link.setFrequency(channel);
|
||||
extendedae_plus$link.updateStatus();
|
||||
|
||||
// 调试信息:检查网格节点状态
|
||||
var gridNode = ((IActionHost)(Object)this).getActionableNode();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] IOBus 设置频道: {}, 连接状态: {}, 网格节点: {}, 在线: {}",
|
||||
channel, extendedae_plus$link.isConnected(),
|
||||
gridNode != null ? "exists" : "null",
|
||||
gridNode != null ? gridNode.isOnline() : "N/A");
|
||||
eap$link.setFrequency(channel);
|
||||
eap$link.updateStatus();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] IOBus 设置频道: {}, 连接状态: {}", channel, eap$link.isConnected());
|
||||
|
||||
// 通知客户端状态变化
|
||||
((appeng.parts.AEBasePart)(Object)this).getHost().markForUpdate();
|
||||
|
|
@ -129,23 +123,23 @@ public abstract class IOBusPartChannelCardMixin implements InterfaceWirelessLink
|
|||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$updateWirelessLink() {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.updateStatus();
|
||||
public void eap$updateWirelessLink() {
|
||||
if (eap$link != null) {
|
||||
eap$link.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean extendedae_plus$isWirelessConnected() {
|
||||
public boolean eap$isWirelessConnected() {
|
||||
if (((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
return extendedae_plus$clientConnected;
|
||||
return eap$clientConnected;
|
||||
} else {
|
||||
return extendedae_plus$link != null && extendedae_plus$link.isConnected();
|
||||
return eap$link != null && eap$link.isConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$setClientWirelessState(boolean connected) {
|
||||
extendedae_plus$clientConnected = connected;
|
||||
public void eap$setClientWirelessState(boolean connected) {
|
||||
eap$clientConnected = connected;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
public abstract class IOBusPartTickerChannelCardMixin {
|
||||
|
||||
@Inject(method = "tickingRequest", at = @At("TAIL"))
|
||||
private void extendedae_plus$tickTail(IGridNode node, int ticksSinceLastCall, CallbackInfoReturnable<TickRateModulation> cir) {
|
||||
private void eap$tickTail(IGridNode node, int ticksSinceLastCall, CallbackInfoReturnable<TickRateModulation> cir) {
|
||||
if (this instanceof InterfaceWirelessLinkBridge bridge) {
|
||||
bridge.extendedae_plus$updateWirelessLink();
|
||||
bridge.eap$updateWirelessLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,42 +26,42 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
public abstract class StorageBusPartChannelCardMixin implements InterfaceWirelessLinkBridge, IUpgradeableObject {
|
||||
|
||||
@Unique
|
||||
private WirelessSlaveLink extendedae_plus$link;
|
||||
private WirelessSlaveLink eap$link;
|
||||
|
||||
@Unique
|
||||
private long extendedae_plus$lastChannel = -1;
|
||||
private long eap$lastChannel = -1;
|
||||
|
||||
@Unique
|
||||
private boolean extendedae_plus$clientConnected = false;
|
||||
private boolean eap$clientConnected = false;
|
||||
|
||||
@Inject(method = "upgradesChanged", at = @At("TAIL"))
|
||||
private void extendedae_plus$onUpgradesChanged(CallbackInfo ci) {
|
||||
private void eap$onUpgradesChanged(CallbackInfo ci) {
|
||||
// 只在服务端初始化频道链接
|
||||
if (!((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
extendedae_plus$initializeChannelLink();
|
||||
eap$initializeChannelLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onMainNodeStateChanged", at = @At("TAIL"))
|
||||
private void extendedae_plus$onMainNodeStateChanged(IGridNodeListener.State reason, CallbackInfo ci) {
|
||||
private void eap$onMainNodeStateChanged(IGridNodeListener.State reason, CallbackInfo ci) {
|
||||
// 在节点状态变化时(包括加载后的GRID_BOOT)重新初始化频道链接
|
||||
if (reason == IGridNodeListener.State.GRID_BOOT && !((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
extendedae_plus$initializeChannelLink();
|
||||
eap$initializeChannelLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"))
|
||||
private void extendedae_plus$afterReadFromNBT(CompoundTag extra, CallbackInfo ci) {
|
||||
private void eap$afterReadFromNBT(CompoundTag extra, CallbackInfo ci) {
|
||||
// 从NBT加载后也重新初始化频道链接(只在服务端)
|
||||
if (!((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
// 从NBT加载时重置频道缓存,强制重新初始化
|
||||
extendedae_plus$lastChannel = -1;
|
||||
extendedae_plus$initializeChannelLink();
|
||||
eap$lastChannel = -1;
|
||||
eap$initializeChannelLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void extendedae_plus$initializeChannelLink() {
|
||||
private void eap$initializeChannelLink() {
|
||||
// 防止重复调用
|
||||
if (((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
return;
|
||||
|
|
@ -80,17 +80,17 @@ public abstract class StorageBusPartChannelCardMixin implements InterfaceWireles
|
|||
}
|
||||
|
||||
// 频道没有变化则跳过
|
||||
if (extendedae_plus$lastChannel == channel) {
|
||||
if (eap$lastChannel == channel) {
|
||||
return;
|
||||
}
|
||||
extendedae_plus$lastChannel = channel;
|
||||
eap$lastChannel = channel;
|
||||
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] StorageBus 初始化频道链接: found={}, channel={}", found, channel);
|
||||
|
||||
if (!found) {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.setFrequency(0L);
|
||||
extendedae_plus$link.updateStatus();
|
||||
if (eap$link != null) {
|
||||
eap$link.setFrequency(0L);
|
||||
eap$link.updateStatus();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] StorageBus 断开频道链接");
|
||||
// 通知客户端状态变化
|
||||
((appeng.parts.AEBasePart)(Object)this).getHost().markForUpdate();
|
||||
|
|
@ -98,24 +98,18 @@ public abstract class StorageBusPartChannelCardMixin implements InterfaceWireles
|
|||
return;
|
||||
}
|
||||
|
||||
if (extendedae_plus$link == null) {
|
||||
if (eap$link == null) {
|
||||
var endpoint = new GenericNodeEndpointImpl(
|
||||
() -> ((appeng.parts.AEBasePart)(Object)this).getHost().getBlockEntity(),
|
||||
() -> ((IActionHost)(Object)this).getActionableNode()
|
||||
);
|
||||
extendedae_plus$link = new WirelessSlaveLink(endpoint);
|
||||
eap$link = new WirelessSlaveLink(endpoint);
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] StorageBus 创建新的无线链接");
|
||||
}
|
||||
|
||||
extendedae_plus$link.setFrequency(channel);
|
||||
extendedae_plus$link.updateStatus();
|
||||
|
||||
// 调试信息:检查网格节点状态
|
||||
var gridNode = ((IActionHost)(Object)this).getActionableNode();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] StorageBus 设置频道: {}, 连接状态: {}, 网格节点: {}, 在线: {}",
|
||||
channel, extendedae_plus$link.isConnected(),
|
||||
gridNode != null ? "exists" : "null",
|
||||
gridNode != null ? gridNode.isOnline() : "N/A");
|
||||
eap$link.setFrequency(channel);
|
||||
eap$link.updateStatus();
|
||||
ExtendedAELogger.LOGGER.debug("[服务端] StorageBus 设置频道: {}, 连接状态: {}", channel, eap$link.isConnected());
|
||||
|
||||
// 通知客户端状态变化
|
||||
((appeng.parts.AEBasePart)(Object)this).getHost().markForUpdate();
|
||||
|
|
@ -125,23 +119,23 @@ public abstract class StorageBusPartChannelCardMixin implements InterfaceWireles
|
|||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$updateWirelessLink() {
|
||||
if (extendedae_plus$link != null) {
|
||||
extendedae_plus$link.updateStatus();
|
||||
public void eap$updateWirelessLink() {
|
||||
if (eap$link != null) {
|
||||
eap$link.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean extendedae_plus$isWirelessConnected() {
|
||||
public boolean eap$isWirelessConnected() {
|
||||
if (((appeng.parts.AEBasePart)(Object)this).isClientSide()) {
|
||||
return extendedae_plus$clientConnected;
|
||||
return eap$clientConnected;
|
||||
} else {
|
||||
return extendedae_plus$link != null && extendedae_plus$link.isConnected();
|
||||
return eap$link != null && eap$link.isConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedae_plus$setClientWirelessState(boolean connected) {
|
||||
extendedae_plus$clientConnected = connected;
|
||||
public void eap$setClientWirelessState(boolean connected) {
|
||||
eap$clientConnected = connected;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
public abstract class StorageBusPartTickerChannelCardMixin {
|
||||
|
||||
@Inject(method = "tickingRequest", at = @At("TAIL"))
|
||||
private void extendedae_plus$tickTail(IGridNode node, int ticksSinceLastCall, CallbackInfoReturnable<TickRateModulation> cir) {
|
||||
private void eap$tickTail(IGridNode node, int ticksSinceLastCall, CallbackInfoReturnable<TickRateModulation> cir) {
|
||||
if (this instanceof InterfaceWirelessLinkBridge bridge) {
|
||||
bridge.extendedae_plus$updateWirelessLink();
|
||||
bridge.eap$updateWirelessLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.extendedae_plus.hooks.BuiltInModelHooks;
|
|||
@Mixin(ModelBakery.class)
|
||||
public class ModelBakeryMixin {
|
||||
@Inject(method = "loadModel", at = @At("HEAD"), cancellable = true)
|
||||
private void extendedae_plus$loadModelHook(ResourceLocation id, CallbackInfo ci) {
|
||||
private void eap$loadModelHook(ResourceLocation id, CallbackInfo ci) {
|
||||
var model = BuiltInModelHooks.getBuiltInModel(id);
|
||||
if (model != null) {
|
||||
cacheAndQueueDependencies(id, model);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
public abstract class EncodePatternTransferHandlerMixin {
|
||||
|
||||
@Inject(method = "transferRecipe", at = @At("HEAD"), require = 0)
|
||||
private void extendedae_plus$captureProcessingName(PatternEncodingTermMenu menu,
|
||||
private void eap$captureProcessingName(PatternEncodingTermMenu menu,
|
||||
Object recipeBase,
|
||||
IRecipeSlotsView slotsView,
|
||||
Player player,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user