I have created a simple entity class to figure out how to get it to work on a server but when running solely the client I am able to use the spawn egg no problem to spawn the entity, but when I try it on a server, nothing happens (no errors or entity constructor called). The egg is there it just doesn't work on the server.
TestMod:
@Mod(name = TestMod.NAME, modid = TestMod.MODID, version = TestMod.VERSION, acceptedMinecraftVersions = TestMod.ACCEPTED_MINECRAFT_VERSIONS)
public class TestMod {
public static final String NAME = "Test Mod";
public static final String MODID = "testmod";
public static final String VERSION = "1.0.0";
public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.11.2]";
public static final String PROXY_PATH = "com.testmod.proxy";
@Instance
public static TestMod instance;
@SidedProxy(clientSide = TestMod.PROXY_PATH + ".ClientProxy", serverSide = TestMod.PROXY_PATH + ".ServerProxy")
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit();
}
@EventHandler
public void init(FMLInitializationEvent event) {
proxy.init();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit();
}
}
Proxies:
public class CommonProxy {
public void preInit() {
NetworkHelper.registerMessages();
}
public void init() {
}
public void postInit() {
}
public EntityPlayer getPlayer(MessageContext ctx) {
return ctx.getServerHandler().playerEntity;
}
}
public class ServerProxy extends CommonProxy {
public void preInit() {
super.preInit();
NetworkHelper.registerMessages();
}
public void init() {
super.init();
}
public void postInit() {
super.postInit();
}
public EntityPlayer getPlayer(MessageContext ctx) {
return ctx.getServerHandler().playerEntity;
}
}
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
super.preInit();
}
@Override
public void init() {
super.init();
EntityHelper.registerEntities();
RenderingRegistry.registerEntityRenderingHandler(TestEntity.class, new RenderTestEntity(Minecraft.getMinecraft().getRenderManager()));
}
@Override
public void postInit() {
super.postInit();
}
@Override
public EntityPlayer getPlayer(MessageContext ctx) {
return ctx.side.isClient() ? Minecraft.getMinecraft().player : super.getPlayer(ctx);
}
}
EntityHelper:
public class EntityHelper {
private static int entityID = 3467;
public static void registerEntities() {
EntityHelper.register(TestEntity.class, "test_entity", 7951674, 7319108);
}
public static void renderEntities() {
RenderingRegistry.registerEntityRenderingHandler(TestEntity.class, new RenderTestEntity(Minecraft.getMinecraft().getRenderManager()));
}
private static void register(Class<? extends Entity> entityClass, String entityName, int eggColour, int spotColour) {
EntityRegistry.registerModEntity(new ResourceLocation("testmod:test_entity"), entityClass, entityName, entityID++, TestMod.instance, 128, 1, true, eggColour, spotColour);
}
}