Merge remote-tracking branch 'origin/1.18' into 1.19.2
This commit is contained in:
commit
a7f0c08a94
|
|
@ -98,6 +98,7 @@ dependencies {
|
|||
modRuntimeOnly("curse.maven:ferritecore-429235:4117906")
|
||||
modCompileOnly("team.chisel.ctm:CTM:${ctm_version}")
|
||||
modCompileOnly("curse.maven:supermartijncore-454372:4455391")
|
||||
modImplementation("appeng:appliedenergistics2-forge:12.9.4")
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.BuiltInModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
|
@ -22,12 +23,19 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
|||
private final ModelBakery bakery;
|
||||
private final Map<Triple<ResourceLocation, Transformation, Boolean>, BakedModel> bakedCache;
|
||||
private final Map<ResourceLocation, BakedModel> permanentOverrides;
|
||||
private BakedModel missingModel;
|
||||
private static final BakedModel SENTINEL = new BuiltInModel(null, null, null, false);
|
||||
|
||||
public DynamicBakedModelProvider(ModelBakery bakery, Map<Triple<ResourceLocation, Transformation, Boolean>, BakedModel> cache) {
|
||||
this.bakery = bakery;
|
||||
this.bakedCache = cache;
|
||||
this.permanentOverrides = new Object2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
public void setMissingModel(BakedModel model) {
|
||||
this.missingModel = model;
|
||||
}
|
||||
|
||||
private static Triple<ResourceLocation, Transformation, Boolean> vanillaKey(Object o) {
|
||||
return Triple.of((ResourceLocation)o, BlockModelRotation.X0_Y0.getRotation(), false);
|
||||
}
|
||||
|
|
@ -43,7 +51,7 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
|||
|
||||
@Override
|
||||
public boolean containsKey(Object o) {
|
||||
return true; //permanentOverrides.containsKey(o) || bakedCache.containsKey(vanillaKey(o));
|
||||
return permanentOverrides.getOrDefault(o, SENTINEL) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,8 +61,18 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
|||
|
||||
@Override
|
||||
public BakedModel get(Object o) {
|
||||
BakedModel model = permanentOverrides.get(o);
|
||||
return model != null ? model : bakery.bake((ResourceLocation)o, BlockModelRotation.X0_Y0);
|
||||
BakedModel model = permanentOverrides.getOrDefault(o, SENTINEL);
|
||||
if(model != SENTINEL)
|
||||
return model;
|
||||
else {
|
||||
model = bakery.bake((ResourceLocation)o, BlockModelRotation.X0_Y0);
|
||||
if(model == missingModel) {
|
||||
// to correctly emulate the original map, we return null for missing models
|
||||
permanentOverrides.put((ResourceLocation) o, null);
|
||||
return null;
|
||||
} else
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
@Shadow public abstract UnbakedModel getModel(ResourceLocation modelLocation);
|
||||
|
||||
@Shadow @Final @Mutable private BlockColors blockColors;
|
||||
|
||||
@Shadow @Nullable public abstract BakedModel bake(ResourceLocation arg, ModelState arg2, Function<Material, TextureAtlasSprite> sprites);
|
||||
|
||||
private Cache<Triple<ResourceLocation, Transformation, Boolean>, BakedModel> loadedBakedModels;
|
||||
private Cache<ResourceLocation, UnbakedModel> loadedModels;
|
||||
|
||||
|
|
@ -329,6 +332,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
@Inject(method = "uploadTextures", at = @At(value = "FIELD", target = "Lnet/minecraft/client/resources/model/ModelBakery;topLevelModels:Ljava/util/Map;", ordinal = 0), cancellable = true)
|
||||
private void skipBake(TextureManager resourceManager, ProfilerFiller profiler, CallbackInfoReturnable<AtlasSet> cir) {
|
||||
profiler.pop();
|
||||
// ensure missing model is a permanent override
|
||||
this.bakedTopLevelModels.put(MISSING_MODEL_LOCATION, this.bake(MISSING_MODEL_LOCATION, BlockModelRotation.X0_Y0, this.atlasSet::getSprite));
|
||||
cir.setReturnValue(atlasSet);
|
||||
}
|
||||
|
||||
|
|
@ -453,6 +458,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
return loadOnlyRelevantBlockState(stateDefinition, location);
|
||||
}
|
||||
|
||||
private BakedModel bakedMissingModel = null;
|
||||
|
||||
@Inject(method = "bake(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/resources/model/ModelState;Ljava/util/function/Function;)Lnet/minecraft/client/resources/model/BakedModel;", at = @At("HEAD"), cancellable = true, remap = false)
|
||||
public void getOrLoadBakedModelDynamic(ResourceLocation arg, ModelState arg2, Function<Material, TextureAtlasSprite> textureGetter, CallbackInfoReturnable<BakedModel> cir) {
|
||||
Triple<ResourceLocation, Transformation, Boolean> triple = Triple.of(arg, arg2.getRotation(), arg2.isUvLocked());
|
||||
|
|
@ -475,7 +482,15 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
}
|
||||
}
|
||||
if(ibakedmodel == null) {
|
||||
ibakedmodel = iunbakedmodel.bake((ModelBakery) (Object) this, textureGetter, arg2, arg);
|
||||
if(iunbakedmodel == missingModel) {
|
||||
// use a shared baked missing model
|
||||
if(bakedMissingModel == null) {
|
||||
bakedMissingModel = iunbakedmodel.bake((ModelBakery) (Object) this, textureGetter, arg2, arg);
|
||||
((DynamicBakedModelProvider)this.bakedTopLevelModels).setMissingModel(bakedMissingModel);
|
||||
}
|
||||
ibakedmodel = bakedMissingModel;
|
||||
} else
|
||||
ibakedmodel = iunbakedmodel.bake((ModelBakery) (Object) this, textureGetter, arg2, arg);
|
||||
}
|
||||
DynamicModelBakeEvent event = new DynamicModelBakeEvent(arg, iunbakedmodel, ibakedmodel, (ModelBakery)(Object)this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.dynamic_resources.ae2;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.init.client.InitAutoRotatingModel;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.embeddedt.modernfix.dynamicresources.DynamicModelBakeEvent;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(InitAutoRotatingModel.class)
|
||||
public class RegistrationMixin {
|
||||
@Shadow @Final private static Map<String, Function<BakedModel, BakedModel>> CUSTOMIZERS;
|
||||
@Inject(method = "init", at = @At("TAIL"), remap = false)
|
||||
private static void doRegisterDynBake(CallbackInfo ci) {
|
||||
MinecraftForge.EVENT_BUS.addListener(RegistrationMixin::onDynamicModelBake);
|
||||
}
|
||||
|
||||
private static void onDynamicModelBake(DynamicModelBakeEvent event) {
|
||||
if (!event.getLocation().getNamespace().equals(AppEng.MOD_ID)) {
|
||||
return;
|
||||
}
|
||||
BakedModel missing = event.getModelLoader().getBakedTopLevelModels().get(ModelBakery.MISSING_MODEL_LOCATION);
|
||||
if(event.getModel() == missing)
|
||||
return;
|
||||
Function<BakedModel, BakedModel> customizerFn = CUSTOMIZERS.get(event.getLocation().getPath());
|
||||
if(customizerFn != null)
|
||||
event.setModel(customizerFn.apply(event.getModel()));
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@
|
|||
"perf.dynamic_resources.BlockModelShaperMixin",
|
||||
"perf.dynamic_resources.ItemModelShaperMixin",
|
||||
"perf.dynamic_resources.ModelBakeryMixin",
|
||||
"perf.dynamic_resources.ae2.RegistrationMixin",
|
||||
"perf.dynamic_resources.ctm.TextureMetadataHandlerMixin",
|
||||
"perf.dynamic_resources.ctm.CTMPackReloadListenerMixin",
|
||||
"perf.dynamic_resources.supermartijncore.ClientRegistrationHandlerMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user