feat: 添加内存卡对供应器智能阻挡、智能倍增设置复制支持
This commit is contained in:
parent
477a5ffee7
commit
6219c0b434
|
|
@ -8,7 +8,9 @@ import appeng.helpers.patternprovider.PatternProviderLogic;
|
|||
import appeng.helpers.patternprovider.PatternProviderTarget;
|
||||
import com.extendedae_plus.api.AdvancedBlockingHolder;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
|
@ -17,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
@Mixin(PatternProviderLogic.class)
|
||||
@Mixin(value = PatternProviderLogic.class, remap = false)
|
||||
public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder {
|
||||
@Unique
|
||||
private static final String EPP_ADV_BLOCKING_KEY = "epp_advanced_blocking";
|
||||
|
|
@ -35,12 +37,12 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
|
|||
this.eap$advancedBlocking = value;
|
||||
}
|
||||
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"), remap = false)
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"))
|
||||
private void eap$writeAdvancedToNbt(CompoundTag tag, CallbackInfo ci) {
|
||||
tag.putBoolean(EPP_ADV_BLOCKING_KEY, this.eap$advancedBlocking);
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"), remap = false)
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"))
|
||||
private void eap$readAdvancedFromNbt(CompoundTag tag, CallbackInfo ci) {
|
||||
if (tag.contains(EPP_ADV_BLOCKING_KEY)) {
|
||||
this.eap$advancedBlocking = tag.getBoolean(EPP_ADV_BLOCKING_KEY);
|
||||
|
|
@ -48,7 +50,7 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
|
|||
}
|
||||
|
||||
// 在 pushPattern 中,重定向对 adapter.containsPatternInput(...) 的调用
|
||||
@Redirect(method = "pushPattern", at = @At(value = "INVOKE", target = "Lappeng/helpers/patternprovider/PatternProviderTarget;containsPatternInput(Ljava/util/Set;)Z"), remap = false)
|
||||
@Redirect(method = "pushPattern", at = @At(value = "INVOKE", target = "Lappeng/helpers/patternprovider/PatternProviderTarget;containsPatternInput(Ljava/util/Set;)Z"))
|
||||
private boolean eap$redirectBlockingContains(PatternProviderTarget adapter,
|
||||
java.util.Set<AEKey> patternInputs,
|
||||
IPatternDetails patternDetails,
|
||||
|
|
@ -87,4 +89,21 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
|
|||
}
|
||||
return true; // 每个输入槽都至少匹配了一个候选输入
|
||||
}
|
||||
|
||||
@Shadow public void saveChanges() {}
|
||||
|
||||
@Inject(method = "exportSettings(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("TAIL"))
|
||||
private void onExportSettings(CompoundTag output, CallbackInfo ci) {
|
||||
System.out.println(this.eap$advancedBlocking);
|
||||
output.putBoolean("eap_advanced_blocking", this.eap$advancedBlocking);
|
||||
}
|
||||
|
||||
@Inject(method = "importSettings(Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/entity/player/Player;)V", at = @At("TAIL"))
|
||||
private void onImportSettings(CompoundTag input, Player player, CallbackInfo ci) {
|
||||
if (input.contains("eap_advanced_blocking")) {
|
||||
this.eap$advancedBlocking = input.getBoolean("eap_advanced_blocking");
|
||||
// 持久化到 world
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,15 @@ import com.extendedae_plus.api.SmartDoublingAwarePattern;
|
|||
import com.extendedae_plus.api.SmartDoublingHolder;
|
||||
import com.extendedae_plus.mixin.ae2.accessor.PatternProviderLogicPatternsAccessor;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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;
|
||||
|
||||
@Mixin(PatternProviderLogic.class)
|
||||
@Mixin(value = PatternProviderLogic.class, remap = false)
|
||||
public class PatternProviderLogicDoublingMixin implements SmartDoublingHolder {
|
||||
@Unique
|
||||
private static final String EPP_SMART_DOUBLING_KEY = "epp_smart_doubling";
|
||||
|
|
@ -43,19 +45,19 @@ public class PatternProviderLogicDoublingMixin implements SmartDoublingHolder {
|
|||
}
|
||||
}
|
||||
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"), remap = false)
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"))
|
||||
private void eap$writeSmartDoublingToNbt(CompoundTag tag, CallbackInfo ci) {
|
||||
tag.putBoolean(EPP_SMART_DOUBLING_KEY, this.eap$smartDoubling);
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"), remap = false)
|
||||
@Inject(method = "readFromNBT", at = @At("TAIL"))
|
||||
private void eap$readSmartDoublingFromNbt(CompoundTag tag, CallbackInfo ci) {
|
||||
if (tag.contains(EPP_SMART_DOUBLING_KEY)) {
|
||||
this.eap$smartDoubling = tag.getBoolean(EPP_SMART_DOUBLING_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updatePatterns", at = @At("TAIL"), remap = false)
|
||||
@Inject(method = "updatePatterns", at = @At("TAIL"))
|
||||
private void eap$applySmartDoublingToPatterns(CallbackInfo ci) {
|
||||
try {
|
||||
var list = ((PatternProviderLogicPatternsAccessor) this).eap$patterns();
|
||||
|
|
@ -68,4 +70,22 @@ public class PatternProviderLogicDoublingMixin implements SmartDoublingHolder {
|
|||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public void saveChanges() {}
|
||||
|
||||
@Inject(method = "exportSettings(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("TAIL"))
|
||||
private void onExportSettings(CompoundTag output, CallbackInfo ci) {
|
||||
System.out.println(this.eap$smartDoubling);
|
||||
output.putBoolean("eap_smart_doubling", this.eap$smartDoubling);
|
||||
}
|
||||
|
||||
@Inject(method = "importSettings(Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/entity/player/Player;)V", at = @At("TAIL"))
|
||||
private void onImportSettings(CompoundTag input, Player player, CallbackInfo ci) {
|
||||
if (input.contains("eap_smart_doubling")) {
|
||||
this.eap$smartDoubling = input.getBoolean("eap_smart_doubling");
|
||||
// 持久化到 world
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user