Насколько я могу судить, я не могу понять, почему этот код работает нормально в клиентской программе запуска, но как только вы попытаетесь зарегистрировать сущности, сервер взломает дерьмо.
Вот код, я только что потерян, я также попробовал другой способ регистрации, но он тоже ничего не сделал.
package com.muddykat.grimoire.entity;
import com.muddykat.grimoire.entity.mob.EntityImp;
import com.muddykat.grimoire.entity.mob.EntityProwler;
import com.muddykat.grimoire.lib.GrimoireLib;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@Mod.EventBusSubscriber
public class EntityReg {
private EntityReg() {
}
public static void preInit() {
//registerEntity(EntityImp.class, "demon_imp", 0x660000, 0xB8AB8D);
//registerEntity(EntityProwler.class, "demon_prowler", 0x660000, 0xB8AB8D);
}
private static int id = 0;
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityEntry> event) {
EntityEntry imp = EntityEntryBuilder.create()
.entity(EntityImp.class)
.id(new ResourceLocation(GrimoireLib.MODID + ":demon_imp"), id++)
.name("grimoire.demon_imp")
.egg(0x660000, 0xB8AB8D)
.tracker(64, 3, true)
.build();
event.getRegistry().register(imp);
EntityEntry prowler = EntityEntryBuilder.create()
.entity(EntityProwler.class)
.id(new ResourceLocation(GrimoireLib.MODID + ":demon_prowler"), id++)
.name("grimoire.demon_prowler")
.egg(0x660000, 0xB8AB8D)
.tracker(64, 3, true)
.build();
event.getRegistry().register(prowler);
}
}
вот журнал сбоев
---- Minecraft Crash Report ----
// This doesn't make any sense!
Time: 12/17/18 6:49 PM
Description: Exception in server tick loop
java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at net.minecraftforge.fml.relauncher.ReflectionHelper.findConstructor(ReflectionHelper.java:255)
at net.minecraftforge.fml.common.registry.EntityEntryBuilder$ConstructorFactory.<init>(EntityEntryBuilder.java:298)
at net.minecraftforge.fml.common.registry.EntityEntryBuilder$1.<init>(EntityEntryBuilder.java:266)
at net.minecraftforge.fml.common.registry.EntityEntryBuilder.build(EntityEntryBuilder.java:266)
at com.muddykat.grimoire.entity.EntityReg.registerEntities(EntityReg.java:37)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_EntityReg_registerEntities_Register.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:789)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:99)
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333)
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.multiplayer.WorldClient
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@14f3c6fc from coremod FMLCorePlugin
at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:260)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176)
... 22 more
Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/multiplayer/WorldClient for invalid side SERVER
at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:62)
at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:256)
... 24 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.12.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_181, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 879695752 bytes (838 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.42 Powered by Forge 14.23.5.2768 6 mods loaded, 6 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
| State | ID | Version | Source | Signature |
|:----- |:--------- |:------------ |:-------------------------------- |:--------- |
| UCH | minecraft | 1.12.2 | minecraft.jar | None |
| UCH | mcp | 9.42 | minecraft.jar | None |
| UCH | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2768.jar | None |
| UCH | forge | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None |
| UCH | grimoire | 1.0 | bin | None |
| UCH | jei | 4.13.1.225 | jei_1.12.2-4.13.1.225.jar | None |
Loaded coremods (and transformers):
Profiler Position: N/A (disabled)
Is Modded: Definitely; Server brand changed to 'fml,forge'
Type: Dedicated Server (map_server.txt)