对供应器发配材料进行拦截,使用ScaledProcessingPattern
This commit is contained in:
parent
6924ff968a
commit
1d55920af9
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.extendedae_plus.mixin.ae2;
|
||||||
|
|
||||||
|
import appeng.api.crafting.IPatternDetails;
|
||||||
|
import appeng.me.service.CraftingService;
|
||||||
|
import com.extendedae_plus.content.ScaledProcessingPattern;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在 CraftingService.getProviders 调用点修改传入的 IPatternDetails 参数(回退到网络注册的原始样板)
|
||||||
|
*/
|
||||||
|
@Mixin(value = CraftingService.class, remap = false)
|
||||||
|
public class CraftingServiceGetProvidersMixin {
|
||||||
|
|
||||||
|
@ModifyArg(method = "getProviders(Lappeng/api/crafting/IPatternDetails;)Ljava/lang/Iterable;",
|
||||||
|
at = @At(value = "INVOKE", target = "Lappeng/me/service/helpers/NetworkCraftingProviders;getMediums(Lappeng/api/crafting/IPatternDetails;)Ljava/lang/Iterable;"),
|
||||||
|
index = 0)
|
||||||
|
private IPatternDetails extendedae_plus$modifyGetProvidersArg(IPatternDetails original) {
|
||||||
|
IPatternDetails base = null;
|
||||||
|
if (original instanceof ScaledProcessingPattern scaledProcessingPattern) {
|
||||||
|
base = scaledProcessingPattern.getOriginal();
|
||||||
|
System.out.println("[extendedae_plus] CraftingService.getProviders mixin invoked for: " + base);
|
||||||
|
}
|
||||||
|
return base == null ? original : base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.extendedae_plus.mixin.ae2;
|
||||||
|
|
||||||
|
import appeng.api.crafting.IPatternDetails;
|
||||||
|
import appeng.helpers.patternprovider.PatternProviderLogic;
|
||||||
|
import com.extendedae_plus.content.ScaledProcessingPattern;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect PatternProviderLogic.pushPattern 中对 List.contains 的调用,
|
||||||
|
* 在遇到缩放样板时回退匹配到原始样板实例。
|
||||||
|
*/
|
||||||
|
@Mixin(value = PatternProviderLogic.class, remap = false)
|
||||||
|
public class PatternProviderLogicContainsRedirectMixin {
|
||||||
|
|
||||||
|
@Redirect(method = "pushPattern",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Ljava/util/List;contains(Ljava/lang/Object;)Z")
|
||||||
|
)
|
||||||
|
private boolean extendedae_plus$patternsContains(List<?> list, Object o) {
|
||||||
|
try {
|
||||||
|
if (o instanceof ScaledProcessingPattern scaled) {
|
||||||
|
IPatternDetails base = scaled.getOriginal();
|
||||||
|
if (base != null && list.indexOf(base) != -1) {
|
||||||
|
System.out.println("[extendedae_plus] contains-redirect: matched base pattern for scaled pattern");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 使用 indexOf 避免再次触发对 List.contains 的 redirect(防止递归)
|
||||||
|
return list.indexOf(o) != -1;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
return list.indexOf(o) != -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,13 +27,18 @@
|
||||||
"jei.EncodePatternTransferHandlerMixin"
|
"jei.EncodePatternTransferHandlerMixin"
|
||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ae2.AEProcessingPatternMixin",
|
|
||||||
"ae2.ContainerPatternEncodingTermMenuMixin",
|
"ae2.ContainerPatternEncodingTermMenuMixin",
|
||||||
"ae2.CraftingCPUClusterMixin",
|
"ae2.CraftingCPUClusterMixin",
|
||||||
|
"ae2.CraftingServiceGetProvidersMixin",
|
||||||
"ae2.CraftingTreeProcessMixin",
|
"ae2.CraftingTreeProcessMixin",
|
||||||
"ae2.MEStorageMenuMixin",
|
"ae2.MEStorageMenuMixin",
|
||||||
|
"ae2.NetworkCraftingProvidersGetMediumsMixin",
|
||||||
|
"ae2.NetworkCraftingProvidersProviderStateMixin",
|
||||||
"ae2.PatternEncodingTermMenuMixin",
|
"ae2.PatternEncodingTermMenuMixin",
|
||||||
"ae2.PatternProviderLogicAdvancedMixin",
|
"ae2.PatternProviderLogicAdvancedMixin",
|
||||||
|
"ae2.PatternProviderLogicContainsRedirectMixin",
|
||||||
|
"ae2.PatternProviderLogicMixin",
|
||||||
|
"ae2.PatternProviderLogicPushPatternMixin",
|
||||||
"ae2.PatternProviderMenuAdvancedMixin",
|
"ae2.PatternProviderMenuAdvancedMixin",
|
||||||
"ae2.accessor.CraftingCalculationAccessor",
|
"ae2.accessor.CraftingCalculationAccessor",
|
||||||
"ae2.accessor.CraftingTreeNodeAccessor",
|
"ae2.accessor.CraftingTreeNodeAccessor",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user