Jump to content

[1.11] Changes on how to register entities?


American2050

Recommended Posts

So, I was checking a mod I had on 1.10.2 and I noticed that something changed on how the entities are registered I assume...

 

The code shows no errors, but the entity spawn is the world as "unknown" and it doesn't render.

 

I can hear it, and it's breaking blocks, I even see the Boss Bar, but I don't see the entity itself.

 

Any clues on what I should look for?

Link to comment
Share on other sites

So, I was checking a mod I had on 1.10.2 and I noticed that something changed on how the entities are registered I assume...

 

The code shows no errors, but the entity spawn is the world as "unknown" and it doesn't render.

 

I can hear it, and it's breaking blocks, I even see the Boss Bar, but I don't see the entity itself.

 

Any clues on what I should look for?

Post code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

This is what I'm doing:

 

public class ModEntities {


public static void init(){

	createEntity(MyDragon.class, 1513, "my_dragon", 161425, 1582224);

}


public static void createEntity(Class entityClass, int ID, String entityName, int solidColor, int spotColor){

	EntityRegistry.registerModEntity(entityClass, entityName, ID, IrishLuck.instance, 128, 1, true);
//		EntityRegistry.registerEgg(entityClass, solidColor, spotColor);

}

}

 

That gets called on preInit

 

And the render on the client proxy gets called on init and it is

 

		RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
                
        renderManager.entityRenderMap.put(MyDragon.class, new RenderMyDragon(renderManager));

Link to comment
Share on other sites

Use

RenderingRegistry.registerEntityRenderingHandler

in preInit from your client proxy to register renderers. Make sure to use the version that is not deprecated.

Thanks. I will start fresh from scratch tomorrow to see what I'm messing here. I tried:

 

        RenderingRegistry.registerEntityRenderingHandler(MyDragon.class, new IRenderFactory<MyDragon>() 
	{
		@Override
		public Render<? super MyDragon> createRenderFor(RenderManager manager) 
		{
			return new RenderMyDragon(manager);
		}
	});

 

And still same problem. For sure I have to implement or extend something new that I'm missing, not sure.

Link to comment
Share on other sites

Yeah man I just went to build a snowball and it didn't work.

 

I set up everything according to 1.11 changes

 

entitythrowable --- >entityorb

entitysnowball --- > entitysphere extends entityorb

itemsnowball----> itemsphere

 

I just transfered it over and my entity was invisible, it did however fly and made impact, and I was able to adjust stack size and situate the tab and such. Item with custom json and texture visible both in hand and on ground.

entity can't be found when searching for it in the chat either.

 

I'll just chill for a minute til this is groovy.

Link to comment
Share on other sites

Entity Registration has changed A LOT in 1.11.

I am currently trying to decide how to best address it in Forge.

 

please keep this going, whatever happens. I don't like the jerky entities :[ , Like I can kinda see what they are getting at, but making all the thrown entities derpy would really suck, and doesn't work for projectiles.

EntityRegistry.registerModEntity(128, 214, true);

Link to comment
Share on other sites

So I can see one of the Forge updates works on fixing the entities registration.

 

I now have a problem when trying to use this method on the render registry:

 

        RenderingRegistry.registerEntityRenderingHandler(MyDragon.class, new IRenderFactory<MyDragon>() 
	{
		@Override
		public Render<? super MyDragon> createRenderFor(RenderManager manager) 
		{
			return new RenderMyDragon(manager);
		}
	});

 

I just get a white box, however when I use the one I'm using on 1.10.2 it renders ok

 

RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
	renderManager.entityRenderMap.put(MyDragon.class, new RenderMyDragon(renderManager));

 

I'm sure the problem is that when I make the Render implement the IRenderFactory I'm not doing this part correctly:

 

	@Override
public Render createRenderFor(RenderManager manager) {
	// TODO Auto-generated method stub
	return this;
}

 

What should I return on that method?

 

Link to comment
Share on other sites

Don't implement

IRenderFactory

on your Renderer.

The easiest way is to have a constructor in your Renderer class that has a

RenderManager

parameter and then use a constructor reference to implement

IRenderFactory

:

 

registerEntityRenderingHandler(MyEntity.class, MyRenderer::new)

 

Any word on items used for spawning things? i.e. eggs, thrownstuff, spawneggs, etc.

Or are the entities only spawnable through world generation (so far)?

 

I see waddles and betterthanbunnies have updated to 1.11. Figured I'd touch base again, since its been a minute.

Link to comment
Share on other sites

What about them?

 

Is it a possibility to register one and throw one now (without the entity being invisible?) Or no....?

 

I've been sitting here looking at my several variations of no error showing code, going "why doesn't this work" Then tearing it down and rebuilding the whole thing again, just to do the same thing. (I've been doing so for 3 days now)

Link to comment
Share on other sites

  • 4 months later...

Hey! I know this is old, but it looks like you never got help and I think all you needed was a colon in this line,

private static final ResourceLocation DREK_TEXTURES = new ResourceLocation(References.MOD_ID, "textures/entity/entitydrek.png");

 

You needed it before textures, so it should look like ":textures/entity/entitydrek.png"

Link to comment
Share on other sites

11 minutes ago, SirJoseph said:

Hey! I know this is old, but it looks like you never got help and I think all you needed was a colon in this line,

private static final ResourceLocation DREK_TEXTURES = new ResourceLocation(References.MOD_ID, "textures/entity/entitydrek.png");

 

You needed it before textures, so it should look like ":textures/entity/entitydrek.png"

Incorrect. ResourceLocation splits the 2 parameters into domain & path. Manually adding a colon is never necessary unless you use the single parameter constructor, which calls ResourceLocation#splitObjectName, and places each part into the mentioned domain & path.
The way you showed, with an added colon in the path, will become "domain::path".

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

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.



×
×
  • Create New...

Important Information

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