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.

[1.8] [SOLVED] Model Bake Event + world.getTileEntity() returns null

Featured Replies

Posted

Currently having problems getting TEs to work and I'm out of ideas for the cause.

 

I've got a TEOre class extending from Tileentity featuring basically the same functions as the CustomeTileEntity in ModelBakeEventDebug.java

 

During the FMLInitializationEvent I do

GameRegistry.registerTileEntity(TEOre.class, ModInfo.ModID + ":orete");

 

My Block Class BlockOreVC extends from BlockContainer and creates the tile entity

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

    @Override
    public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
        TileEntity te = world.getTileEntity(pos);
        if(te instanceof TEOre) {
        	TEOre cte = (TEOre) te;
            return cte.getState();
        } else {
        	if (te == null) {
        		System.out.println("getExtendedState() Error: tileentity is null!");
        	} else {
        		System.out.println("getExtendedState() Error: te is NOT of instance TEOre at pos " + pos);
        	}
        }
        return state;
    }

    @Override
    protected BlockState createBlockState() {
        return new ExtendedBlockState(this, new IProperty[0], TEOre.properties);
    }

 

I create the blocks in WorldGenDeposits like this:

				world.setBlockState(pos, deposit.block.getDefaultState(), 2);

				if (deposit.block instanceof BlockOreVC) {
					TEOre tileentity = (TEOre)world.getTileEntity(pos);
					if(tileentity != null) {
						tileentity.setOreType(deposit).setRockType((EnumRockType)parentmaterial.getValue(BlockRock.STONETYPE));
					} else {
						System.out.println("tileentity was not created?");
					}
				}

 

 

When generating a new world however the call to getExtendedState() will return null for world.getTileEntity(pos);

I dont understand why because during creation I can access the tileentity and modify it's state.

 

Am I missing some client <=> server stuff for tileentities to work?

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.