From f6b2c8c6142745208304ff228ddec68a75093c67 Mon Sep 17 00:00:00 2001 From: XianYuFish001 Date: Wed, 24 Sep 2025 14:27:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E5=8F=96=E5=92=8Cmaster=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E5=BC=80=E6=BA=90=E5=8D=8F=E8=AE=AE,?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0readme,=E6=B7=BB=E5=8A=A0component=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- readme.md | 6 ++ .../com/extendedae_plus/ExtendedAEPlus.java | 36 ++------- .../com/extendedae_plus/config/ModConfig.java | 10 ++- .../java/com/extendedae_plus/util/GetKey.java | 81 +++++++++++++++++++ 5 files changed, 100 insertions(+), 35 deletions(-) create mode 100644 readme.md create mode 100644 src/main/java/com/extendedae_plus/util/GetKey.java diff --git a/gradle.properties b/gradle.properties index c9bb96e..0407709 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ loader_version_range=[1,) ## Mod Properties mod_id=extendedae_plus mod_name=ExtendedAE-Plus -mod_license=MIT +mod_license=LGPL-3.0-or-later mod_version=1.0.0 mod_group_id=com.extendedae_plus mod_authors=GaLicn, XianYuFish001 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..24f5a66 --- /dev/null +++ b/readme.md @@ -0,0 +1,6 @@ +# ExtendedAE Plus +_这个分支是粗浅的EMI适配,技术力不足,请见谅_ + +### 相较于主分支(1.4.0)的改动: +- 删除了JEI的适配 +- 一些QoL功能, 针对EMI环境下遇到的问题 \ No newline at end of file diff --git a/src/main/java/com/extendedae_plus/ExtendedAEPlus.java b/src/main/java/com/extendedae_plus/ExtendedAEPlus.java index f11d489..703b64c 100644 --- a/src/main/java/com/extendedae_plus/ExtendedAEPlus.java +++ b/src/main/java/com/extendedae_plus/ExtendedAEPlus.java @@ -24,23 +24,14 @@ import net.neoforged.neoforge.event.level.LevelEvent; import net.neoforged.neoforge.event.server.ServerStartingEvent; import org.slf4j.Logger; -// The value here should match an entry in the META-INF/neoforge.mods.toml file @Mod(ExtendedAEPlus.MODID) public class ExtendedAEPlus { - // Define mod id in a common place for everything to reference public static final String MODID = "extendedae_plus"; - // Directly reference a slf4j logger public static final Logger LOGGER = LogUtils.getLogger(); - // 移除 MDK 示例注册,改为使用实际模组的方块/物品/创造物品栏注册见 ModBlocks、ModItems、ModCreativeTabs - // The constructor for the mod class is the first code that is run when your mod is loaded. - // FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically. public ExtendedAEPlus(IEventBus modEventBus, ModContainer modContainer) { - // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); - // 注册网络负载处理器(NeoForge 1.21 新式 Payload API) modEventBus.addListener(ModNetwork::registerPayloadHandlers); - // 注册能力:让 AE2 电缆识别我们的 In-World Grid Node Host modEventBus.addListener(ModCapabilities::onRegisterCapabilities); /* @@ -48,42 +39,32 @@ public class ExtendedAEPlus { 将这literal地狱烧成灰(bushi 反正就是引入dataGeneration, 多写点translatable 顺便不小心露出我无敌的component工具类( - 还有改一下config的结构 + 算了算了,我真不敢动aaa */ - // 注册本模组方块/物品/创造物品栏 ModBlocks.BLOCKS.register(modEventBus); ModItems.ITEMS.register(modEventBus); ModBlockEntities.BLOCK_ENTITY_TYPES.register(modEventBus); ModCreativeTabs.TABS.register(modEventBus); - // Register the Deferred Register to the mod event bus so menu types get registered ModMenuTypes.MENUS.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. NeoForge.EVENT_BUS.register(this); NeoForge.EVENT_BUS.addListener(ExtendedAEPlus::onLevelLoad); NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerTick); NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerStopping); - // 注册配置:接入自定义的 ModConfigs modContainer.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, ModConfig.COMMON_SPEC); } - // 便捷 ResourceLocation 工具 public static ResourceLocation id(String path) { return ResourceLocation.fromNamespaceAndPath(MODID, path); } private void commonSetup(FMLCommonSetupEvent event) { - // Some common setup code LOGGER.info("HELLO FROM COMMON SETUP"); - // 示例日志,避免引用不存在的模板 Config 字段 LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT)); StorageCells.addCellHandler(InfinityBigIntegerCellHandler.INSTANCE); - // 绑定 AE2 的 CraftingBlockEntity 到本模组的自定义加速器方块,避免 AEBaseEntityBlock.blockEntityType 为空 event.enqueueWork(() -> { try { // 注册自定义 AE2 MenuLocator(用于 Curios 槽位打开菜单) @@ -98,11 +79,11 @@ public class ExtendedAEPlus { LOGGER.warn("Failed to register CuriosItemLocator with AE2 MenuLocators: {}", t.toString()); } - AEBaseEntityBlock b4 = (AEBaseEntityBlock) ModBlocks.ACCELERATOR_4x.get(); - AEBaseEntityBlock b16 = (AEBaseEntityBlock) ModBlocks.ACCELERATOR_16x.get(); - AEBaseEntityBlock b64 = (AEBaseEntityBlock) ModBlocks.ACCELERATOR_64x.get(); - AEBaseEntityBlock b256 = (AEBaseEntityBlock) ModBlocks.ACCELERATOR_256x.get(); - AEBaseEntityBlock b1024 = (AEBaseEntityBlock) ModBlocks.ACCELERATOR_1024x.get(); + AEBaseEntityBlock b4 = ModBlocks.ACCELERATOR_4x.get(); + AEBaseEntityBlock b16 = ModBlocks.ACCELERATOR_16x.get(); + AEBaseEntityBlock b64 = ModBlocks.ACCELERATOR_64x.get(); + AEBaseEntityBlock b256 = ModBlocks.ACCELERATOR_256x.get(); + AEBaseEntityBlock b1024 = ModBlocks.ACCELERATOR_1024x.get(); // 使用我们自定义的 CraftingBlockEntity 类型,它的有效方块列表包含自定义加速器 var type = ModBlockEntities.EPLUS_CRAFTING_UNIT_BE.get(); @@ -119,13 +100,8 @@ public class ExtendedAEPlus { }); } - // 移除示例 addCreative 事件,避免将示例物品加入原版标签 - - // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { - // Do something when the server starts - LOGGER.info("HELLO from server starting"); } diff --git a/src/main/java/com/extendedae_plus/config/ModConfig.java b/src/main/java/com/extendedae_plus/config/ModConfig.java index 7ea735f..a5f3558 100644 --- a/src/main/java/com/extendedae_plus/config/ModConfig.java +++ b/src/main/java/com/extendedae_plus/config/ModConfig.java @@ -1,5 +1,6 @@ package com.extendedae_plus.config; +import com.extendedae_plus.util.GetKey; import net.neoforged.neoforge.common.ModConfigSpec; public final class ModConfig { @@ -39,14 +40,16 @@ public final class ModConfig { .define("patternTerminalShowSlotsDefault", true); OVERRIDE_AE2WT_PICKING = builder - .translation("config.extendedae_plus.override_ae2wt_picking") + .translation(new GetKey(GetKey.CONFIG) + .addStr("override_ae2wt_picking").buildRaw()) .comment("是否覆盖AE2WT使用中键从终端选取方块的逻辑", "开启后选取方块的数量将不被限制在32个", "(不建议使用,在EMI环境下可能出现奇怪bug)") .define("overrideAE2WTPicking", false); INDEPENDENT_UPLOADING_BUTTON = builder - .translation("config.extendedae_plus.independent_uploading_button") + .translation(new GetKey(GetKey.CONFIG) + .addStr("independence_uploading_button").buildRaw()) .comment("启用后,在样板编码终端会出现一个独立的按钮用于上传样板") .define("independentUploadingButton", false); @@ -59,8 +62,7 @@ public final class ModConfig { PROVIDER_ROUND_ROBIN_ENABLE = builder.comment( "智能倍增时是否对样板供应器轮询分配", "仅多个供应器有相同样板时生效,开启后请求会均分到所有可用供应器,关闭则全部分配给单一供应器", - "注意:所有相关供应器需开启智能倍增,否则可能失效", - "默认: true") + "注意:所有相关供应器需开启智能倍增,否则可能失效") .define("providerRoundRobinEnable", true); // 智能倍增的最大倍数(以单次样板产出为单位)。 diff --git a/src/main/java/com/extendedae_plus/util/GetKey.java b/src/main/java/com/extendedae_plus/util/GetKey.java new file mode 100644 index 0000000..2359bf6 --- /dev/null +++ b/src/main/java/com/extendedae_plus/util/GetKey.java @@ -0,0 +1,81 @@ +package com.extendedae_plus.util; + +import com.extendedae_plus.ExtendedAEPlus; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.fluids.FluidType; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredItem; + +public class GetKey { + private final String keyType; + private String mainDescription = ExtendedAEPlus.MODID; + private String additionalKey = "."; + private Object[] args; + + public static final String CTAB = "ctab"; + public static final String GUI = "gui"; + public static final String MESSAGE = "message"; + public static final String CONFIG = "config"; + + public GetKey() { + this.keyType = ""; + } + + public GetKey(String keyType) { + this.keyType = keyType.toLowerCase() + '.'; + } + + public GetKey(DeferredItem item) { + this.keyType = ""; + this.mainDescription = item.asItem().getDescriptionId().toLowerCase(); + } + + public GetKey(DeferredHolder fluid) { + this.keyType = ""; + this.mainDescription = fluid.get().getDescriptionId().toLowerCase(); + this.additionalKey = ""; + } + + public GetKey item(ItemStack item) { + this.mainDescription = item.getDescriptionId().toLowerCase(); + return this; + } + + public GetKey item(Item item) { + this.mainDescription = item.getDescriptionId().toLowerCase(); + return this; + } + + public GetKey item(DeferredItem item) { + this.mainDescription = item.asItem().getDescriptionId().toLowerCase(); + return this; + } + + public GetKey addStr(String additionalKey) { + if (!this.additionalKey.endsWith(".")) + this.additionalKey += "."; + this.additionalKey += additionalKey; + return this; + } + + public GetKey obj(Object... args) { + this.args = args; + return this; + } + + public String buildRaw() { + return keyType + mainDescription + additionalKey; + } + + public Component build() { + if (args == null) return Component.translatable(keyType + mainDescription + additionalKey); + return Component.translatable(keyType + mainDescription + additionalKey, args); + } + + public String getDescriptionID(ItemStack itemStack) { + return "item.fish_things." + BuiltInRegistries.ITEM.getKey(itemStack.getItem()).getPath(); + } +}