Merge remote-tracking branch 'origin/1.19.4' into 1.20
This commit is contained in:
commit
fa17a5f745
|
|
@ -274,7 +274,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
public BakedModel bakeDefault(ResourceLocation modelLocation, ModelState state) {
|
public BakedModel bakeDefault(ResourceLocation modelLocation, ModelState state) {
|
||||||
ModelBakery self = (ModelBakery) (Object) this;
|
ModelBakery self = (ModelBakery) (Object) this;
|
||||||
ModelBaker theBaker = self.new ModelBakerImpl(textureGetter, modelLocation);
|
ModelBaker theBaker = self.new ModelBakerImpl(textureGetter, modelLocation);
|
||||||
return theBaker.bake(modelLocation, state);
|
return theBaker.bake(modelLocation, state, theBaker.getModelTextureGetter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,27 @@
|
||||||
package org.embeddedt.modernfix.forge.mixin.perf.dynamic_resources.ctm;
|
package org.embeddedt.modernfix.forge.mixin.perf.dynamic_resources.ctm;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.resources.model.*;
|
import net.minecraft.client.resources.model.*;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.embeddedt.modernfix.ModernFixClient;
|
import org.embeddedt.modernfix.ModernFixClient;
|
||||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
import org.embeddedt.modernfix.annotation.RequiresMod;
|
import org.embeddedt.modernfix.annotation.RequiresMod;
|
||||||
import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration;
|
import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration;
|
||||||
import org.embeddedt.modernfix.api.helpers.ModelHelpers;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import team.chisel.ctm.CTM;
|
import team.chisel.ctm.CTM;
|
||||||
|
import team.chisel.ctm.api.model.IModelCTM;
|
||||||
|
import team.chisel.ctm.client.mixin.ModelBakerImplAccessor;
|
||||||
import team.chisel.ctm.client.model.AbstractCTMBakedModel;
|
import team.chisel.ctm.client.model.AbstractCTMBakedModel;
|
||||||
|
import team.chisel.ctm.client.model.ModelCTM;
|
||||||
import team.chisel.ctm.client.texture.IMetadataSectionCTM;
|
import team.chisel.ctm.client.texture.IMetadataSectionCTM;
|
||||||
import team.chisel.ctm.client.util.ResourceUtil;
|
import team.chisel.ctm.client.util.ResourceUtil;
|
||||||
import team.chisel.ctm.client.util.TextureMetadataHandler;
|
import team.chisel.ctm.client.util.TextureMetadataHandler;
|
||||||
|
|
@ -22,20 +29,23 @@ import team.chisel.ctm.client.util.TextureMetadataHandler;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
@Mixin(TextureMetadataHandler.class)
|
@Mixin(TextureMetadataHandler.class)
|
||||||
@RequiresMod("ctm")
|
@RequiresMod("ctm")
|
||||||
@ClientOnlyMixin
|
@ClientOnlyMixin
|
||||||
public abstract class TextureMetadataHandlerMixin implements ModernFixClientIntegration {
|
public abstract class TextureMetadataHandlerMixin implements ModernFixClientIntegration {
|
||||||
|
|
||||||
@Shadow @Nonnull protected abstract BakedModel wrap(ResourceLocation loc, UnbakedModel model, BakedModel object, ModelBaker loader) throws IOException;
|
@Shadow @Nonnull protected abstract BakedModel wrap(UnbakedModel model, BakedModel object) throws IOException;
|
||||||
|
|
||||||
|
@Shadow @Final public static Multimap<ResourceLocation, Material> TEXTURES_SCRAPED;
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void subscribeDynamic(CallbackInfo ci) {
|
private void subscribeDynamic(CallbackInfo ci) {
|
||||||
ModernFixClient.CLIENT_INTEGRATIONS.add(this);
|
ModernFixClient.CLIENT_INTEGRATIONS.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onModelBake", at = @At("HEAD"), cancellable = true, remap = false)
|
@Inject(method = { "onModelBake(Lnet/minecraftforge/client/event/ModelEvent$ModifyBakingResult;)V", "onModelBake(Lnet/minecraftforge/client/event/ModelEvent$BakingCompleted;)V" }, at = @At("HEAD"), cancellable = true, remap = false)
|
||||||
private void noIteration(CallbackInfo ci) {
|
private void noIteration(CallbackInfo ci) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
@ -59,8 +69,7 @@ public abstract class TextureMetadataHandlerMixin implements ModernFixClientInte
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO port
|
Collection<Material> textures = Sets.newHashSet(TEXTURES_SCRAPED.get(dep));
|
||||||
Collection<Material> textures = Collections.emptyList(); // model.getMaterials(event.getModelLoader()::getModel, errors);
|
|
||||||
Collection<ResourceLocation> newDependencies = model.getDependencies();
|
Collection<ResourceLocation> newDependencies = model.getDependencies();
|
||||||
for (Material tex : textures) {
|
for (Material tex : textures) {
|
||||||
IMetadataSectionCTM meta = null;
|
IMetadataSectionCTM meta = null;
|
||||||
|
|
@ -82,7 +91,8 @@ public abstract class TextureMetadataHandlerMixin implements ModernFixClientInte
|
||||||
}
|
}
|
||||||
if (shouldWrap) {
|
if (shouldWrap) {
|
||||||
try {
|
try {
|
||||||
baked = wrap(rl, rootModel, baked, ModelHelpers.adaptBakery(bakery));
|
baked = wrap(rootModel, baked);
|
||||||
|
handleInit(rl, baked, bakery);
|
||||||
dependencies.clear();
|
dependencies.clear();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CTM.logger.error("Could not wrap model " + rl + ". Aborting...", e);
|
CTM.logger.error("Could not wrap model " + rl + ". Aborting...", e);
|
||||||
|
|
@ -91,4 +101,21 @@ public abstract class TextureMetadataHandlerMixin implements ModernFixClientInte
|
||||||
}
|
}
|
||||||
return baked;
|
return baked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleInit(ResourceLocation key, BakedModel wrappedModel, ModelBakery bakery) {
|
||||||
|
if(wrappedModel instanceof AbstractCTMBakedModel baked) {
|
||||||
|
IModelCTM var10 = baked.getModel();
|
||||||
|
if (var10 instanceof ModelCTM ctmModel) {
|
||||||
|
if (!ctmModel.isInitialized()) {
|
||||||
|
Function<Material, TextureAtlasSprite> spriteGetter = (m) -> {
|
||||||
|
return Minecraft.getInstance().getModelManager().getAtlas(m.atlasLocation()).getSprite(m.texture());
|
||||||
|
};
|
||||||
|
ModelBakery.ModelBakerImpl baker = ModelBakerImplAccessor.createImpl(bakery, ($, m) -> {
|
||||||
|
return spriteGetter.apply(m);
|
||||||
|
}, key);
|
||||||
|
ctmModel.bake(baker, spriteGetter, BlockModelRotation.X0_Y0, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ parchment_version=2023.07.09
|
||||||
refined_storage_version=4392788
|
refined_storage_version=4392788
|
||||||
jei_version=13.1.0.2
|
jei_version=13.1.0.2
|
||||||
rei_version=11.0.597
|
rei_version=11.0.597
|
||||||
ctm_version=1.19.2-1.1.7+11
|
ctm_version=1.19.3-1.1.7+14
|
||||||
kubejs_version=1902.6.0-build.142
|
kubejs_version=1902.6.0-build.142
|
||||||
rhino_version=1902.2.2-build.268
|
rhino_version=1902.2.2-build.268
|
||||||
supported_minecraft_versions=1.20.1
|
supported_minecraft_versions=1.20.1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user