Merge remote-tracking branch 'origin/main' into 1.18
This commit is contained in:
commit
49a0b56b74
|
|
@ -96,6 +96,7 @@ dependencies {
|
||||||
modCompileOnly("dev.latvian.mods:kubejs-forge:${kubejs_version}")
|
modCompileOnly("dev.latvian.mods:kubejs-forge:${kubejs_version}")
|
||||||
modRuntimeOnly("curse.maven:ferritecore-429235:4074294")
|
modRuntimeOnly("curse.maven:ferritecore-429235:4074294")
|
||||||
modCompileOnly("team.chisel.ctm:CTM:${ctm_version}")
|
modCompileOnly("team.chisel.ctm:CTM:${ctm_version}")
|
||||||
|
modCompileOnly("curse.maven:supermartijncore-454372:4455378")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.perf.dynamic_resources.supermartijncore;
|
||||||
|
|
||||||
|
import com.supermartijn642.core.registry.ClientRegistrationHandler;
|
||||||
|
import com.supermartijn642.core.util.Pair;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
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.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@Mixin(ClientRegistrationHandler.class)
|
||||||
|
public class ClientRegistrationHandlerMixin {
|
||||||
|
@Shadow @Final private List<Pair<Supplier<Stream<ResourceLocation>>, Function<BakedModel, BakedModel>>> modelOverwrites;
|
||||||
|
|
||||||
|
private Map<ResourceLocation, Function<BakedModel, BakedModel>> modelOverwritesByLocation = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
@Redirect(method = "handleModelBakeEvent", at = @At(value = "FIELD", target = "Lcom/supermartijn642/core/registry/ClientRegistrationHandler;modelOverwrites:Ljava/util/List;"), remap = false)
|
||||||
|
private List<?> skipModelOverwrites(ClientRegistrationHandler h) {
|
||||||
|
modelOverwritesByLocation.clear();
|
||||||
|
for(Pair<Supplier<Stream<ResourceLocation>>, Function<BakedModel, BakedModel>> pair : this.modelOverwrites) {
|
||||||
|
Stream<ResourceLocation> locationStream = pair.left().get();
|
||||||
|
Function<BakedModel, BakedModel> swapper = pair.right();
|
||||||
|
locationStream.forEach(l -> {
|
||||||
|
modelOverwritesByLocation.put(l, swapper);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
|
private void registerDynBake(String modid, CallbackInfo ci) {
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onDynamicModelBake);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onDynamicModelBake(DynamicModelBakeEvent event) {
|
||||||
|
Function<BakedModel, BakedModel> replacer = modelOverwritesByLocation.get(event.getLocation());
|
||||||
|
if(replacer != null)
|
||||||
|
event.setModel(replacer.apply(event.getModel()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
"perf.dynamic_resources.ModelBakeryMixin",
|
"perf.dynamic_resources.ModelBakeryMixin",
|
||||||
"perf.dynamic_resources.ctm.TextureMetadataHandlerMixin",
|
"perf.dynamic_resources.ctm.TextureMetadataHandlerMixin",
|
||||||
"perf.dynamic_resources.ctm.CTMPackReloadListenerMixin",
|
"perf.dynamic_resources.ctm.CTMPackReloadListenerMixin",
|
||||||
|
"perf.dynamic_resources.supermartijncore.ClientRegistrationHandlerMixin",
|
||||||
"perf.model_optimizations.OBJLoaderMixin",
|
"perf.model_optimizations.OBJLoaderMixin",
|
||||||
"perf.model_optimizations.SelectorMixin",
|
"perf.model_optimizations.SelectorMixin",
|
||||||
"perf.model_optimizations.TransformationMatrixMixin",
|
"perf.model_optimizations.TransformationMatrixMixin",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user