Update NeoForge, adjust dynamic resources for NF API
This commit is contained in:
parent
700ccc25b7
commit
d46d24542f
|
|
@ -75,20 +75,34 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
|
|
||||||
private final Map<ModelResourceLocation, BakedModel> mfix$emulatedBakedRegistry = new DynamicOverridableMap<>(this::loadBakedModelDynamic);
|
private final Map<ModelResourceLocation, BakedModel> mfix$emulatedBakedRegistry = new DynamicOverridableMap<>(this::loadBakedModelDynamic);
|
||||||
|
|
||||||
@Unique
|
@Override
|
||||||
private UnbakedModel loadUnbakedModelDynamic(ModelResourceLocation location) {
|
public UnbakedModel mfix$loadUnbakedModelDynamic(ModelResourceLocation location) {
|
||||||
if(location.equals(MISSING_MODEL_VARIANT)) {
|
if(location.equals(MISSING_MODEL_VARIANT)) {
|
||||||
return missingModel;
|
return missingModel;
|
||||||
}
|
}
|
||||||
if(DEBUG_MODEL_LOADS) {
|
modelBakeryLock.lock();
|
||||||
ModernFix.LOGGER.info("Loading model {}", location);
|
try {
|
||||||
|
UnbakedModel existing = this.topLevelModels.get(location);
|
||||||
|
if (existing != null) {
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
if(DEBUG_MODEL_LOADS) {
|
||||||
|
ModernFix.LOGGER.info("Loading model {}", location);
|
||||||
|
}
|
||||||
|
if(location.variant().equals("inventory")) {
|
||||||
|
this.loadItemModelAndDependencies(location.id());
|
||||||
|
} else {
|
||||||
|
((IBlockStateModelLoader)dynamicLoader).loadSpecificBlock(location);
|
||||||
|
}
|
||||||
|
return this.topLevelModels.getOrDefault(location, this.missingModel);
|
||||||
|
} finally {
|
||||||
|
modelBakeryLock.unlock();
|
||||||
}
|
}
|
||||||
if(location.variant().equals("inventory")) {
|
}
|
||||||
this.loadItemModelAndDependencies(location.id());
|
|
||||||
} else {
|
@Override
|
||||||
((IBlockStateModelLoader)dynamicLoader).loadSpecificBlock(location);
|
public UnbakedModel mfix$getMissingModel() {
|
||||||
}
|
return missingModel;
|
||||||
return this.topLevelModels.getOrDefault(location, this.missingModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
|
@ -101,7 +115,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
try {
|
try {
|
||||||
model = bakedTopLevelModels.get(location);
|
model = bakedTopLevelModels.get(location);
|
||||||
if(model == null) {
|
if(model == null) {
|
||||||
UnbakedModel prototype = loadUnbakedModelDynamic(location);
|
UnbakedModel prototype = mfix$loadUnbakedModelDynamic(location);
|
||||||
prototype.resolveParents(this::getModel);
|
prototype.resolveParents(this::getModel);
|
||||||
if(DEBUG_MODEL_LOADS) {
|
if(DEBUG_MODEL_LOADS) {
|
||||||
ModernFix.LOGGER.info("Baking model {}", location);
|
ModernFix.LOGGER.info("Baking model {}", location);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
package org.embeddedt.modernfix.duck;
|
package org.embeddedt.modernfix.duck;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
|
|
||||||
public interface IExtendedModelBakery {
|
public interface IExtendedModelBakery {
|
||||||
void mfix$tick();
|
void mfix$tick();
|
||||||
void mfix$finishLoading();
|
void mfix$finishLoading();
|
||||||
|
UnbakedModel mfix$loadUnbakedModelDynamic(ModelResourceLocation location);
|
||||||
|
UnbakedModel mfix$getMissingModel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ mixinextras_version=0.3.2
|
||||||
mod_id=modernfix
|
mod_id=modernfix
|
||||||
minecraft_version=1.21
|
minecraft_version=1.21
|
||||||
enabled_platforms=fabric,neoforge
|
enabled_platforms=fabric,neoforge
|
||||||
forge_version=21.0.0-beta
|
forge_version=21.0.18-beta
|
||||||
# parchment_version=2023.07.09
|
# parchment_version=2023.07.09
|
||||||
refined_storage_version=4392788
|
refined_storage_version=4392788
|
||||||
jei_version=16.0.0.28
|
jei_version=16.0.0.28
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.embeddedt.modernfix.neoforge.mixin.perf.dynamic_resources;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
import org.embeddedt.modernfix.duck.IExtendedModelBakery;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(targets = {"net/minecraft/client/resources/model/ModelBakery$ModelBakerImpl"})
|
||||||
|
@ClientOnlyMixin
|
||||||
|
public class ModelBakerImplMixin {
|
||||||
|
@Shadow @Final private ModelBakery field_40571;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author embeddedt
|
||||||
|
* @reason Handle dynamic model loading
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public UnbakedModel getTopLevelModel(ModelResourceLocation location) {
|
||||||
|
IExtendedModelBakery bakery = (IExtendedModelBakery)this.field_40571;
|
||||||
|
UnbakedModel model = bakery.mfix$loadUnbakedModelDynamic(location);
|
||||||
|
return model == bakery.mfix$getMissingModel() ? null : model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ modId = "neoforge" #mandatory
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
type = "required" #mandatory
|
type = "required" #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange = "[21.0.0-alpha,)" #mandatory
|
versionRange = "[21.0.17-beta,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user