Skip to content

Comments

Make possible for addons to add machine items in other creative tabs#1510

Merged
ALongStringOfNumbers merged 1 commit intoGregTechCEu:masterfrom
Tictim:custom_machine_tab
Mar 2, 2023
Merged

Make possible for addons to add machine items in other creative tabs#1510
ALongStringOfNumbers merged 1 commit intoGregTechCEu:masterfrom
Tictim:custom_machine_tab

Conversation

@Tictim
Copy link
Contributor

@Tictim Tictim commented Feb 14, 2023

What

This PR introduces a method to add machines in creative tabs other than gregtech.main.

This feature is only intended for addons - specifically, only custom MTEs; providing ways to arbitrarily change creative tabs for existing MTEs is not the goal of this PR.

Implementation Details

Creative tab checking is now handled by MTEs directly, by newly created method MetaTileEntity#isInCreativeTab(CreativeTabs). This method can be overridden, allowing fine controls on which creative tab the machine is added. The method is called on BlockMachine#getSubBlocks() so that previous implementations of MetaTileEntity#getSubItems() function the same way.

To minimize performance impact, each additional creative tabs for machines must be manually registered by MachineItemBlock#addCreativeTab(CreativeTabs). This approach should retain performance on unmodified instance as-is.

Potential Compatibility Issues

Compatibility issue should be minimal, as the interaction between previous MetaTileEntity#getSubItems() implementations and newly added API produces identical result to previous code.

I did not observe any performance degradation from my own testing, but considering it was done with just one extra tab registered, it is not a definite answer.

…to add machine items in their own creative tabs
@ALongStringOfNumbers ALongStringOfNumbers added the type: feature New feature or request label Feb 15, 2023
Copy link
Contributor

@LAGIdiot LAGIdiot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks reasonable. In game testing was not performed.

@ALongStringOfNumbers ALongStringOfNumbers merged commit af293fa into GregTechCEu:master Mar 2, 2023
@Tictim Tictim deleted the custom_machine_tab branch March 3, 2023 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants