Jump to content

Recommended Posts

Posted

I'm working on a spell-casting mob and was thinking I would be clever and just create a fake spell entity within the mob's render class, and render that as appropriate, since I don't actually want to spawn the spell into the world just yet.

 

Anyway, Minecraft doesn't seem to like that so much:

 

java.lang.NullPointerException: Rendering entity in world
at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:62)
at net.minecraft.client.renderer.entity.Render.bindEntityTexture(Render.java:57)
at zeldaswordskills.client.render.entity.RenderEntityMagicSpell.doRender(RenderEntityMagicSpell.java:55)
at zeldaswordskills.client.render.entity.RenderEntityWizzrobe.doRender(RenderEntityWizzrobe.java:56)
at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:278)
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:251)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:533)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1308)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1095)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067)
at net.minecraft.client.Minecraft.run(Minecraft.java:961)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:65)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:62)
at net.minecraft.client.renderer.entity.Render.bindEntityTexture(Render.java:57)
at zeldaswordskills.client.render.entity.RenderEntityMagicSpell.doRender(RenderEntityMagicSpell.java:55)
at zeldaswordskills.client.render.entity.RenderEntityWizzrobe.doRender(RenderEntityWizzrobe.java:56)

-- Entity being rendered --
Details:
Entity Type: zeldaswordskills.wizzrobe (zeldaswordskills.entity.mobs.EntityWizzrobe)
Entity ID: 70
Entity Name: entity.zeldaswordskills.wizzrobe.name
Entity's Exact location: -104.53, 83.00, 174.50
Entity's Block location: World: (-105,83,174), Chunk: (at 7,5,14 in -7,10; contains blocks -112,0,160 to -97,255,175), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Entity's Momentum: 0.00, -0.08, 0.00

-- Renderer details --
Details:
Assigned renderer: zeldaswordskills.client.render.entity.RenderEntityWizzrobe@b9902f7
Location: 5.56,-3.62,1.74 - World: (5,-4,1), Chunk: (at 5,-1,1 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Rotation: 88.59375
Delta: 0.1744988
Stacktrace:
at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:278)
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:251)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:533)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1308)

 

 

Here is what I tried in the mob's render class:

 

@SideOnly(Side.CLIENT)
public class RenderEntityWizzrobe extends RenderLiving
{
private static final ResourceLocation fireWizzrobeTexture = new ResourceLocation("textures/entity/zombie.png");

private final EntityMagicSpell spell;
private final RenderEntityMagicSpell spellRenderer;

/** Wizzrobe model provides easy means of knowing if spell should be rendered */
private final ModelWizzrobe model;

public RenderEntityWizzrobe(ModelWizzrobe model) {
	super(model, 0.5F);
	this.model = model;
	this.spell = new EntityMagicSpell(Minecraft.getMinecraft().theWorld);
	this.spell.ticksExisted = 0;
	this.spellRenderer = new RenderEntityMagicSpell();
}

@Override
public void doRender(Entity entity, double dx, double dy, double dz, float yaw, float partialTick) {
	super.doRender(entity, dx, dy, dz, yaw, partialTick);
	if (model.atPeak) { // spell should render
		spell.setType(MagicType.WIND);
		++spell.ticksExisted;
		spellRenderer.doRender(spell, dx, dy, dz, yaw, partialTick); // NULL pointer thrown from here, pointing to bindEntityTexture
	} else {
		spell.ticksExisted = 0;
	}
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	return fireWizzrobeTexture; // TODO
}
}

 

 

Here is the RenderEntityMagicSpell class - works fine for real spell entities rendering in the world:

 

@SideOnly(Side.CLIENT)
public class RenderEntityMagicSpell extends Render
{
private final ModelCube box1 = new ModelCube(4);
private final ModelCube box2 = new ModelCube(4);

public RenderEntityMagicSpell() {}

@Override
public void doRender(Entity entity, double dx, double dy, double dz, float yaw, float partialTick) {
	GL11.glPushMatrix();
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
	GL11.glTranslated(dx, dy, dz);
	GL11.glRotatef(yaw, 0, 1, 0);
	float roll = ((float) entity.ticksExisted + partialTick) * 40;
	while (roll > 360) roll -= 360;
	GL11.glRotatef(roll, 0.8F, 0F, -0.6F);
	bindEntityTexture(entity);
	Tessellator.instance.setBrightness(0xf000f0);
	box1.render(entity);
	GL11.glRotatef(45, 1, 0, 1);
	box2.render(entity);
	GL11.glDisable(GL12.GL_RESCALE_NORMAL);
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glPopMatrix();
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	return ((EntityMagicSpell) entity).getType().getEntityTexture();
}
}

 

 

Clearly the problem is that Render#bindEntityTexture is not able to get the correct texture, but after going through the stack trace and trying to trace the method calls, I still cannot fathom why.

 

Does anyone have experience doing something like this?

Posted

Hi

 

I don't have experience doing this, but at the risk of stating the obvious I assume that in net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:62), either renderManager or renderEngine is null?

 

        this.renderManager.renderEngine.bindTexture(p_110776_1_);

 

If you can figure out why that is, you'd be a lot closer..?

 

-TGG

 

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



×
×
  • Create New...

Important Information

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