GregTechCEu / GregTech

GregTech CE 1.12 fork continuing progression and development
GNU Lesser General Public License v3.0
223 stars 166 forks source link

Fix blocks not being able to choose preferred meta values in previews #2446

Closed bruberu closed 1 month ago

bruberu commented 1 month ago

What

Previously, in Supersymmetry, there were several blocks in JEI previews that were rotated variants of the original block shown in JEI searches. However, the toItem method used to retrieve the stack for the item requirement list did not take this into account, and used the rotated variant rather than the normal item. For example, if rotated wooden logs were placed into a multiblock structure, missing item textures would appear:

image

Implementation Details

I've mitigated this issue by prioritizing the pickBlock method within the stack retrieval algorithm, allowing blocks such as wooden logs to have more of a "say" in what meta is applied. Although the original comment states that pickBlock is "not great," analyzing the code shows that it has nearly the same method calls as GTUtility's toItem, with the GregFakePlayer call being cached after its first use.

Outcome

Allows blocks from addons to return the correct item stack for multiblock previews.

Potential Compatibility Issues

In the case that a specific multiblock from an addon added special code to pickBlock that wouldn't apply to multiblock previews for some reason, that might cause a problem, but I find it unlikely.