Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

 

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.