Material Block Cleanup + Block Registration Cleanup + @#1715
Merged
TechLord22 merged 6 commits intoGregTechCEu:masterfrom May 11, 2023
Merged
Material Block Cleanup + Block Registration Cleanup + @#1715TechLord22 merged 6 commits intoGregTechCEu:masterfrom
TechLord22 merged 6 commits intoGregTechCEu:masterfrom
Conversation
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; |
Contributor
There was a problem hiding this comment.
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
This file contains hidden or 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
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,BlockFrameandBlockOre, each usedDelayedStateBlockfor 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,DelayedStateBlockis 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,
CompressedItemBlockandFrameItemBlock, were replaced by a new classMaterialItemBlock.As
DelayedStateBlockno 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 inClientProxyhave been moved directly to the usage, with better implementation. I don't know who came up with the idea of sharing oneIBlockColor/IItemColorwith 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.
MultiblockControllerBaseMarked
structurePatternas nullable. Ran reformat once.MetaItemBracketHandlerRemoved unnecessary suppression.
BlockCompressed/BlockFrame/BlockOreRemoved static
getItemutil method that just delegated call toGTUtility#getItem.BlockOre/OreItemBlockChanged to use vanilla
setCreativeTabinstead of overridinggetCreativeTabsmanually.MetaTileEntityLargeMiner/MetaTileEntityLargeBoilerRemoved returning
nullatcreateStructurePattern. 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.MetaTileEntitySteamOvenRemoved unused variable.
MetaTileEntityMultiblockTankChanged 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.