Jump to content

[1.7.10] Help Understanding This Error


PhantomTiger

Recommended Posts

Hi,

I am having trouble trying to understand where the error is happening within my code, the game crashes when I right click my custom painting item on a surface, I'm guessing something is going wrong with the spawning of the entity. Thanks for any help!

 

The Error:

 

---- Minecraft Crash Report ----

// Don't be sad, have a hug! <3

 

Time: 8/18/15 3:48 PM

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at com.tiger.entitiy.PapPapEntity.getWidthPixels(PapPapEntity.java:134)

at net.minecraft.entity.EntityHanging.setDirection(EntityHanging.java:43)

at net.minecraft.entity.item.EntityPainting.<init>(EntityPainting.java:35)

at com.tiger.entitiy.PapPapEntity.<init>(PapPapEntity.java:69)

at com.tiger.entitiy.PapPapHanging.createHangingEntity(PapPapHanging.java:57)

at com.tiger.entitiy.PapPapHanging.onItemUse(PapPapHanging.java:34)

at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:143)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:403)

at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1518)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2033)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028)

at net.minecraft.client.Minecraft.run(Minecraft.java:951)

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:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

 

 

 

My Entity class

public class PapPapEntity extends EntityPainting{

public PapPapEnum fielda;

public static enum PapPapEnum{
       AlphA("AlphA", 16, 16, 0, 0),
	AlphB("AlphB", 16, 16, 16, 0),
	AlphC("AlphC", 16, 16, 32, 0),
	AlphD("AlphD", 16, 16, 48, 0),
	AlphE("AlphE", 16, 16, 64, 0),
                Ankh("Ankh", 16, 16, 80, 0),
                Udjat("Udjat", 16, 16, 96, 0),
                Pool("Pool", 32, 16, 0, 32),
               Courbet("Courbet", 32, 16, 32, 32),
               Sea("Sea", 32, 16, 64, 32),
               Sunset("Sunset", 32, 16, 96, 32),
               Creebet("Creebet", 32, 16, 128, 32),
               Wanderer("Wanderer", 16, 32, 0, 64),
               Graham("Graham", 16, 32, 16, 64),
               Match("Match", 32, 32, 0, 128),
               Bust("Bust", 32, 32, 32, 128),
               Stage("Stage", 32, 32, 64, 128),
               Void("Void", 32, 32, 96, 128),
               SkullAndRoses("SkullAndRoses", 32, 32, 128, 128),
               Wither("Wither", 32, 32, 160, 128),
               Fighters("Fighters", 64, 32, 0, 96),
               Pointer("Pointer", 64, 64, 0, 192),
               Pigscene("Pigscene", 64, 64, 64, 192),
               BurningSkull("BurningSkull", 64, 64, 128, 192),
               Skeleton("Skeleton", 64, 48, 192, 64),
               DonkeyKong("DonkeyKong", 64, 48, 192, 112);


             public static final int maxArtTitleLength = "SkullAndRoses".length();
             public final String title;
             public final int sizeX;
             public final int sizeY;
             public final int offsetX;
             public final int offsetY;
        
            private PapPapEnum(String strin2, int int9, int int10, int int11, int int12){
                 this.title = strin2;
                 this.sizeX = int9;
                 this.sizeY = int10;
                 this.offsetX = int11;
                 this.offsetY = int12;
        }
}

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

public PapPapEntity(World world, int int1, int int2, int int3, int int4) {
	super(world, int1, int2, int3, int4);
	ArrayList arraylist = new ArrayList();
    PapPapEnum[] aenumart = PapPapEnum.values();
    int i1 = aenumart.length;

    for (int j1 = 0; j1 < i1; ++j1){
    	PapPapEnum enumart = aenumart[j1];
        this.fielda = enumart;
        this.setDirection(int4);

        if (this.onValidSurface()){
        	arraylist.add(enumart);
        }
    }

    if (!arraylist.isEmpty()){
    	this.fielda = (PapPapEnum)arraylist.get(this.rand.nextInt(arraylist.size()));
    }

    this.setDirection(int4);
}
@SideOnly(Side.CLIENT)
    public PapPapEntity(World world, int int5, int int6, int int7, int int8, String strin1){
        super(world, int5, int6, int7, int8);
        PapPapEnum[] aenumart = PapPapEnum.values();
        int i1 = aenumart.length;
        int i2 = 0;
        while (i2<i1){
        	PapPapEnum enumart = aenumart[i2];
        	if (enumart.title.equals(strin1)){
        		this.fielda = enumart;
        		break;
        	}
        	i2++;
        }
        this.setDirection(int8);
    }

    public void writeEntityToNBT(NBTTagCompound tagzcom) {
        tagzcom.setString("Motive", this.fielda.title);
        super.writeEntityToNBT(tagzcom);
    }


    public void readEntityFromNBT(NBTTagCompound tagzcom){
        String s = tagzcom.getString("Motive");
        PapPapEnum[] aenumart = PapPapEnum.values();
        int i = aenumart.length;

        for (int j = 0; j < i; ++j){
            PapPapEnum enumart = aenumart[j];

            if (enumart.title.equals(s)){
                this.fielda = enumart;
            }
        }

        if (this.fielda == null){
            this.fielda = PapPapEnum.AlphA;
        }

        super.readEntityFromNBT(tagzcom);
    }

