59 lines
2.4 KiB
Java
59 lines
2.4 KiB
Java
package com.mingliqiye.minecraft.enchantment.conflict;
|
|
|
|
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
|
|
import com.mingliqiye.minecraft.enchantment.conflict.network.ChannelHander;
|
|
import com.mingliqiye.minecraft.enchantment.conflict.network.message.ConfigMessage;
|
|
import com.mojang.logging.LogUtils;
|
|
import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.ModContainer;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
import org.slf4j.Logger;
|
|
|
|
/**
|
|
* 有没有大佬能够修复该版本的问题<br/>
|
|
* 开发环境可以运行 生产环境报错映射出错 FriendlyByteBuf::writeUtf(String s,int i)
|
|
* @see ConfigMessage
|
|
* @see FriendlyByteBuf
|
|
* @deprecated
|
|
*/
|
|
@Mod(EnchantmentDoNotConflictForge.MODID)
|
|
public class EnchantmentDoNotConflictForge {
|
|
public static final String MODID = "enchantmentdoesnotconflict";
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
|
|
public EnchantmentDoNotConflictForge(IEventBus modEventBus, ModContainer container) {
|
|
container.addConfig(
|
|
new net.minecraftforge.fml.config.ModConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON,
|
|
ModConfig.SPEC, container));
|
|
modEventBus.addListener(this::commonSetup);
|
|
MinecraftForge.EVENT_BUS.addListener(this::onPlayerLogin);
|
|
}
|
|
|
|
public EnchantmentDoNotConflictForge(FMLJavaModLoadingContext context) {
|
|
this(context.getModEventBus(), context.getContainer());
|
|
}
|
|
|
|
public void commonSetup(FMLCommonSetupEvent event) {
|
|
event.enqueueWork(() -> {
|
|
ChannelHander.register();
|
|
ModConfig.load();
|
|
LOGGER.info("Network channel registered successfully");
|
|
});
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
|
if (event.getEntity() instanceof ServerPlayer player) {
|
|
ChannelHander.sendConfig(player);
|
|
LOGGER.debug("Sent config to player: {}", player.getName().getString());
|
|
}
|
|
}
|
|
}
|