选取和master一样的开源协议,添加readme,添加component工具类
This commit is contained in:
parent
1c1eb8bc0c
commit
f6b2c8c614
|
|
@ -14,7 +14,7 @@ loader_version_range=[1,)
|
||||||
## Mod Properties
|
## Mod Properties
|
||||||
mod_id=extendedae_plus
|
mod_id=extendedae_plus
|
||||||
mod_name=ExtendedAE-Plus
|
mod_name=ExtendedAE-Plus
|
||||||
mod_license=MIT
|
mod_license=LGPL-3.0-or-later
|
||||||
mod_version=1.0.0
|
mod_version=1.0.0
|
||||||
mod_group_id=com.extendedae_plus
|
mod_group_id=com.extendedae_plus
|
||||||
mod_authors=GaLicn, XianYuFish001
|
mod_authors=GaLicn, XianYuFish001
|
||||||
|
|
|
||||||
6
readme.md
Normal file
6
readme.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# ExtendedAE Plus
|
||||||
|
_这个分支是粗浅的EMI适配,技术力不足,请见谅_
|
||||||
|
|
||||||
|
### 相较于主分支(1.4.0)的改动:
|
||||||
|
- 删除了JEI的适配
|
||||||
|
- 一些QoL功能, 针对EMI环境下遇到的问题
|
||||||
|
|
@ -24,23 +24,14 @@ import net.neoforged.neoforge.event.level.LevelEvent;
|
||||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
// The value here should match an entry in the META-INF/neoforge.mods.toml file
|
|
||||||
@Mod(ExtendedAEPlus.MODID)
|
@Mod(ExtendedAEPlus.MODID)
|
||||||
public class ExtendedAEPlus {
|
public class ExtendedAEPlus {
|
||||||
// Define mod id in a common place for everything to reference
|
|
||||||
public static final String MODID = "extendedae_plus";
|
public static final String MODID = "extendedae_plus";
|
||||||
// Directly reference a slf4j logger
|
|
||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
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) {
|
public ExtendedAEPlus(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
// Register the commonSetup method for modloading
|
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
// 注册网络负载处理器(NeoForge 1.21 新式 Payload API)
|
|
||||||
modEventBus.addListener(ModNetwork::registerPayloadHandlers);
|
modEventBus.addListener(ModNetwork::registerPayloadHandlers);
|
||||||
// 注册能力:让 AE2 电缆识别我们的 In-World Grid Node Host
|
|
||||||
modEventBus.addListener(ModCapabilities::onRegisterCapabilities);
|
modEventBus.addListener(ModCapabilities::onRegisterCapabilities);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -48,42 +39,32 @@ public class ExtendedAEPlus {
|
||||||
将这literal地狱烧成灰(bushi
|
将这literal地狱烧成灰(bushi
|
||||||
反正就是引入dataGeneration, 多写点translatable
|
反正就是引入dataGeneration, 多写点translatable
|
||||||
顺便不小心露出我无敌的component工具类(
|
顺便不小心露出我无敌的component工具类(
|
||||||
还有改一下config的结构
|
算了算了,我真不敢动aaa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 注册本模组方块/物品/创造物品栏
|
|
||||||
ModBlocks.BLOCKS.register(modEventBus);
|
ModBlocks.BLOCKS.register(modEventBus);
|
||||||
ModItems.ITEMS.register(modEventBus);
|
ModItems.ITEMS.register(modEventBus);
|
||||||
ModBlockEntities.BLOCK_ENTITY_TYPES.register(modEventBus);
|
ModBlockEntities.BLOCK_ENTITY_TYPES.register(modEventBus);
|
||||||
ModCreativeTabs.TABS.register(modEventBus);
|
ModCreativeTabs.TABS.register(modEventBus);
|
||||||
// Register the Deferred Register to the mod event bus so menu types get registered
|
|
||||||
ModMenuTypes.MENUS.register(modEventBus);
|
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.register(this);
|
||||||
NeoForge.EVENT_BUS.addListener(ExtendedAEPlus::onLevelLoad);
|
NeoForge.EVENT_BUS.addListener(ExtendedAEPlus::onLevelLoad);
|
||||||
|
|
||||||
NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerTick);
|
NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerTick);
|
||||||
NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerStopping);
|
NeoForge.EVENT_BUS.addListener(InfinityBigIntegerCellInventory::onServerStopping);
|
||||||
|
|
||||||
// 注册配置:接入自定义的 ModConfigs
|
|
||||||
modContainer.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, ModConfig.COMMON_SPEC);
|
modContainer.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, ModConfig.COMMON_SPEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 便捷 ResourceLocation 工具
|
|
||||||
public static ResourceLocation id(String path) {
|
public static ResourceLocation id(String path) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(MODID, path);
|
return ResourceLocation.fromNamespaceAndPath(MODID, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commonSetup(FMLCommonSetupEvent event) {
|
private void commonSetup(FMLCommonSetupEvent event) {
|
||||||
// Some common setup code
|
|
||||||
LOGGER.info("HELLO FROM COMMON SETUP");
|
LOGGER.info("HELLO FROM COMMON SETUP");
|
||||||
// 示例日志,避免引用不存在的模板 Config 字段
|
|
||||||
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT));
|
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT));
|
||||||
StorageCells.addCellHandler(InfinityBigIntegerCellHandler.INSTANCE);
|
StorageCells.addCellHandler(InfinityBigIntegerCellHandler.INSTANCE);
|
||||||
// 绑定 AE2 的 CraftingBlockEntity 到本模组的自定义加速器方块,避免 AEBaseEntityBlock.blockEntityType 为空
|
|
||||||
event.enqueueWork(() -> {
|
event.enqueueWork(() -> {
|
||||||
try {
|
try {
|
||||||
// 注册自定义 AE2 MenuLocator(用于 Curios 槽位打开菜单)
|
// 注册自定义 AE2 MenuLocator(用于 Curios 槽位打开菜单)
|
||||||
|
|
@ -98,11 +79,11 @@ public class ExtendedAEPlus {
|
||||||
LOGGER.warn("Failed to register CuriosItemLocator with AE2 MenuLocators: {}", t.toString());
|
LOGGER.warn("Failed to register CuriosItemLocator with AE2 MenuLocators: {}", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
AEBaseEntityBlock<CraftingBlockEntity> b4 = (AEBaseEntityBlock<CraftingBlockEntity>) ModBlocks.ACCELERATOR_4x.get();
|
AEBaseEntityBlock<CraftingBlockEntity> b4 = ModBlocks.ACCELERATOR_4x.get();
|
||||||
AEBaseEntityBlock<CraftingBlockEntity> b16 = (AEBaseEntityBlock<CraftingBlockEntity>) ModBlocks.ACCELERATOR_16x.get();
|
AEBaseEntityBlock<CraftingBlockEntity> b16 = ModBlocks.ACCELERATOR_16x.get();
|
||||||
AEBaseEntityBlock<CraftingBlockEntity> b64 = (AEBaseEntityBlock<CraftingBlockEntity>) ModBlocks.ACCELERATOR_64x.get();
|
AEBaseEntityBlock<CraftingBlockEntity> b64 = ModBlocks.ACCELERATOR_64x.get();
|
||||||
AEBaseEntityBlock<CraftingBlockEntity> b256 = (AEBaseEntityBlock<CraftingBlockEntity>) ModBlocks.ACCELERATOR_256x.get();
|
AEBaseEntityBlock<CraftingBlockEntity> b256 = ModBlocks.ACCELERATOR_256x.get();
|
||||||
AEBaseEntityBlock<CraftingBlockEntity> b1024 = (AEBaseEntityBlock<CraftingBlockEntity>) ModBlocks.ACCELERATOR_1024x.get();
|
AEBaseEntityBlock<CraftingBlockEntity> b1024 = ModBlocks.ACCELERATOR_1024x.get();
|
||||||
|
|
||||||
// 使用我们自定义的 CraftingBlockEntity 类型,它的有效方块列表包含自定义加速器
|
// 使用我们自定义的 CraftingBlockEntity 类型,它的有效方块列表包含自定义加速器
|
||||||
var type = ModBlockEntities.EPLUS_CRAFTING_UNIT_BE.get();
|
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
|
@SubscribeEvent
|
||||||
public void onServerStarting(ServerStartingEvent event) {
|
public void onServerStarting(ServerStartingEvent event) {
|
||||||
// Do something when the server starts
|
|
||||||
LOGGER.info("HELLO from server starting");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.extendedae_plus.config;
|
package com.extendedae_plus.config;
|
||||||
|
|
||||||
|
import com.extendedae_plus.util.GetKey;
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
public final class ModConfig {
|
public final class ModConfig {
|
||||||
|
|
@ -39,14 +40,16 @@ public final class ModConfig {
|
||||||
.define("patternTerminalShowSlotsDefault", true);
|
.define("patternTerminalShowSlotsDefault", true);
|
||||||
|
|
||||||
OVERRIDE_AE2WT_PICKING = builder
|
OVERRIDE_AE2WT_PICKING = builder
|
||||||
.translation("config.extendedae_plus.override_ae2wt_picking")
|
.translation(new GetKey(GetKey.CONFIG)
|
||||||
|
.addStr("override_ae2wt_picking").buildRaw())
|
||||||
.comment("是否覆盖AE2WT使用中键从终端选取方块的逻辑",
|
.comment("是否覆盖AE2WT使用中键从终端选取方块的逻辑",
|
||||||
"开启后选取方块的数量将不被限制在32个",
|
"开启后选取方块的数量将不被限制在32个",
|
||||||
"(不建议使用,在EMI环境下可能出现奇怪bug)")
|
"(不建议使用,在EMI环境下可能出现奇怪bug)")
|
||||||
.define("overrideAE2WTPicking", false);
|
.define("overrideAE2WTPicking", false);
|
||||||
|
|
||||||
INDEPENDENT_UPLOADING_BUTTON = builder
|
INDEPENDENT_UPLOADING_BUTTON = builder
|
||||||
.translation("config.extendedae_plus.independent_uploading_button")
|
.translation(new GetKey(GetKey.CONFIG)
|
||||||
|
.addStr("independence_uploading_button").buildRaw())
|
||||||
.comment("启用后,在样板编码终端会出现一个独立的按钮用于上传样板")
|
.comment("启用后,在样板编码终端会出现一个独立的按钮用于上传样板")
|
||||||
.define("independentUploadingButton", false);
|
.define("independentUploadingButton", false);
|
||||||
|
|
||||||
|
|
@ -59,8 +62,7 @@ public final class ModConfig {
|
||||||
PROVIDER_ROUND_ROBIN_ENABLE = builder.comment(
|
PROVIDER_ROUND_ROBIN_ENABLE = builder.comment(
|
||||||
"智能倍增时是否对样板供应器轮询分配",
|
"智能倍增时是否对样板供应器轮询分配",
|
||||||
"仅多个供应器有相同样板时生效,开启后请求会均分到所有可用供应器,关闭则全部分配给单一供应器",
|
"仅多个供应器有相同样板时生效,开启后请求会均分到所有可用供应器,关闭则全部分配给单一供应器",
|
||||||
"注意:所有相关供应器需开启智能倍增,否则可能失效",
|
"注意:所有相关供应器需开启智能倍增,否则可能失效")
|
||||||
"默认: true")
|
|
||||||
.define("providerRoundRobinEnable", true);
|
.define("providerRoundRobinEnable", true);
|
||||||
|
|
||||||
// 智能倍增的最大倍数(以单次样板产出为单位)。
|
// 智能倍增的最大倍数(以单次样板产出为单位)。
|
||||||
|
|
|
||||||
81
src/main/java/com/extendedae_plus/util/GetKey.java
Normal file
81
src/main/java/com/extendedae_plus/util/GetKey.java
Normal file
|
|
@ -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<FluidType, ?> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user