    public int getWidthPixels(){
        return this.fielda.sizeX;
    }

    public int getHeightPixels(){
        return this.fielda.sizeY;
    }
public void onBroken(Entity entit){
        if (entit instanceof EntityPlayer){
            EntityPlayer entityplayer = (EntityPlayer)entit;

            if (entityplayer.capabilities.isCreativeMode){
                return;
            }
        }

        this.entityDropItem(new ItemStack(TigerItems.PapPap), 0.0F);
    }


}

 

My Entity Rendering Class

@SideOnly(Side.CLIENT)
public class PapPapRender extends Render{

    private static final ResourceLocation local = new ResourceLocation(RefStrings.MODID, "textures/painting/egypt.png");


    public void doRender(PapPapEntity entity, double douba, double doubb, double doubc, float flota, float flotb){
    	GL11.glPushMatrix();
        GL11.glTranslated(douba, doubb, doubc);
        GL11.glRotatef(flota, 0.0F, 1.0F, 0.0F);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        PapPapEntity.PapPapEnum enumart = entity.fielda;
        float f2 = 0.0625F;
        GL11.glScalef(f2, f2, f2);
        funca(entity, enumart.sizeX, enumart.sizeY);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }



    private void funca(PapPapEntity entity, int inta, int intb){
    	float f = (float)(-inta) / 2.0F;
        float f1 = (float)(-intb) / 2.0F;
        float f2 = 0.5F;
        float f3 = 0.75F;
        float f4 = 0.8125F;
        float f5 = 0.0F;
        float f6 = 0.0625F;
        float f7 = 0.75F;
        float f8 = 0.8125F;
        float f9 = 0.001953125F;
        float f10 = 0.001953125F;
        float f11 = 0.7519531F;
        float f12 = 0.7519531F;
        float f13 = 0.0F;
        float f14 = 0.0625F;

        for (int i1 = 0; i1 < inta / 16; ++i1) {
            for (int j1 = 0; j1 < intb / 16; ++j1){
                float f15 = f + (float)((i1 + 1) * 16);
                float f16 = f + (float)(i1 * 16);
                float f17 = f1 + (float)((j1 + 1) * 16);
                float f18 = f1 + (float)(j1 * 16);
                this.funcb(entity, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);
                float f19 = (float)(0 + inta - i1 * 16) / 256.0F;
                float f20 = (float)(0 + inta - (i1 + 1) * 16) / 256.0F;
                float f21 = (float)(0 + intb - j1 * 16) / 256.0F;
                float f22 = (float)(0 + intb - (j1 + 1) * 16) / 256.0F;
                Tessellator t = Tessellator.instance;
                
                t.startDrawingQuads();
                t.setNormal(0.0F, 0.0F, 1.0F);
                t.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f3, (double)f5);
                t.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f4, (double)f5);
                t.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f4, (double)f6);
                t.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f3, (double)f6);
                t.setNormal(0.0F, 1.0F, 0.0F);
                t.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f7, (double)f9);
                t.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f8, (double)f9);
                t.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f8, (double)f10);
                t.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f7, (double)f10);
                t.setNormal(0.0F, -1.0F, 0.0F);
                t.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f7, (double)f9);
                t.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f8, (double)f9);
                t.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f8, (double)f10);
                t.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f7, (double)f10);
                t.setNormal(-1.0F, 0.0F, 0.0F);
                t.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f12, (double)f13);
                t.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f12, (double)f14);
                t.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f11, (double)f14);
                t.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f11, (double)f13);
                t.setNormal(1.0F, 0.0F, 0.0F);
                t.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f12, (double)f13);
                t.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f12, (double)f14);
                t.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f11, (double)f14);
                t.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f11, (double)f13);
                t.draw();
          }
        }
     }
    private void funcb(PapPapEntity entity, float flot1, float flot2){
        int i = MathHelper.floor_double(entity.posX);
        int j = MathHelper.floor_double(entity.posY + (double)(flot2 / 16.0F));
        int k = MathHelper.floor_double(entity.posZ);

        if (entity.hangingDirection == 2)
        {
            i = MathHelper.floor_double(entity.posX + (double)(flot1 / 16.0F));
        }

        if (entity.hangingDirection == 1)
        {
            k = MathHelper.floor_double(entity.posZ - (double)(flot1 / 16.0F));
        }

        if (entity.hangingDirection == 0)
        {
            i = MathHelper.floor_double(entity.posX - (double)(flot1 / 16.0F));
        }

        if (entity.hangingDirection == 3)
        {
            k = MathHelper.floor_double(entity.posZ + (double)(flot1 / 16.0F));
        }

        int l = this.renderManager.worldObj.getLightBrightnessForSkyBlocks(i, j, k, 0);
        int i1 = l % 65536;
        int j1 = l / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);
        GL11.glColor3f(1.0F, 1.0F, 1.0F);
    }

protected ResourceLocation getEntityTexture(Entity ent){
	return local;
}

public void doRender(Entity entity, double douba, double doubb, double doubc, float flota, float flotb){
	doRender((PapPapEntity)entity, douba, doubb, doubc, flota, flotb);
}
}

 

I'm a novice programmer but I learn from others showing me how to code correctly so thank you for any help you give me! :)

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.

Announcements



×
×
  • Create New...

Important Information

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