File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
common/src/main/java/org/embeddedt/modernfix/dynamicresources Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1111import net .minecraft .world .level .block .state .BlockState ;
1212import org .jetbrains .annotations .Nullable ;
1313
14+ import java .lang .ref .WeakReference ;
1415import java .util .List ;
15- import java .util .Map ;
16- import java .util .concurrent .ConcurrentHashMap ;
1716
1817/**
1918 * Delegate model that stores the location of an actual baked model, for use in ItemOverrides.
2019 */
2120public class ItemOverrideBakedModel implements BakedModel {
22- private static final Map <ResourceLocation , ItemOverrideBakedModel > OVERRIDE_MODELS = new ConcurrentHashMap <>();
2321 public final ResourceLocation realLocation ;
22+ private WeakReference <BakedModel > realModel = new WeakReference <>(null );
2423
2524 private ItemOverrideBakedModel (ResourceLocation realLocation ) {
2625 this .realLocation = realLocation ;
2726 }
2827
2928 public static ItemOverrideBakedModel of (ResourceLocation realLocation ) {
30- return OVERRIDE_MODELS . computeIfAbsent ( realLocation , ItemOverrideBakedModel :: new );
29+ return new ItemOverrideBakedModel ( realLocation );
3130 }
3231
3332 public BakedModel getRealModel () {
34- return DynamicBakedModelProvider .currentInstance .get (realLocation );
33+ BakedModel m = realModel .get ();
34+ if (m == null ) {
35+ m = DynamicBakedModelProvider .currentInstance .get (realLocation );
36+ realModel = new WeakReference <>(m );
37+ }
38+ return m ;
3539 }
3640
3741 @ Override
You can’t perform that action at this time.
0 commit comments