Jump to content

[1.7.10] [Not Resolved] Entity Rendering Not Working.


Awesome_Spider

Recommended Posts

So I've made an entity, but the problem is when I spawn it with a spawn egg it doesn't render. Here is my code:

 

 

 

Entity:

public class ArcanePowerMatrix 
			extends EntityLiving{



public ArcanePowerMatrix(World world) {
	super(world);
}

@Override
protected void entityInit() {

}

@Override
public void readEntityFromNBT(NBTTagCompound tags) {

}

@Override
public void writeEntityToNBT(NBTTagCompound tags) {

}
}

Model:

public class ModelPowerMatrix extends ModelBase{
  //fields
    ModelRenderer Base;
    ModelRenderer MainCube;
    ModelRenderer littleCube;
    ModelRenderer littleCube2;
    ModelRenderer littleCube3;
    ModelRenderer littleCube4;
  
  public ModelPowerMatrix()
  {
    textureWidth = 128;
    textureHeight = 64;
    
      Base = new ModelRenderer(this, 0, 32);
      Base.addBox(-5F, 0F, -5F, 10, 1, 10);
      Base.setRotationPoint(0F, 23F, 0F);
      Base.setTextureSize(64, 32);
      Base.mirror = true;
      setRotation(Base, 0F, 0F, 0F);
      MainCube = new ModelRenderer(this, 0, 0);
      MainCube.addBox(-6F, -6F, -6F, 12, 12, 12);
      MainCube.setRotationPoint(0F, 11F, 0F);
      MainCube.setTextureSize(64, 32);
      MainCube.mirror = true;
      setRotation(MainCube, -0.7853982F, 0F, -0.7853982F);
      littleCube = new ModelRenderer(this, 50, 0);
      littleCube.addBox(-2F, -2F, -2F, 4, 4, 4);
      littleCube.setRotationPoint(5.5F, 5.5F, -11.5F);
      littleCube.setTextureSize(64, 32);
      littleCube.mirror = true;
      setRotation(littleCube, -0.7853982F, 0F, -0.7853982F);
      littleCube2 = new ModelRenderer(this, 50, 0);
      littleCube2.addBox(-2F, -2F, -2F, 4, 4, 4);
      littleCube2.setRotationPoint(5.5F, 5.5F, 11.5F);
      littleCube2.setTextureSize(64, 32);
      littleCube2.mirror = true;
      setRotation(littleCube2, -0.7853982F, 0F, -0.7853982F);
      littleCube3 = new ModelRenderer(this, 50, 0);
      littleCube3.addBox(-2F, -2F, -2F, 4, 4, 4);
      littleCube3.setRotationPoint(-2F, -3F, 0F);
      littleCube3.setTextureSize(64, 32);
      littleCube3.mirror = true;
      setRotation(littleCube3, -0.7853982F, 0F, -0.7853982F);
      littleCube4 = new ModelRenderer(this, 50, 0);
      littleCube4.addBox(-2F, -2F, -2F, 4, 4, 4);
      littleCube4.setRotationPoint(14F, 13F, 0F);
      littleCube4.setTextureSize(64, 32);
      littleCube4.mirror = true;
      setRotation(littleCube4, -0.7853982F, 0F, -0.7853982F);
  }
  
  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);
    Base.render(f5);
    MainCube.render(f5);
    littleCube.render(f5);
    littleCube2.render(f5);
    littleCube3.render(f5);
    littleCube4.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);
  }
}

Renderer:

@SideOnly(Side.CLIENT)
public class RenderPowerMatrix
			extends RenderLiving{

public RenderPowerMatrix(ModelBase modelBase, float shadowSize) {
	super(modelBase, shadowSize);
}

@Override
protected ResourceLocation getEntityTexture(Entity var1) {
	return new ResourceLocation("wizardry", "/textures/entities/PowerMatrix.png");
}
}

My entity is registered like this:

registerEntity(ArcanePowerMatrix.class, "powerMatrix", 000, 000);

 

registerEntity is like this:

public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
    	int id = EntityRegistry.findGlobalUniqueEntityId();
    	EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
    	EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, bkEggColor, fgEggColor));
    }

 

In ClientProxy my renderer is registered like this:

RenderingRegistry.registerEntityRenderingHandler(ArcanePowerMatrix.class, new RenderPowerMatrix(new ModelPowerMatrix(), 0F));

 

 

Link to comment
Share on other sites

Are you calling the method which holds

RenderingRegistry.registerEntityRenderingHandler(ArcanePowerMatrix.class, new RenderPowerMatrix(new ModelPowerMatrix(), 0F));

in your main class?

 

No, I'm calling it in my ClientProxy.

 

