Fix dynamic resources losing nested model loads sometimes
This commit is contained in:
parent
c73cb8115e
commit
0a2601257c
|
|
@ -348,6 +348,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int mfix$nestedLoads = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
* @reason synchronize
|
* @reason synchronize
|
||||||
|
|
@ -372,6 +374,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
while(!this.loadingStack.isEmpty()) {
|
while(!this.loadingStack.isEmpty()) {
|
||||||
ResourceLocation resourcelocation = this.loadingStack.iterator().next();
|
ResourceLocation resourcelocation = this.loadingStack.iterator().next();
|
||||||
|
|
||||||
|
mfix$nestedLoads++;
|
||||||
try {
|
try {
|
||||||
existing = this.unbakedCache.get(resourcelocation);
|
existing = this.unbakedCache.get(resourcelocation);
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
|
|
@ -389,6 +392,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
this.unbakedCache.put(resourcelocation, iunbakedmodel);
|
this.unbakedCache.put(resourcelocation, iunbakedmodel);
|
||||||
smallLoadingCache.put(resourcelocation, iunbakedmodel);
|
smallLoadingCache.put(resourcelocation, iunbakedmodel);
|
||||||
} finally {
|
} finally {
|
||||||
|
mfix$nestedLoads--;
|
||||||
this.loadingStack.remove(resourcelocation);
|
this.loadingStack.remove(resourcelocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +402,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
// the model immediately
|
// the model immediately
|
||||||
UnbakedModel result = smallLoadingCache.getOrDefault(modelLocation, iunbakedmodel);
|
UnbakedModel result = smallLoadingCache.getOrDefault(modelLocation, iunbakedmodel);
|
||||||
// We are done with loading, so clear this cache to allow GC of any unneeded models
|
// We are done with loading, so clear this cache to allow GC of any unneeded models
|
||||||
smallLoadingCache.clear();
|
if(mfix$nestedLoads == 0)
|
||||||
|
smallLoadingCache.clear();
|
||||||
cir.setReturnValue(result);
|
cir.setReturnValue(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +469,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
if (iunbakedmodel instanceof BlockModel) {
|
if (iunbakedmodel instanceof BlockModel) {
|
||||||
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
||||||
if (blockmodel.getRootModel() == GENERATION_MARKER) {
|
if (blockmodel.getRootModel() == GENERATION_MARKER) {
|
||||||
ibakedmodel = ITEM_MODEL_GENERATOR.generateBlockModel(textureGetter, blockmodel).bake((ModelBakery)(Object)this, blockmodel, this.atlasSet::getSprite, arg2, arg, false);
|
ibakedmodel = ITEM_MODEL_GENERATOR.generateBlockModel(textureGetter, blockmodel).bake((ModelBakery)(Object)this, blockmodel, textureGetter, arg2, arg, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ibakedmodel == null) {
|
if(ibakedmodel == null) {
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
smallLoadingCache.put(location, model);
|
smallLoadingCache.put(location, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int mfix$nestedLoads = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
|
|
@ -258,6 +259,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
while(!this.loadingStack.isEmpty()) {
|
while(!this.loadingStack.isEmpty()) {
|
||||||
ResourceLocation resourcelocation = this.loadingStack.iterator().next();
|
ResourceLocation resourcelocation = this.loadingStack.iterator().next();
|
||||||
|
|
||||||
|
mfix$nestedLoads++;
|
||||||
try {
|
try {
|
||||||
existing = this.unbakedCache.get(resourcelocation);
|
existing = this.unbakedCache.get(resourcelocation);
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
|
|
@ -275,6 +277,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
this.unbakedCache.put(resourcelocation, iunbakedmodel);
|
this.unbakedCache.put(resourcelocation, iunbakedmodel);
|
||||||
smallLoadingCache.put(resourcelocation, iunbakedmodel);
|
smallLoadingCache.put(resourcelocation, iunbakedmodel);
|
||||||
} finally {
|
} finally {
|
||||||
|
mfix$nestedLoads--;
|
||||||
this.loadingStack.remove(resourcelocation);
|
this.loadingStack.remove(resourcelocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +287,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
// the model immediately
|
// the model immediately
|
||||||
UnbakedModel result = smallLoadingCache.getOrDefault(modelLocation, iunbakedmodel);
|
UnbakedModel result = smallLoadingCache.getOrDefault(modelLocation, iunbakedmodel);
|
||||||
// We are done with loading, so clear this cache to allow GC of any unneeded models
|
// We are done with loading, so clear this cache to allow GC of any unneeded models
|
||||||
smallLoadingCache.clear();
|
if(mfix$nestedLoads == 0)
|
||||||
|
smallLoadingCache.clear();
|
||||||
cir.setReturnValue(result);
|
cir.setReturnValue(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -337,7 +341,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
if (iunbakedmodel instanceof BlockModel) {
|
if (iunbakedmodel instanceof BlockModel) {
|
||||||
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
||||||
if (blockmodel.getRootModel() == GENERATION_MARKER) {
|
if (blockmodel.getRootModel() == GENERATION_MARKER) {
|
||||||
ibakedmodel = ITEM_MODEL_GENERATOR.generateBlockModel(textureGetter, blockmodel).bake((ModelBakery)(Object)this, blockmodel, this.atlasSet::getSprite, arg2, arg, false);
|
ibakedmodel = ITEM_MODEL_GENERATOR.generateBlockModel(textureGetter, blockmodel).bake((ModelBakery)(Object)this, blockmodel, textureGetter, arg2, arg, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ibakedmodel == null) {
|
if(ibakedmodel == null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user