Jump to content

[1.7.2] [Solved] Particle crash by custom block renderer


Recommended Posts

Posted

Hello.

 

I'm using the lastest forge version with Java 8 and I'm getting every time a crash when I add particle to my Campfire block. So what I'm doing wrong, and no its not the particle class, because the same code without TileEntity and custom renderer worked fine.

 

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

 

And yes, I tested it with different Forge versions...

 

Oh and before I forget it ... here is the crash:

 

  Reveal hidden contents

 

 

Bektor

Developer of Primeval Forest.

Posted

Hi

 

The problem is related to your TileEntity setup code.

FYI I traced it back like this:

NibbleArray::
    /**
     * Returns the nibble of data corresponding to the passed in x, y, z. y is at most 6 bits, z is at most 4.
     */
    public int get(int par1, int par2, int par3)
    {
        int l = par2 << this.depthBitsPlusFour | par3 << this.depthBits | par1;
        int i1 = l >> 1;
        int j1 = l & 1;
        return j1 == 0 ? this.data[i1] & 15 : this.data[i1] >> 4 & 15;   // From Error log: error is here, i1 is -88
    }

So int par1, par2, and par3 are out of the expected range, and from the index it looks one or more is probably negative when they're expected to be positive

Tracing this back up through the list of callers brings us eventually to 

 

    public void addTileEntity(TileEntity p_150813_1_)
    {
        int i = p_150813_1_.xCoord - this.xPosition * 16;
        int j = p_150813_1_.yCoord;
        int k = p_150813_1_.zCoord - this.zPosition * 16;
        this.func_150812_a(i, j, k, p_150813_1_);             // i, j, and/or k are out of expected range, probably smaller than the chunk [x,y,z] position

//[..]
    }

 

So it looks to me like your TileEntity x coordinate and/or z coordinate is wrong for the chunk that it's being added to; the vanilla assumes that the TileEntity [x,y,z] will be within the  16x256x16 block cube for that chunk.

A search through the code shows that xCoord is normally set in only two places:

Chunk.setChunkBlockTileEntity()

and

TileEntity.readFromNBT()

 

Your TileEntity had an override of readFromNBT, so what should that look like for a vanilla TileEntity such as TileEntityChest?

 

TileEntityChest::
    /**
     * Reads a tile entity from NBT.
     */
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");

--> I think this is the problem - compare with yours

 

-TGG

 

Posted

Well... :P I am wondering the same thing. I have made a small fix for this problem by creating an item that places the wanted block via the onItemUse() method. Then, from there, create an IItemRenderer (I think its called) and register it. Then for the actual rendering you use your tile entity renderer and position 0,0,0.

 

But I would like to know the better way of doing it...

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

@TGG How does ISimpleBlockRenderingHandler take care of rendering a block in the inventory? Can you give an example?

We all stuff up sometimes... But I seem to be at the bottom of that pot.

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.