Jump to content

Recommended Posts

Posted

I am triing to make a custom furnace, which is like the vanilla furnace, just with some additional properties.

Since most of the stuff is like vanilla furnaces I created a TE extending TileEntityFurnace, a Block extended BlockFurnace and fixxed my .json files.

I am saving the locations of placed furnaces in a TileEntity, called TileEntityBase. At one point I need to sync the placed furnaces between Client and Server Side, so I am using a package.

The problem is that it seems that my custom block is creating a TileEntityFurnace, so I am getting a ClassCastException here

 int i = 0;
for(BlockPos location : message.furnaceLocations)
{			
  furnaces[i] = (TileEntityBaseFurnace) worldObj.getTileEntity(location);
  i++;
}

 

The locations are beeing send via the message, and these are the correct positions, I checked that.

So it seems that at some point minecraft seems to kill my custom TileEntity and replace it with a TileEntityFurnace.

But the only place where I can see Minecraft creating a TE is at

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
  return new TileEntityBaseFurnace();
}

 

Am I missing something?

 

Posted

I do this because like a machine that can access several furnaces. Like an overview of all your furnaces. That why I want to send the data to client so it can display it in the gui

Posted

It is usually bad practice to cast something without checking that it is an instanceof the class you're casting to. So check that worldObj.getTileEntity() instanceof TileEntityBaseFurnace.

 

After that, I think you just need to do standard debug. Put console/logger statements in each of the parts of the code, such as the message processing, to confirm that the information is getting synced as you expect. In the code you posted above, put in statements that print out the location and what block is in that position.

 

You should quickly be able to figure out what is wrong just by following the execution of your code.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.