Oh sorry, I was tired when I read that, yes I'm calling that method in my main class (not ClientProxy, that wouldn't have worked, sorry for the miss-understanding).

Link to comment
Share on other sites

Add an println to the onUpdate method to make sure it is spawning right (make sure to call super!). Can we see spawning code?

 

What onUpdate method? I try to add that. Also I don't have spawning code, I just register the entity and it does that on it's own.

 

Well... I guess some people are as stumped as me. :/

 

Does the game crash when you try (Post Error)? Or does it just not render at all?

 

It just doesn't render at all, either that or it doesn't spawn.

Link to comment
Share on other sites

Now that I look at it, it gives me this in the console when I use the spawn egg:

[17:26:14] [server thread/WARN]: Skipping Entity with id 7
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.reflect.InvocationTargetException
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.entity.EntityList.createEntityByID(EntityList.java:221)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.item.ItemMonsterPlacer.spawnCreature(ItemMonsterPlacer.java:173)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.item.ItemMonsterPlacer.onItemUse(ItemMonsterPlacer.java:79)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:456)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:142)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:422)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NullPointerException
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.entity.DataWatcher.updateObject(DataWatcher.java:153)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.entity.EntityLivingBase.setHealth(EntityLivingBase.java:812)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:157)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at com.awsp8.wizardry.Entities.ArcanePowerMatrix.<init>(ArcanePowerMatrix.java:13)
[17:26:19] [server thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	... 20 more

 

Weird a NullPointerException at the end, easy to fix. But it says it can't find the health info, even EASIER to fix :) well i'll try to fix it then. If I don't i'll reply again.

Link to comment
Share on other sites

The onUpdate method is called each tick (look at Entity class). The println was to check it was spawning correctly, you might want to make it print (this.worldObj.isRemote + ", " + this) to see the entity and which world it is in. Give us what that outputs and updated code when you implement it.

Link to comment
Share on other sites

The onUpdate method is called each tick (look at Entity class). The println was to check it was spawning correctly, you might want to make it print (this.worldObj.isRemote + ", " + this) to see the entity and which world it is in. Give us what that outputs and updated code when you implement it.

 

I place this code (this is how I debug):

Wizardry.log.debug(this.worldObj.isRemote + ", " + this);

 

where you advised me to put it and it printed absolutely nothing when I spawned the entity. Thoughts? :)

Link to comment
Share on other sites

Well here is the updated code:

 

package com.awsp8.wizardry.Entities;

import com.awsp8.wizardry.Wizardry;

import sun.misc.SharedSecrets;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class ArcanePowerMatrix 
			extends EntityLiving{



public ArcanePowerMatrix(World world) {
	super(world);
}

@Override
public void entityInit(){
	super.entityInit();
}

@Override
public void onUpdate(){
	super.onUpdate();

	Wizardry.log.debug(this.worldObj.isRemote + ", " + this);
}

@Override
public void applyEntityAttributes(){
        super.applyEntityAttributes();
    }

@Override
public boolean canDespawn(){
	return false;
}

@Override
public boolean canBePushed(){
	return false;
}
}

 

And I have noticed that the exception is gone, but it still doesn't spawn. Now I'm actually not sure now whether it's a rendering problem or a spawning problem (considering it doesn't print anything).

Link to comment
Share on other sites

I use this method to create a spawn egg for it:

public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
    	int id = EntityRegistry.findGlobalUniqueEntityId();
    	EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
    	EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, bkEggColor, fgEggColor));
    }

 

But I don't understand why it's not working because all my other entities spawn ok, but this one doesn't spawn. I have no idea why, they are all registered the same way.

Link to comment
Share on other sites

Then I have no clue. Setup a proper git repo so that I can easily check out your code. No, a zip download does not work.

 

I have a git repos:

 

My entity code:

https://github.com/AwesomeSpider/Wizardry/blob/master/src/main/java/com/awsp8/wizardry/Entities/ArcanePowerMatrix.java

 

My entity model code:

 

https://github.com/AwesomeSpider/Wizardry/blob/master/src/main/java/com/awsp8/wizardry/entity/model/ModelPowerMatrix.java

 

My entity rendering code:

 

https://github.com/AwesomeSpider/Wizardry/blob/master/src/main/java/com/awsp8/wizardry/entity/render/RenderPowerMatrix.java

 

Hope you can help, if not it's fine I can always remove the entity. :)

Link to comment
Share on other sites

well, that would at least make

setDead

be called on the entity, but that is not the case either. it just seems as if the entity instance just vanishes.

 

Weird... I just remembered this has happened to me before with another entity. If I'm remembering correctly I couldn't fix it and ended up having to delete the entity. I had no idea what caused it, this is REALLY weird. I'll do more research, wish me luck. :)

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.