-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Material Block Cleanup + Block Registration Cleanup + @ #1715
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TechLord22
reviewed
Apr 20, 2023
src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityLargeBoiler.java
Show resolved
Hide resolved
TechLord22
reviewed
Apr 29, 2023
|
||
public Material getGtMaterial(int meta) { | ||
return variantProperty.getAllowedValues().get(meta); | ||
return net.minecraft.block.material.Material.IRON; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, why this change? I know that super should always return Material.IRON because that is set in the constructor, but I would rather just continue calling super in case we change materials on frames, or just some frames, some day
ALongStringOfNumbers
approved these changes
May 10, 2023
TechLord22
approved these changes
May 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR features yet another code cleanup, this time focused on material blocks - compressed blocks, frames, and surface rocks.
Implementation Details
Previous implementation of these blocks,
BlockCompressed
,BlockFrame
andBlockOre
, each usedDelayedStateBlock
for implementation. The class essentially bypassed the limit imposed by initialization order, by modifying internal variable with reflection. Since the restriction can be also bypassed by alternative approach shown in this PR,DelayedStateBlock
is a kind of an unnecessary hack.Additionally those three classes had very similar implementations, with most of them being identical to eachother, so I've gathered common parts to a new class
BlockMaterialBase
, and rewrote the three preexisting classes with the new class as superclass.Two item classes,
CompressedItemBlock
andFrameItemBlock
, were replaced by a new classMaterialItemBlock
.As
DelayedStateBlock
no longer has any usage after this PR, it is marked as deprecated.Block registration stuff also received refactor: Compressed blocks, frames, and surface rocks now have separate list of blocks for registration, eliminating need for
distinct()
stream operations. Also all the block/item colors declared inClientProxy
have been moved directly to the usage, with better implementation. I don't know who came up with the idea of sharing oneIBlockColor
/IItemColor
with multiple blocks and typechecking the block inside the color implementation, but it was certainly a funny one.Additional Information
To become true Developer of GregTech I decided to fully embrace the tradition of our ancestor - the great Archengius, creator of GT:CE Official Edition - by creating the work with same spirit and technique as him. i.e. I made an Arch commit. Below are the list of minor code refactors included in this PR.
MultiblockControllerBase
Marked
structurePattern
as nullable. Ran reformat once.MetaItemBracketHandler
Removed unnecessary suppression.
BlockCompressed
/BlockFrame
/BlockOre
Removed static
getItem
util method that just delegated call toGTUtility#getItem
.BlockOre
/OreItemBlock
Changed to use vanilla
setCreativeTab
instead of overridinggetCreativeTabs
manually.MetaTileEntityLargeMiner
/MetaTileEntityLargeBoiler
Removed returning
null
atcreateStructurePattern
. It looked like there was some sort of init order problem similar to the one that led to creation ofDelayedStateBlock
, but I didn't notice any such problem both during code inspection and in-game testing.MetaTileEntitySteamOven
Removed unused variable.
MetaTileEntityMultiblockTank
Changed nothing.
Potential Compatibility Issues
Mods using util methods removed from this PR, like
BlockCompressed#getItem
, will be affected. Other than that I'm not sure.