Jump to content

[1.11.2] Registered Entity Shows on Client but not Server


harison513

Recommended Posts

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);
	}
	
}

 

Link to comment
Share on other sites

Well duh it doesn't work on the server. Look where you put EntityHelper.registerEntities();

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Just now, Draco18s said:

Well duh it doesn't work on the server. Look where you put EntityHelper.registerEntities();

 

If I put it in the CommonProxy or anywhere else I get this crash when starting the server:

 

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/entity/Render for invalid side SERVER

 

public class CommonProxy {

	public void preInit() {
		NetworkHelper.registerMessages();
	}

	public void init() {
		EntityHelper.registerEntities(); // Error here
	}

	public void postInit() {
		
	}
	
	public EntityPlayer getPlayer(MessageContext ctx) {
		return ctx.getServerHandler().playerEntity;
	}

}

 

Link to comment
Share on other sites

Okay, I have removed the rendering for now and moved the entity registration to the CommonProxy init and I still get this error:

 

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/entity/Render for invalid side SERVER

 

Am I registering it wrong?

 

private static void register(Class<? extends Entity> entityClass, String entityName, int eggColour, int spotColour) {
	EntityRegistry.registerModEntity(new ResourceLocation("test_entity"), entityClass, entityName, entityID++, TestMod.instance, 128, 1, true, eggColour, spotColour);
}

 

public static void registerEntities() { // Which is called in the CommonProxy init
	EntityHelper.register(TestEntity.class, "test_entity", 0x000000, 0xffffff);
}

 

Link to comment
Share on other sites

2 hours ago, harison513 said:

Oh wait, now its gone... I'm confused.

Eclipse probably got around to cleaning up your imports so that the renderer class is no longer loaded.

 

If you really need that renderer, then you should still use it, but only call it from your client proxy. Don't mix it in with actions that must execute on the server. Your problem was where you chose to make the jump to the proxy, not the need for it. Get those initialization things sorted between common and client.

 

Why do you bother with an EntityHelper class? Are any of those methods ever called from more than one place? Can't you just put their guts into the proxies from which they're called?

 

PS: Put @Override annotations on all methods that are supposed to be overrides.

 

PPS:

private static int entityID = 3467;

 

Looks like bad form. I think you should allow the system to allocate your entity ID and return it to you. Forcing any static ID for anything is just asking for trouble. How old is the tutorial you're working from?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

On 3/21/2017 at 1:10 PM, diesieben07 said:

Imports have nothing to do with when classes get loaded. In fact imports do not even appear in the compiled class files.

You've said that before, but I know from experience that a left-behind import statement alone can cause a class loading error (at least when running in Eclipse's debugger).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

7 hours ago, jeffryfisher said:

You've said that before, but I know from experience that a left-behind import statement alone can cause a class loading error (at least when running in Eclipse's debugger).

Imports are syntactic sugar. They avoid you having to use fully qualified names.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin77 adalah bocoran slot rekomendasi gacor dari Ligawin77 yang bisa anda temukan di SLOT Ligawin77. Situs SLOT Ligawin77 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin77 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin77 merupakan SLOT Ligawin77 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin77. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin77 hari ini yang telah disediakan SLOT Ligawin77. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin77 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin77 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin77 di link SLOT Ligawin77.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Slot Aster88 adalah bocoran slot rekomendasi gacor dari Aster88 yang bisa anda temukan di SLOT Aster88. Situs SLOT Aster88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Aster88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Aster88 merupakan SLOT Aster88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Aster88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Aster88 hari ini yang telah disediakan SLOT Aster88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Aster88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Aster88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Aster88 di link SLOT Aster88.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.