feat: 添加智能系列功能支持内存卡复制 Closes #28

添加自定义Component
补全jade config翻译键
This commit is contained in:
C-H716 2025-11-21 17:29:51 +08:00
parent 0622767f10
commit 99a492f4c0
6 changed files with 78 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import appeng.block.AEBaseEntityBlock;
import appeng.blockentity.crafting.CraftingBlockEntity;
import appeng.items.parts.PartModelsHelper;
import com.extendedae_plus.ae.api.storage.InfinityBigIntegerCellHandler;
import com.extendedae_plus.api.ids.EAPComponents;
import com.extendedae_plus.config.ModConfigs;
import com.extendedae_plus.init.*;
import com.extendedae_plus.util.storage.InfinityStorageManager;
@ -55,6 +56,7 @@ public class ExtendedAEPlus {
// Register the Deferred Register to the mod event bus so menu types get registered
ModMenuTypes.MENUS.register(modEventBus);
EAPComponents.DR.register(modEventBus);
// Register ourselves for server and other game events we are interested in.
// Note that this is necessary if and only if we want *this* class (ExtendedAEPlus) to respond directly to events.
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.

View File

@ -0,0 +1,36 @@
package com.extendedae_plus.api.ids;
import com.extendedae_plus.ExtendedAEPlus;
import com.mojang.serialization.Codec;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.codec.ByteBufCodecs;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.function.UnaryOperator;
public final class EAPComponents {
public static final DeferredRegister<DataComponentType<?>> DR =
DeferredRegister.create(Registries.DATA_COMPONENT_TYPE, ExtendedAEPlus.MODID);
// 2. 你的自定义组件下面举几个常见例子
// 布尔值高级阻塞模式
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Boolean>> ADVANCED_BLOCKING =
register("advanced_blocking", builder ->
builder.persistent(Codec.BOOL) // 存档持久化
.networkSynchronized(ByteBufCodecs.BOOL)); // 网络同步客户端要看到
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Boolean>> SMART_DOUBLING =
register("smart_doubling", builder ->
builder.persistent(Codec.BOOL) // 存档持久化
.networkSynchronized(ByteBufCodecs.BOOL)); // 网络同步客户端要看到
private static <T> DeferredHolder<DataComponentType<?>, DataComponentType<T>> register(
String name,
UnaryOperator<DataComponentType.Builder<T>> builderOperator) {
return DR.register(name, () -> builderOperator.apply(DataComponentType.builder()).build());
}
}

View File

@ -7,7 +7,11 @@ import appeng.api.stacks.GenericStack;
import appeng.helpers.patternprovider.PatternProviderLogic;
import appeng.helpers.patternprovider.PatternProviderTarget;
import com.extendedae_plus.api.AdvancedBlockingHolder;
import com.extendedae_plus.api.ids.EAPComponents;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
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;
@ -37,12 +41,12 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
}
@Inject(method = "writeToNBT", at = @At("TAIL"))
private void eap$writeAdvancedToNbt(CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries, CallbackInfo ci) {
private void eap$writeAdvancedToNbt(CompoundTag tag, HolderLookup.Provider registries, CallbackInfo ci) {
tag.putBoolean(EAP_ADV_BLOCKING_KEY, this.eap$advancedBlocking);
}
@Inject(method = "readFromNBT", at = @At("TAIL"))
private void eap$readAdvancedFromNbt(CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries, CallbackInfo ci) {
private void eap$readAdvancedFromNbt(CompoundTag tag, HolderLookup.Provider registries, CallbackInfo ci) {
if (tag.contains(EAP_ADV_BLOCKING_KEY)) {
this.eap$advancedBlocking = tag.getBoolean(EAP_ADV_BLOCKING_KEY);
}
@ -55,7 +59,7 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
IPatternDetails patternDetails,
appeng.api.stacks.KeyCounter[] inputHolder) {
// 原版是否打开阻挡
boolean vanillaBlocking = ((PatternProviderLogic)(Object)this).isBlocking();
boolean vanillaBlocking = ((PatternProviderLogic) (Object) this).isBlocking();
if (!vanillaBlocking) {
return adapter.containsPatternInput(patternInputs);
}
@ -89,5 +93,18 @@ public class PatternProviderLogicAdvancedMixin implements AdvancedBlockingHolder
return true; // 每个输入槽都至少匹配了一个候选输入
}
@Shadow public void saveChanges() {}
@Shadow
public void saveChanges() {}
@Inject(method = "exportSettings", at = @At("TAIL"))
private void onExportSettings(DataComponentMap.Builder builder, CallbackInfo ci) {
builder.set(EAPComponents.ADVANCED_BLOCKING, this.eap$advancedBlocking);
}
@Inject(method = "importSettings", at = @At("TAIL"))
private void onImportSettings(DataComponentMap input, Player player, CallbackInfo ci) {
this.eap$advancedBlocking = Boolean.TRUE.equals(input.get(EAPComponents.ADVANCED_BLOCKING.get()));
// 持久化到 world
this.saveChanges();
}
}

View File

@ -5,8 +5,11 @@ import appeng.crafting.pattern.AEProcessingPattern;
import appeng.helpers.patternprovider.PatternProviderLogic;
import com.extendedae_plus.api.SmartDoublingAwarePattern;
import com.extendedae_plus.api.SmartDoublingHolder;
import com.extendedae_plus.api.ids.EAPComponents;
import com.extendedae_plus.mixin.ae2.accessor.PatternProviderLogicPatternsAccessor;
import net.minecraft.core.component.DataComponentMap;
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;
@ -72,4 +75,16 @@ public class PatternProviderLogicDoublingMixin implements SmartDoublingHolder {
@Shadow
public void saveChanges() {}
@Inject(method = "exportSettings", at = @At("TAIL"))
private void onExportSettings(DataComponentMap.Builder builder, CallbackInfo ci) {
builder.set(EAPComponents.SMART_DOUBLING, this.eap$smartDoubling);
}
@Inject(method = "importSettings", at = @At("TAIL"))
private void onImportSettings(DataComponentMap input, Player player, CallbackInfo ci) {
this.eap$smartDoubling = Boolean.TRUE.equals(input.get(EAPComponents.SMART_DOUBLING.get()));
// 持久化到 world
this.saveChanges();
}
}

View File

@ -76,6 +76,8 @@
"config.jade.plugin_extendedae_plus.wt_master_location": "Show Master Node Location",
"config.jade.plugin_extendedae_plus.wt_locked": "Show Lock Status",
"config.jade.plugin_extendedae_plus.wt_network_usable": "Show Network Online Status",
"config.jade.plugin_extendedae_plus.wt_channels": "Show Channel Usage",
"config.jade.plugin_extendedae_plus.wt_owner": "Show Owner Information",
"extendedae_plus.tooltip.frequency": "Frequency: %d",
"extendedae_plus.tooltip.master_mode": "Mode: %s",
"extendedae_plus.tooltip.locked": "Lock Status: %s",

View File

@ -76,6 +76,8 @@
"config.jade.plugin_extendedae_plus.wt_master_location": "显示主节点位置",
"config.jade.plugin_extendedae_plus.wt_locked": "显示锁定状态",
"config.jade.plugin_extendedae_plus.wt_network_usable": "显示网络在线状态",
"config.jade.plugin_extendedae_plus.wt_channels": "显示频道使用情况",
"config.jade.plugin_extendedae_plus.wt_owner": "显示所有者信息",
"extendedae_plus.tooltip.frequency": "频率: %d",
"extendedae_plus.tooltip.master_mode": "模式: %s",
"extendedae_plus.tooltip.locked": "锁定状态: %s",