33import com .llamalad7 .mixinextras .injector .ModifyExpressionValue ;
44import net .minecraft .client .renderer .texture .TextureAtlasSprite ;
55import net .minecraft .client .resources .model .*;
6- import net .minecraft .core .registries .BuiltInRegistries ;
76import net .minecraft .resources .ResourceLocation ;
8- import net .minecraft .world .level .block .Block ;
9- import net .minecraft .world .level .block .state .BlockState ;
10- import net .minecraftforge .fml .util .ObfuscationReflectionHelper ;
117import org .embeddedt .modernfix .ModernFix ;
128import org .embeddedt .modernfix .ModernFixClient ;
139import org .embeddedt .modernfix .api .entrypoint .ModernFixClientIntegration ;
2016import org .spongepowered .asm .mixin .injection .Inject ;
2117import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
2218
23- import java .lang .invoke .MethodHandle ;
24- import java .lang .invoke .MethodHandles ;
25- import java .util .Objects ;
26- import java .util .Optional ;
2719import java .util .function .Function ;
2820
2921@ Mixin (value = ModelBakery .ModelBakerImpl .class , priority = 600 )
@@ -35,17 +27,6 @@ public abstract class ModelBakerImplMixin implements IModelBakerImpl {
3527
3628 @ Shadow @ Final private Function <Material , TextureAtlasSprite > modelTextureGetter ;
3729
38- private static final MethodHandle blockStateLoaderHandle ;
39- static {
40- try {
41- blockStateLoaderHandle = MethodHandles .lookup ().unreflect (
42- ObfuscationReflectionHelper .findMethod (ModelBakery .class , "m_119263_" , BlockState .class )
43- );
44- } catch (ReflectiveOperationException e ) {
45- throw new RuntimeException (e );
46- }
47- }
48-
4930 @ Override
5031 public void mfix$ignoreCache () {
5132 mfix$ignoreCache = true ;
@@ -69,20 +50,7 @@ private void obtainModel(ResourceLocation arg, CallbackInfoReturnable<UnbakedMod
6950 if (arg instanceof ModelResourceLocation && arg != ModelBakery .MISSING_MODEL_LOCATION ) {
7051 // synchronized because we use topLevelModels
7152 synchronized (this .field_40571 ) {
72- /* to emulate vanilla model loading, treat as top-level */
73- Optional <Block > blockOpt = Objects .equals (((ModelResourceLocation )arg ).getVariant (), "inventory" ) ? Optional .empty () : BuiltInRegistries .BLOCK .getOptional (new ResourceLocation (arg .getNamespace (), arg .getPath ()));
74- if (blockOpt .isPresent ()) {
75- /* load via lambda for mods that expect blockstate to get loaded */
76- for (BlockState state : extendedBakery .getBlockStatesForMRL (blockOpt .get ().getStateDefinition (), (ModelResourceLocation )arg )) {
77- try {
78- blockStateLoaderHandle .invokeExact (this .field_40571 , state );
79- } catch (Throwable e ) {
80- ModernFix .LOGGER .error ("Error loading model" , e );
81- }
82- }
83- } else {
84- this .field_40571 .loadTopLevel ((ModelResourceLocation )arg );
85- }
53+ this .field_40571 .loadTopLevel ((ModelResourceLocation )arg );
8654 cir .setReturnValue (this .field_40571 .topLevelModels .getOrDefault (arg , extendedBakery .mfix$getUnbakedMissingModel ()));
8755 // avoid leaks
8856 this .field_40571 .topLevelModels .clear ();
0 commit comments