Jump to content

[1.8.9] Forge // Entity Spawn and Game Crash?!?


terraya
 Share

Recommended Posts

Hello Dear Forum,

 

i´ve got a small problem, the game start etc ... but after

i try to rightclick on the ground to spawn my new Entity, my whole minecraft screen goes blue and game crashes.

 

any ideas?

 

the Crash Report:

 

---- Minecraft Crash Report ----
// I blame Dinnerbone.

Time: 11.09.16 18:50
Description: Rendering entity in world

java.lang.NullPointerException: Rendering entity in world
at net.minecraft.client.renderer.entity.RendererLivingEntity.canRenderName(RendererLivingEntity.java:590)
at net.minecraft.client.renderer.entity.RenderLiving.canRenderName(RenderLiving.java:26)
at net.minecraft.client.renderer.entity.RenderLiving.canRenderName(RenderLiving.java:16)
at net.minecraft.client.renderer.entity.RendererLivingEntity.renderName(RendererLivingEntity.java:509)
at net.minecraft.client.renderer.entity.RendererLivingEntity.renderName(RendererLivingEntity.java:31)
at net.minecraft.client.renderer.entity.Render.doRender(Render.java:59)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:208)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:54)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:16)
at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:380)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:337)
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:304)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:672)
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1369)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1283)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1111)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107)
at net.minecraft.client.Minecraft.run(Minecraft.java:380)
at net.minecraft.client.main.Main.main(Main.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

 

 

package ArturFarid.BlockUpdate.entity;

import net.minecraft.entity.monster.EntityMob;
import net.minecraft.world.World;

public class EntityModelTest extends EntityMob{

public EntityModelTest(World worldIn) {
	super(worldIn);
}

}

 

package ArturFarid.BlockUpdate.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;

public class ModelTest extends ModelBase
{
  //fields
    ModelRenderer leg2;
    ModelRenderer leg1;
    ModelRenderer body;
    ModelRenderer head;
  
  public ModelTest()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      leg2 = new ModelRenderer(this, 10, 14);
      leg2.addBox(-1F, 0F, -3F, 3, 15, 3);
      leg2.setRotationPoint(4F, 9F, 1F);
      leg2.setTextureSize(64, 32);
      leg2.mirror = true;
      setRotation(leg2, 0F, 0F, 0F);
      leg1 = new ModelRenderer(this, 52, 10);
      leg1.addBox(-2F, 0F, -3F, 3, 15, 3);
      leg1.setRotationPoint(-5F, 9F, 1F);
      leg1.setTextureSize(64, 32);
      leg1.mirror = true;
      setRotation(leg1, 0F, 0F, 0F);
      body = new ModelRenderer(this, 0, 0);
      body.addBox(0F, 0F, 0F, 17, 20, ;
      body.setRotationPoint(-9F, -11F, -5F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      head = new ModelRenderer(this, 41, 0);
      head.addBox(-4F, -5F, -2F, 8, 5, 4);
      head.setRotationPoint(-1F, -11F, -2F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    leg2.render(f5);
    leg1.render(f5);
    body.render(f5);
    head.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    this.leg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.leg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    this.leg1.rotateAngleY = 0.0F;
    this.leg2.rotateAngleY = 0.0F;
  }

}

 

and the render

 

package ArturFarid.BlockUpdate.Render;

import ArturFarid.BlockUpdate.model.ModelTest;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

public class RenderModelTest extends RenderLiving{

public RenderModelTest() {
	super(Minecraft.getMinecraft().getRenderManager(), new ModelTest(), 0);

}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	return new ResourceLocation("blockupdate", "textures/entity/ModelTest.png");
}

}

Link to comment
Share on other sites

package ArturFarid.BlockUpdate.Util;

import ArturFarid.BlockUpdate.BlocksUpdate;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class EntityCreator {

public static final void CreateEntity(Class entityClass, Render render, String entityName, EnumCreatureType type, int probability, int minSpawn, int maxSpawn, BiomeGenBase[] biomes, int solidColor, int spotColor, boolean hasSpawnEgg) {
	int id = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
	EntityRegistry.registerModEntity(entityClass, entityName, id, BlocksUpdate.instance, 64, 1, true);
	EntityRegistry.addSpawn(entityName, probability, minSpawn, maxSpawn, type, biomes);
	RenderingRegistry.registerEntityRenderingHandler(entityClass, render);

	if(hasSpawnEgg){
		EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, solidColor, spotColor));
	}
}
}

 

 

 

 

and

 

 

		EntityCreator.CreateEntity(EntityModelTest.class, new RenderModelTest(), "ModelTest", EnumCreatureType.MONSTER, 5, 0, 10, new BiomeGenBase[]{}, 0xFF0FB, 0xD69D00, true);

Link to comment
Share on other sites

  • Do not use
    registerGlobalEntityID

    .

  • Do not insert stuff into
    EntityList.entityEggs

    (or any other field inside

    EntityList

    ) directly. If you want spawn eggs, use the version of

    registerModEntity

    that takes color parameters.

  • You must call registerEntityRenderingHandler from your client proxy or you will crash servers.

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
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.

 Share



×
×
  • Create New...

Important Information

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