Jump to content

[Suggestion] createNewTileEntity should pass all variables down the chain


Recommended Posts

Posted

I don't know if ITileEntityProvider is a Forge implementation or not but just in case it is....

 

Suggestion:

 

Implement createTileEntity() in ITileEntityProvider to use the metadata value as provided by the call to createTileEntity() in Block.java

 

Details:

 

In Block.java, under the heading "Forge Start" we find an implementation of createTileEntity:

 

    public TileEntity createTileEntity(World world, int metadata)
    {
        if (isTileProvider)
        {
            return ((ITileEntityProvider)this).createNewTileEntity(world);
        }
        return null;
    }

 

which in turn calls to ITileEntityProvider, the actual implementation that gets overridden by modders. Unfortunately it neglects to pass the metadata value through to ITileEntityProvider thereby making this value unavailable.

 

The usefulness in having it is that the value can be passed into the TileEntity through its constructor (none of the TileEntity inherited properties: worldObj, xCoord, blockMetadata, etc. are available for use in the constructor) which would in turn allow modders some flexibility to make rudamentary decisions on how the TileEntity would be initialized.

Posted

ITileEntityProvider is not a forge addition (which you could have know by just looking at the package).

 

Well to be fair the package doesn't necessarily mean it's not forge. Take a look at net.minecraft.block.block and you'll see a giant comment called "FORGE START".

 

 

To make TileEntities with forge don't implement or extend anything. Just override

hasTileEntity(int metadata)

and

createTileEntity(World world, int metadata)

in your block.

 

Thanks for this tip. I was implementing ITileEntityProvider based on some research on the wiki and other sources. I guess things are a bit outdated now.

Posted

They are correct, any class that we add will NOT be in net.minecraft, it'll be in net.minecraftforge.

So ITileEntityProvider is NOT something we can edit as it'd break interfaces. However, as they said, you'd just override Block.hasTileEntity and Block.createTileEntity to do everything you need.

Mainly because ITileEntityProvider will never be applicable to anything except blocks. It doesn't seem logicial to have it as a interface :P

 

As for 'not in net.minecraftforge' we have to touch base classes, that's kinda our job. If we touch thing in a large way {like we do with Block/Item} we try to keep all of our code seperate, hence the 'Forge Start' comment. If you'd notice the bulk of our Block.java.path is adding new code in 1 big hunk :P

 

Basically, to sum it up, With Forge, ITileEntityProvider is obsolete, don't use it.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.