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