Jump to content

[1.11] How do you render a throwable entity?


Recommended Posts

I'm trying to make a throwable item that renders like a snowball, but I haven't done any modding since 1.7.10 and have no idea what's going on now in 1.11.


I can't find any tutorials/github code with a render class for a throwable entity, only mobs, and can't find where the render class is actually referred, to register the vanilla snowball for example, in the base code.


So from what I've actually been able to find, and tell me if I'm wrong, but I believe this registers the entity:

EntityRegistry.registerModEntity(null, EntityBomb.class, "Bomb", Main.entityIds++, Main.instance, 64, 20, true);

But what is the resource location (where I have 'null', first parameter) supposed to be?


And then I think this is what the render class should be:

public class RenderItemBomb<T extends Entity> extends Render<T>

protected final Item item;
private final String texture;
public static RenderFactory factory;

public RenderItemBomb(RenderManager renderManagerIn)
	this.item = Registry.bomb;
	this.texture = "bomb";
	this.factory = new RenderFactory();

public static class RenderFactory implements IRenderFactory<EntityThrowable>

	public Render<? super EntityThrowable> createRenderFor(RenderManager manager)
		return new RenderItemBomb(manager);

public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
	GlStateManager.translate((float) x, (float) y, (float) z);
	GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
			(float) (this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX,
			1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);

	if (this.renderOutlines)

	/** (?) **/
	/** (?) **/
	this.itemRenderer.renderItem(this.getStackToRender(entity), ItemCameraTransforms.TransformType.GROUND);
	/** (?) **/
	/** (?) **/

	if (this.renderOutlines)

	super.doRender(entity, x, y, z, entityYaw, partialTicks);

public ItemStack getStackToRender(T entityIn)
	return new ItemStack(this.item);

protected ResourceLocation getEntityTexture(Entity entity)
	return new ResourceLocation(Main.MODID, texture);

But then that line in the middle I surrounded by question marks, where it grabs the item's renderer, how am I supposed to get that?

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.

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.