Jump to content

[Solved] TileEntity cast weird behaviour


Wouto1997

Recommended Posts

Hello everyone.

 

I'm currently working on a mod, where I have a block, which has a TileEntity, with a custom model. The TileEntity model has a movable part in it, of which the TileEntity tells it's current state. The TileEntity also has a second value, Energy, which will tell the renderer what texture to use. In my TileEntitySpecialRenderer extended class, I've got this function:

 

    @Override
    public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) {
        this.renderAModelAt(var2, var4, var6, ((TileEntityTPPeripheral)var1).Energy, ((TileEntityTPPeripheral)var1).ChestConnection);
    }

 

Now when it executes renderAModelAt(); I've put in some debugging messages, and I've gotten the following output:

  • Energy: 0
  • ChestConnection: 3
  • Texture: 0.png

 

The ChectConnection variable ( that first variable that makes a part move ) is working here, but the Energy variable should be 10000.

I've also added an onblockactivated check on the block of the tile entity to check the Energy there, and there it is actually saying 10000.

The texture doesn't really matter in this debugging result, since that's determined by the currently incorrect energy value.

 

If anyone has a clue of what I'm doing wrong I'd be glad to hear :)

Link to comment
Share on other sites

I had the same desync trouble between client and server parts of the game. The container class should solve your problem: just override methods

 

public void addCraftingToCrafters(ICrafting par1ICrafting)

public void detectAndSendChanges()

 

  @SideOnly(Side.CLIENT)

    public void updateProgressBar(int index, int value)

 

(you can find out what they should do in ContainerFurnace class)

these methods are required for proper syncing between client and server TE

Link to comment
Share on other sites

Thanks a lot! used the Packet132TileEntityData packet if other people are wondering.

 

-note:

an issue I had with the packet was that I kept getting nullpointerexceptions on world loading, now this was just me being stupid, ( nullpointerexceptions usually mean you did something stupid but anyways), What I was doing wrong, in the Packet, make sure you assign a new NBTTagCompound() to customParam1 before you start putting stuff in it :3

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.