修复改用网络发包后导致通用无线样板管理终端上传失败的问题
This commit is contained in:
parent
4eabb242bc
commit
05492e2ffe
|
|
@ -0,0 +1,79 @@
|
|||
package com.extendedae_plus.mixin;
|
||||
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import com.extendedae_plus.util.ExtendedAEPatternUploadUtil;
|
||||
import com.glodblock.github.extendedae.xmod.wt.ContainerUWirelessExPAT;
|
||||
import com.glodblock.github.extendedae.xmod.wt.HostUWirelessExPAT;
|
||||
import com.glodblock.github.glodium.network.packet.sync.IActionHolder;
|
||||
import com.glodblock.github.glodium.network.packet.sync.Paras;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 为通用无线样板访问终端(AE2WTlib 集成)容器注册通用动作(CGenericPacket 分发)
|
||||
*/
|
||||
@Mixin(ContainerUWirelessExPAT.class)
|
||||
public abstract class ContainerUWirelessExPatternTerminalMixin implements IActionHolder {
|
||||
|
||||
@Unique
|
||||
private final Map<String, Consumer<Paras>> actions = createHolder();
|
||||
|
||||
@Unique
|
||||
private Player epp$player;
|
||||
|
||||
// 明确目标构造签名:<init>(int, Inventory, HostUWirelessExPAT)
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lcom/glodblock/github/extendedae/xmod/wt/HostUWirelessExPAT;)V", at = @At("TAIL"))
|
||||
private void init(int id, net.minecraft.world.entity.player.Inventory playerInventory, HostUWirelessExPAT host, CallbackInfo ci) {
|
||||
this.epp$player = playerInventory.player;
|
||||
// 注册上传动作:参数顺序必须与客户端 CGenericPacket 保持一致
|
||||
this.actions.put("upload", p -> {
|
||||
try {
|
||||
Object o0 = p.get(0);
|
||||
Object o1 = p.get(1);
|
||||
int playerSlotIndex = (o0 instanceof Number) ? ((Number) o0).intValue() : Integer.parseInt(String.valueOf(o0));
|
||||
long providerId = (o1 instanceof Number) ? ((Number) o1).longValue() : Long.parseLong(String.valueOf(o1));
|
||||
var sp = (ServerPlayer) this.epp$player;
|
||||
System.out.println("[EAE+][Server][UWireless] upload: slot=" + playerSlotIndex + ", provider=" + providerId);
|
||||
ExtendedAEPatternUploadUtil.uploadPatternToProvider(sp, playerSlotIndex, providerId);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
System.out.println("[EAE+][Server] UWirelessExPAT actions registered: " + this.actions.keySet());
|
||||
}
|
||||
|
||||
// 兼容部分整合包构造签名(第三参为 IConfigurableObject),在不存在该重载时不报错
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lappeng/api/util/IConfigurableObject;)V", at = @At("TAIL"), require = 0)
|
||||
private void initFallback(int id, net.minecraft.world.entity.player.Inventory playerInventory, IConfigurableObject host, CallbackInfo ci) {
|
||||
this.epp$player = playerInventory.player;
|
||||
this.actions.put("upload", p -> {
|
||||
try {
|
||||
Object o0 = p.get(0);
|
||||
Object o1 = p.get(1);
|
||||
int playerSlotIndex = (o0 instanceof Number) ? ((Number) o0).intValue() : Integer.parseInt(String.valueOf(o0));
|
||||
long providerId = (o1 instanceof Number) ? ((Number) o1).longValue() : Long.parseLong(String.valueOf(o1));
|
||||
var sp = (ServerPlayer) this.epp$player;
|
||||
System.out.println("[EAE+][Server][UWireless/Fallback] upload: slot=" + playerSlotIndex + ", provider=" + providerId);
|
||||
ExtendedAEPatternUploadUtil.uploadPatternToProvider(sp, playerSlotIndex, providerId);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
System.out.println("[EAE+][Server] UWirelessExPAT actions registered (fallback): " + this.actions.keySet());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Consumer<Paras>> getActionMap() {
|
||||
return this.actions;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.extendedae_plus.mixin;
|
||||
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import com.extendedae_plus.util.ExtendedAEPatternUploadUtil;
|
||||
import com.glodblock.github.extendedae.container.ContainerWirelessExPAT;
|
||||
import com.glodblock.github.extendedae.common.me.itemhost.HostWirelessExPAT;
|
||||
|
|
@ -28,7 +30,8 @@ public abstract class ContainerWirelessExPatternTerminalMixin implements IAction
|
|||
@Unique
|
||||
private Player epp$player;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
// 明确目标构造签名:<init>(int, Inventory, HostWirelessExPAT)
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lcom/glodblock/github/extendedae/common/me/itemhost/HostWirelessExPAT;)V", at = @At("TAIL"))
|
||||
private void init(int id, net.minecraft.world.entity.player.Inventory playerInventory, HostWirelessExPAT host, CallbackInfo ci) {
|
||||
this.epp$player = playerInventory.player;
|
||||
// 注册上传动作:参数顺序必须与客户端 CGenericPacket 保持一致
|
||||
|
|
@ -48,6 +51,26 @@ public abstract class ContainerWirelessExPatternTerminalMixin implements IAction
|
|||
System.out.println("[EAE+][Server] WirelessExPAT actions registered: " + this.actions.keySet());
|
||||
}
|
||||
|
||||
// 兼容部分整合包构造签名(第三参为 IConfigurableObject),在不存在该重载时不报错
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lappeng/api/util/IConfigurableObject;)V", at = @At("TAIL"), require = 0)
|
||||
private void initFallback(int id, net.minecraft.world.entity.player.Inventory playerInventory, IConfigurableObject host, CallbackInfo ci) {
|
||||
this.epp$player = playerInventory.player;
|
||||
this.actions.put("upload", p -> {
|
||||
try {
|
||||
Object o0 = p.get(0);
|
||||
Object o1 = p.get(1);
|
||||
int playerSlotIndex = (o0 instanceof Number) ? ((Number) o0).intValue() : Integer.parseInt(String.valueOf(o0));
|
||||
long providerId = (o1 instanceof Number) ? ((Number) o1).longValue() : Long.parseLong(String.valueOf(o1));
|
||||
var sp = (ServerPlayer) this.epp$player;
|
||||
System.out.println("[EAE+][Server][Wireless/Fallback] upload: slot=" + playerSlotIndex + ", provider=" + providerId);
|
||||
ExtendedAEPatternUploadUtil.uploadPatternToProvider(sp, playerSlotIndex, providerId);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
System.out.println("[EAE+][Server] WirelessExPAT actions registered (fallback): " + this.actions.keySet());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Consumer<Paras>> getActionMap() {
|
||||
|
|
|
|||
|
|
@ -34,3 +34,6 @@ mandatory = true
|
|||
versionRange = "[1.4.2,)"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "extendedae_plus.mixins.json"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
"mixins": [
|
||||
"ContainerExPatternProviderMixin",
|
||||
"ContainerExPatternTerminalMixin",
|
||||
"ContainerWirelessExPatternTerminalMixin"
|
||||
"ContainerWirelessExPatternTerminalMixin",
|
||||
"ContainerUWirelessExPatternTerminalMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user