Fix some bugs

This commit is contained in:
embeddedt 2023-03-04 19:21:49 -05:00
parent 6d7a450ec8
commit 1c2a2c65ad
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 17 additions and 10 deletions

View File

@ -27,8 +27,6 @@ public class ModernFixConfig {
public static ForgeConfigSpec.BooleanValue REBUILD_BLOCKSTATES_ASYNC;
public static ForgeConfigSpec.ConfigValue<List<? extends String>> MODELS_TO_BAKE;
public static Set<ResourceLocation> jeiPluginBlacklist;
static {
@ -45,9 +43,6 @@ public class ModernFixConfig {
REBUILD_BLOCKSTATES_ASYNC = COMMON_BUILDER
.comment("Rebuild blockstate cache asynchronously. Should work with most mods, but can be disabled.")
.define("rebuild_blockstate_cache_async", true);
MODELS_TO_BAKE = COMMON_BUILDER
.comment("List of additional mod IDs for which models should be baked at resource reload time")
.defineList("models_to_bake_early", Collections.emptyList(), o -> o instanceof String);
}
static {

View File

@ -100,7 +100,6 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
Collection<String> modsListening = ModUtil.findAllModsListeningToEvent(ModelBakeEvent.class);
LOGGER.debug("Found ModelBakeEvent listeners: [" + String.join(", ", modsListening) + "]");
Set<String> incompatibleLazyBakedModels = ImmutableSet.<String>builder()
.addAll(ModernFixConfig.MODELS_TO_BAKE.get())
.addAll(modsListening)
.build();
/* First, bake any incompatible models ahead of time (for mods that have custom models) */

View File

@ -3,11 +3,16 @@ package org.embeddedt.modernfix.mixin.perf.faster_texture_stitching;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraftforge.fml.ModLoader;
import org.embeddedt.modernfix.ModernFix;
import org.embeddedt.modernfix.textures.StbStitcher;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
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.Arrays;
import java.util.Comparator;
@ -29,8 +34,13 @@ public class StitcherMixin {
* @author embeddedt, SuperCoder79
* @reason Use improved STB stitcher instead of the vanilla implementation, for performance
*/
@Overwrite
public void stitch() {
@Inject(method = "stitch", at = @At("HEAD"), cancellable = true)
private void stitchFast(CallbackInfo ci) {
if(!ModLoader.isLoadingStateValid()) {
ModernFix.LOGGER.error("Using vanilla stitcher implementation due to invalid loading state");
return;
}
ci.cancel();
ObjectArrayList<Stitcher.Holder> holderList = new ObjectArrayList<>(this.texturesToBeStitched);
holderList.sort(HOLDER_COMPARATOR);
Stitcher.Holder[] aholder = holderList.toArray(new Stitcher.Holder[0]);
@ -45,8 +55,11 @@ public class StitcherMixin {
* @author embeddedt, SuperCoder79
* @reason We setup the image ourselves in the StbStitcher, so we just feed this information back into the vanilla code
*/
@Overwrite
public void gatherSprites(Stitcher.SpriteLoader spriteLoader) {
@Inject(method = "gatherSprites", at = @At("HEAD"), cancellable = true)
private void gatherSpritesFast(Stitcher.SpriteLoader spriteLoader, CallbackInfo ci) {
if(!ModLoader.isLoadingStateValid())
return;
ci.cancel();
for(StbStitcher.LoadableSpriteInfo info : loadableSpriteInfos) {
spriteLoader.load(info.info, info.width, info.height, info.x, info.y);
}