Skip to content

Commit

Permalink
修改本模组 API 注册时间,使其在配置文件之后加载,便于配置文件管控
Browse files Browse the repository at this point in the history
- 修正一处 mixin 报错
  • Loading branch information
TartaricAcid committed Oct 3, 2024
1 parent 6796fab commit f30aaa1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package com.github.tartaricacid.touhoulittlemaid;

import com.github.tartaricacid.touhoulittlemaid.api.ILittleMaid;
import com.github.tartaricacid.touhoulittlemaid.block.multiblock.MultiBlockManager;
import com.github.tartaricacid.touhoulittlemaid.config.GeneralConfig;
import com.github.tartaricacid.touhoulittlemaid.config.ServerConfig;
import com.github.tartaricacid.touhoulittlemaid.entity.backpack.BackpackManager;
import com.github.tartaricacid.touhoulittlemaid.entity.chatbubble.ChatBubbleManger;
import com.github.tartaricacid.touhoulittlemaid.entity.task.TaskManager;
import com.github.tartaricacid.touhoulittlemaid.entity.task.meal.MaidMealManager;
import com.github.tartaricacid.touhoulittlemaid.init.*;
import com.github.tartaricacid.touhoulittlemaid.inventory.chest.ChestManager;
import com.github.tartaricacid.touhoulittlemaid.item.bauble.BaubleManager;
import com.github.tartaricacid.touhoulittlemaid.util.AnnotatedInstanceUtil;
import com.google.common.collect.Lists;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
Expand All @@ -35,7 +28,6 @@ public TouhouLittleMaid() {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, GeneralConfig.init());
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.init());
ChatBubbleManger.initDefaultChat();
modApiInit();
}

private static void initRegister(IEventBus eventBus) {
Expand All @@ -58,14 +50,4 @@ private static void initRegister(IEventBus eventBus) {
InitCommand.ARGUMENT_TYPE.register(eventBus);
InitPoi.POI_TYPES.register(eventBus);
}

private static void modApiInit() {
EXTENSIONS = AnnotatedInstanceUtil.getModExtensions();
TaskManager.init();
BackpackManager.init();
BaubleManager.init();
MultiBlockManager.init();
ChestManager.init();
MaidMealManager.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class BackpackManager {
private BackpackManager() {
EMPTY_BACKPACK = new EmptyBackpack();
BACKPACK_ID_MAP = Maps.newHashMap();
BACKPACK_ITEM_MAP = Maps.newHashMap();
}

public static void init() {
Expand All @@ -45,10 +46,7 @@ public static void init() {
littleMaid.addMaidBackpack(manager);
}
BACKPACK_ID_MAP = ImmutableMap.copyOf(BACKPACK_ID_MAP);
}

public static void initItemIndex() {
BACKPACK_ITEM_MAP = Maps.newHashMap();
// 将物品和背包绑定
BACKPACK_ID_MAP.forEach((id, backpack) -> BACKPACK_ITEM_MAP.put(backpack.getItem(), backpack));
BACKPACK_ITEM_MAP = ImmutableMap.copyOf(BACKPACK_ITEM_MAP);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.github.tartaricacid.touhoulittlemaid.init.registry;

import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid;
import com.github.tartaricacid.touhoulittlemaid.block.multiblock.MultiBlockManager;
import com.github.tartaricacid.touhoulittlemaid.entity.backpack.BackpackManager;
import com.github.tartaricacid.touhoulittlemaid.entity.info.ServerCustomPackLoader;
import com.github.tartaricacid.touhoulittlemaid.entity.task.TaskManager;
import com.github.tartaricacid.touhoulittlemaid.entity.task.meal.MaidMealManager;
import com.github.tartaricacid.touhoulittlemaid.inventory.chest.ChestManager;
import com.github.tartaricacid.touhoulittlemaid.item.bauble.BaubleManager;
import com.github.tartaricacid.touhoulittlemaid.network.NetworkHandler;
import com.github.tartaricacid.touhoulittlemaid.util.AnnotatedInstanceUtil;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
Expand All @@ -13,6 +20,16 @@ public final class CommonRegistry {
public static void onSetupEvent(FMLCommonSetupEvent event) {
event.enqueueWork(ServerCustomPackLoader::reloadPacks);
event.enqueueWork(NetworkHandler::init);
event.enqueueWork(BackpackManager::initItemIndex);
event.enqueueWork(CommonRegistry::modApiInit);
}

private static void modApiInit() {
TouhouLittleMaid.EXTENSIONS = AnnotatedInstanceUtil.getModExtensions();
TaskManager.init();
BackpackManager.init();
BaubleManager.init();
MultiBlockManager.init();
ChestManager.init();
MaidMealManager.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
@Mixin(FenceGateBlock.class)
public interface FenceGateBlockAccessor {
@Final
@Accessor("openSound")
@Accessor(value = "openSound", remap = false)
SoundEvent tlmOpenSound();

@Final
@Accessor("closeSound")
@Accessor(value = "closeSound", remap = false)
SoundEvent tlmCloseSound();
}

0 comments on commit f30aaa1

Please sign in to comment.