diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-07 13:26:03 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-07 13:26:03 +0100 |
commit | bf7795df22ca7892fae1238403feebb57c005562 (patch) | |
tree | 3a49db5bade38498f976321b6e9008203f2d4d3b /src/main/java/moe/nea/firmament/mixins/custommodels | |
parent | cdb5e60f52eea9030af9ca2d4a49913664023965 (diff) | |
download | Firmament-bf7795df22ca7892fae1238403feebb57c005562.tar.gz Firmament-bf7795df22ca7892fae1238403feebb57c005562.tar.bz2 Firmament-bf7795df22ca7892fae1238403feebb57c005562.zip |
WIP: Port to compilation on 1.21.4
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/custommodels')
21 files changed, 0 insertions, 838 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ApplyHeadModelInItemRenderer.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ApplyHeadModelInItemRenderer.java deleted file mode 100644 index dac65fe..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ApplyHeadModelInItemRenderer.java +++ /dev/null @@ -1,35 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ModelTransformationMode; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ItemRenderer.class) -public class ApplyHeadModelInItemRenderer { - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;ZF)V", - at = @At("HEAD")) - private void applyHeadModel(ItemStack stack, ModelTransformationMode transformationMode, boolean leftHanded, - MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, - BakedModel model, boolean useInventoryModel, float z, CallbackInfo ci, - @Local(argsOnly = true) LocalRef<BakedModel> modelMut - ) { - var extra = BakedModelExtra.cast(model); - if (transformationMode == ModelTransformationMode.HEAD && extra != null) { - var headModel = extra.getHeadModel_firmament(); - if (headModel != null) { - modelMut.set(headModel); - } - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBasic.java b/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBasic.java deleted file mode 100644 index 3ed2177..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBasic.java +++ /dev/null @@ -1,42 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import moe.nea.firmament.features.texturepack.TintOverrides; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BasicBakedModel; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(BasicBakedModel.class) -public class BakedModelDataHolderBasic implements BakedModelExtra { - - @Unique - private BakedModel headModel; - - @Unique - @Nullable - private TintOverrides tintOverrides; - - @Nullable - @Override - public BakedModel getHeadModel_firmament() { - return headModel; - } - - @Override - public void setHeadModel_firmament(@Nullable BakedModel headModel) { - this.headModel = headModel; - } - - @Override - public @Nullable TintOverrides getTintOverrides_firmament() { - return tintOverrides; - } - - @Override - public void setTintOverrides_firmament(@Nullable TintOverrides tintOverrides) { - this.tintOverrides = tintOverrides; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBuiltin.java b/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBuiltin.java deleted file mode 100644 index 87aecb1..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedModelDataHolderBuiltin.java +++ /dev/null @@ -1,43 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import moe.nea.firmament.features.texturepack.TintOverrides; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BuiltinBakedModel; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(BuiltinBakedModel.class) -public class BakedModelDataHolderBuiltin implements BakedModelExtra { - - @Unique - @Nullable - private BakedModel headModel; - - @Unique - @Nullable - private TintOverrides tintOverrides; - - @Override - public @Nullable TintOverrides getTintOverrides_firmament() { - return tintOverrides; - } - - @Override - public void setTintOverrides_firmament(@Nullable TintOverrides tintOverrides) { - this.tintOverrides = tintOverrides; - } - - @Nullable - @Override - public BakedModel getHeadModel_firmament() { - return headModel; - } - - @Override - public void setHeadModel_firmament(@Nullable BakedModel headModel) { - this.headModel = headModel; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedOverrideDataHolder.java b/src/main/java/moe/nea/firmament/mixins/custommodels/BakedOverrideDataHolder.java deleted file mode 100644 index 26972b1..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/BakedOverrideDataHolder.java +++ /dev/null @@ -1,28 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.BakedOverrideData; -import moe.nea.firmament.features.texturepack.FirmamentModelPredicate; -import net.minecraft.client.render.model.json.ModelOverrideList; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(ModelOverrideList.BakedOverride.class) -public class BakedOverrideDataHolder implements BakedOverrideData { - - @Unique - private FirmamentModelPredicate[] firmamentOverrides; - - @Nullable - @Override - public FirmamentModelPredicate[] getFirmamentOverrides() { - return firmamentOverrides; - } - - @Override - public void setFirmamentOverrides(@NotNull FirmamentModelPredicate[] overrides) { - this.firmamentOverrides = overrides; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/HeadModelReplacerPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/HeadModelReplacerPatch.java deleted file mode 100644 index 26c331e..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/HeadModelReplacerPatch.java +++ /dev/null @@ -1,57 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import net.minecraft.block.AbstractSkullBlock; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.client.render.entity.feature.HeadFeatureRenderer; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.model.ModelWithHead; -import net.minecraft.client.render.entity.state.LivingEntityRenderState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(HeadFeatureRenderer.class) -public class HeadModelReplacerPatch<S extends LivingEntityRenderState, M extends EntityModel<S> & ModelWithHead> { - /** - * This class serves to disable the replacing of head models with the vanilla block model. Vanilla first selects loads - * the model containing the head model regularly in {@link LivingEntityRenderer#updateRenderState}, but then discards - * the model in {@link HeadFeatureRenderer#render(MatrixStack, VertexConsumerProvider, int, LivingEntityRenderState, float, float)} - * if it detects a skull block. This serves to disable that functionality if a head model override is present. - */ - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/LivingEntityRenderState;FF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BlockItem;getBlock()Lnet/minecraft/block/Block;")) - private Block replaceSkull(BlockItem instance, Operation<Block> original, @Local BakedModel bakedModel) { - var oldBlock = original.call(instance); - if (oldBlock instanceof AbstractSkullBlock) { - var extra = BakedModelExtra.cast(bakedModel); - if (extra != null && extra.getHeadModel_firmament() != null) - return Blocks.ENCHANTING_TABLE; // Any non skull block. Let's choose the enchanting table because it is very distinct. - } - return oldBlock; - } - - /** - * We disable the has model override, since texture packs get precedent to server data. - */ - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/LivingEntityRenderState;FF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/feature/ArmorFeatureRenderer;hasModel(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/EquipmentSlot;)Z")) - private boolean replaceHasModel(ItemStack stack, EquipmentSlot slot, Operation<Boolean> original, - @Local BakedModel bakedModel) { - var extra = BakedModelExtra.cast(bakedModel); - if (extra != null && extra.getHeadModel_firmament() != null) - return false; - return original.call(stack, slot); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemColorRemovalPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ItemColorRemovalPatch.java deleted file mode 100644 index 8c76c60..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemColorRemovalPatch.java +++ /dev/null @@ -1,39 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.TintOverrides; -import moe.nea.firmament.init.ItemColorsSodiumRiser; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.client.color.item.ItemColors; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ItemColors.class) -public class ItemColorRemovalPatch { - - /** - * @see ItemColorsSodiumRiser - */ - private @Nullable ItemColorProvider overrideSodium_firmament(@Nullable ItemColorProvider original) { - var tintOverrides = TintOverrides.Companion.getCurrentOverrides(); - if (!tintOverrides.hasOverrides()) return original; - return (stack, tintIndex) -> { - var override = tintOverrides.getOverride(tintIndex); - if (override != null) return override; - if (original != null) return original.getColor(stack, tintIndex); - return -1; - }; - } - - - @Inject(method = "getColor", at = @At("HEAD"), cancellable = true) - private void overrideGetColorCall(ItemStack item, int tintIndex, CallbackInfoReturnable<Integer> cir) { - var tintOverrides = TintOverrides.Companion.getCurrentOverrides(); - var override = tintOverrides.getOverride(tintIndex); - if (override != null) - cir.setReturnValue(override); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemModelGeneratorJsonUnbakedModelCopy.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ItemModelGeneratorJsonUnbakedModelCopy.java deleted file mode 100644 index 89d0411..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemModelGeneratorJsonUnbakedModelCopy.java +++ /dev/null @@ -1,22 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra; -import net.minecraft.client.render.model.json.ItemModelGenerator; -import net.minecraft.client.render.model.json.JsonUnbakedModel; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ItemModelGenerator.class) -public class ItemModelGeneratorJsonUnbakedModelCopy { - @ModifyReturnValue(method = "create", at = @At("RETURN")) - private JsonUnbakedModel copyExtraModelData(JsonUnbakedModel original, @Local(argsOnly = true) JsonUnbakedModel oldModel) { - var extra = ((JsonUnbakedModelFirmExtra) original); - var oldExtra = ((JsonUnbakedModelFirmExtra) oldModel); - extra.setHeadModel_firmament(oldExtra.getHeadModel_firmament()); - extra.setTintOverrides_firmament(oldExtra.getTintOverrides_firmament()); - return original; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemRendererTintContextPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ItemRendererTintContextPatch.java deleted file mode 100644 index 8c5411b..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ItemRendererTintContextPatch.java +++ /dev/null @@ -1,35 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import moe.nea.firmament.features.texturepack.TintOverrides; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ModelTransformationMode; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = ItemRenderer.class, priority = 1010) -public class ItemRendererTintContextPatch { - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;ZF)V", - at = @At(value = "HEAD"), allow = 1) - private void onStartRendering(ItemStack stack, ModelTransformationMode transformationMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, boolean useInventoryModel, float z, CallbackInfo ci) { - var extra = BakedModelExtra.cast(model); - if (extra != null) { - TintOverrides.Companion.enter(extra.getTintOverrides_firmament()); - } - } - - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;ZF)V", - at = @At("TAIL"), allow = 1) - private void onEndRendering(ItemStack stack, ModelTransformationMode transformationMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, boolean useInventoryModel, float z, CallbackInfo ci) { - var extra = BakedModelExtra.cast(model); - if (extra != null) { - TintOverrides.Companion.exit(extra.getTintOverrides_firmament()); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java b/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java deleted file mode 100644 index a5bb34f..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java +++ /dev/null @@ -1,130 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.BakedModelExtra; -import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra; -import moe.nea.firmament.features.texturepack.TintOverrides; -import moe.nea.firmament.util.ErrorUtil; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.Baker; -import net.minecraft.client.render.model.ModelRotation; -import net.minecraft.client.render.model.UnbakedModel; -import net.minecraft.client.render.model.json.JsonUnbakedModel; -import net.minecraft.util.Identifier; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -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.Objects; - -@Mixin(JsonUnbakedModel.class) -public abstract class JsonUnbakedModelDataHolder implements JsonUnbakedModelFirmExtra { - @Shadow - @Nullable - protected JsonUnbakedModel parent; - - @Shadow - public abstract String toString(); - - @Unique - @Nullable - public Identifier headModel; - @Unique - @Nullable - public TintOverrides tintOverrides; - @Unique - @Nullable - public TintOverrides mergedTintOverrides; - - @Override - public void setTintOverrides_firmament(@Nullable TintOverrides tintOverrides) { - this.tintOverrides = tintOverrides; - this.mergedTintOverrides = null; - } - - @Override - public @NotNull TintOverrides getTintOverrides_firmament() { - if (mergedTintOverrides != null) - return mergedTintOverrides; - var mergedTintOverrides = parent == null ? new TintOverrides() - : ((JsonUnbakedModelFirmExtra) parent).getTintOverrides_firmament(); - if (tintOverrides != null) - mergedTintOverrides = tintOverrides.mergeWithParent(mergedTintOverrides); - this.mergedTintOverrides = mergedTintOverrides; - return mergedTintOverrides; - } - - @Override - public void setHeadModel_firmament(@Nullable Identifier identifier) { - this.headModel = identifier; - } - - @Override - public @Nullable Identifier getHeadModel_firmament() { - if (this.headModel != null) return this.headModel; - if (this.parent == null) return null; - return ((JsonUnbakedModelFirmExtra) this.parent).getHeadModel_firmament(); - } - - @Inject(method = "resolve", at = @At("HEAD")) - private void addDependencies(UnbakedModel.Resolver resolver, CallbackInfo ci) { - var headModel = getHeadModel_firmament(); - if (headModel != null) { - resolver.resolve(headModel); - } - } - - private void addExtraBakeInfo(BakedModel bakedModel, Baker baker) { - if (!this.toString().contains("minecraft") && this.toString().contains("crimson")) { - System.out.println("Found non minecraft model " + this); - } - var extra = BakedModelExtra.cast(bakedModel); - if (extra != null) { - var headModel = getHeadModel_firmament(); - if (headModel != null) { - extra.setHeadModel_firmament(baker.bake(headModel, ModelRotation.X0_Y0)); - } - if (getTintOverrides_firmament().hasOverrides()) { - extra.setTintOverrides_firmament(getTintOverrides_firmament()); - } - } - } - - /** - * @see ProvideBakerToJsonUnbakedModelPatch - */ - @Override - public void storeExtraBaker_firmament(@NotNull Baker baker) { - this.storedBaker = baker; - } - - @Unique - private Baker storedBaker; - - @ModifyReturnValue( - method = "bake(Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;Z)Lnet/minecraft/client/render/model/BakedModel;", - at = @At("RETURN")) - private BakedModel bakeExtraInfoWithoutBaker(BakedModel original) { - if (storedBaker != null) { - addExtraBakeInfo(original, storedBaker); - storedBaker = null; - } - return original; - } - - @ModifyReturnValue( - method = { - "bake(Lnet/minecraft/client/render/model/Baker;Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;" - }, - at = @At(value = "RETURN")) - private BakedModel bakeExtraInfo(BakedModel original, @Local(argsOnly = true) Baker baker) { - addExtraBakeInfo(original, baker); - return original; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ModelOverrideDataHolder.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ModelOverrideDataHolder.java deleted file mode 100644 index 5f9689a..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ModelOverrideDataHolder.java +++ /dev/null @@ -1,28 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.FirmamentModelPredicate; -import moe.nea.firmament.features.texturepack.ModelOverrideData; -import net.minecraft.client.render.model.json.ModelOverride; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(ModelOverride.class) -public class ModelOverrideDataHolder implements ModelOverrideData { - - @Unique - private FirmamentModelPredicate[] overrides; - - @Nullable - @Override - public FirmamentModelPredicate[] getFirmamentOverrides() { - return overrides; - } - - @Override - public void setFirmamentOverrides(@NotNull FirmamentModelPredicate[] overrides) { - this.overrides = overrides; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java deleted file mode 100644 index 4468150..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java +++ /dev/null @@ -1,29 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.CustomGlobalArmorOverrides; -import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; -import net.minecraft.component.type.EquippableComponent; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.Optional; - -@Mixin(ArmorFeatureRenderer.class) -public class PatchArmorTexture { - @WrapOperation( - method = "renderArmor", - at = @At(value = "INVOKE", target = "Lnet/minecraft/component/type/EquippableComponent;model()Ljava/util/Optional;")) - private Optional<Identifier> overrideLayers( - EquippableComponent instance, Operation<Optional<Identifier>> original, @Local(argsOnly = true) ItemStack itemStack - ) { - // TODO: check that all armour items are naturally equippable and have the equppable component. otherwise our call here will not be reached. - var overrides = CustomGlobalArmorOverrides.overrideArmor(itemStack); - return overrides.or(() -> original.call(instance)); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java deleted file mode 100644 index d6c25b5..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java +++ /dev/null @@ -1,31 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra; -import moe.nea.firmament.features.texturepack.TintOverrides; -import net.minecraft.client.render.model.json.JsonUnbakedModel; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(JsonUnbakedModel.Deserializer.class) -public class PatchJsonUnbakedModelDeserializer { - @ModifyReturnValue(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/render/model/json/JsonUnbakedModel;", - at = @At("RETURN")) - private JsonUnbakedModel addHeadModel(JsonUnbakedModel original, @Local JsonObject jsonObject) { - var headModel = jsonObject.get("firmament:head_model"); - var extra = ((JsonUnbakedModelFirmExtra) original); - if (headModel instanceof JsonPrimitive prim && prim.isString()) { - extra.setHeadModel_firmament(Identifier.of(prim.getAsString())); - } - var tintOverrides = jsonObject.get("firmament:tint_overrides"); - if (tintOverrides instanceof JsonObject object) { - extra.setTintOverrides_firmament(TintOverrides.Companion.parse(object)); - } - return original; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchLegacyArmorLayerSupport.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchLegacyArmorLayerSupport.java deleted file mode 100644 index 8c0b3f8..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchLegacyArmorLayerSupport.java +++ /dev/null @@ -1,22 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import moe.nea.firmament.features.texturepack.CustomGlobalArmorOverrides; -import net.minecraft.client.render.entity.equipment.EquipmentModelLoader; -import net.minecraft.client.render.entity.equipment.EquipmentRenderer; -import net.minecraft.item.equipment.EquipmentModel; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(EquipmentRenderer.class) -public class PatchLegacyArmorLayerSupport { - @WrapOperation(method = "render(Lnet/minecraft/item/equipment/EquipmentModel$LayerType;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/model/Model;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Identifier;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/equipment/EquipmentModelLoader;get(Lnet/minecraft/util/Identifier;)Lnet/minecraft/item/equipment/EquipmentModel;")) - private EquipmentModel patchModelLayers(EquipmentModelLoader instance, Identifier id, Operation<EquipmentModel> original) { - var modelOverride = CustomGlobalArmorOverrides.overrideArmorLayer(id); - if (modelOverride != null) return modelOverride; - return original.call(instance, id); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchOverrideDeserializer.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchOverrideDeserializer.java deleted file mode 100644 index abb1792..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchOverrideDeserializer.java +++ /dev/null @@ -1,50 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.CustomModelOverrideParser; -import moe.nea.firmament.features.texturepack.ModelOverrideData; -import net.minecraft.client.render.model.json.ModelOverride; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; -import java.util.Map; - -@Mixin(ModelOverride.Deserializer.class) -public class PatchOverrideDeserializer { - - @ModifyReturnValue( - method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/render/model/json/ModelOverride;", - at = @At(value = "RETURN")) - private ModelOverride addCustomOverrides(ModelOverride original, @Local JsonObject jsonObject) { - var originalData = (ModelOverrideData) (Object) original; - originalData.setFirmamentOverrides(CustomModelOverrideParser.parseCustomModelOverrides(jsonObject)); - return original; - } - - @ModifyExpressionValue( - method = "deserializeMinPropertyValues(Lcom/google/gson/JsonObject;)Ljava/util/List;", - at = @At(value = "INVOKE", target = "Ljava/util/Map$Entry;getValue()Ljava/lang/Object;")) - private Object removeFirmamentPredicatesFromJsonIteration(Object original, @Local Map.Entry<String, JsonElement> entry) { - if (entry.getKey().startsWith("firmament:")) return new JsonPrimitive(0F); - return original; - } - - @Inject( - method = "deserializeMinPropertyValues", - at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;") - ) - private void whatever(JsonObject object, CallbackInfoReturnable<List<ModelOverride.Condition>> cir, - @Local Map<Identifier, Float> maps) { - maps.entrySet().removeIf(it -> it.getKey().getNamespace().equals("firmament")); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ProvideBakerToJsonUnbakedModelPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ProvideBakerToJsonUnbakedModelPatch.java deleted file mode 100644 index c1ac119..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ProvideBakerToJsonUnbakedModelPatch.java +++ /dev/null @@ -1,27 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.Baker; -import net.minecraft.client.render.model.ModelBakeSettings; -import net.minecraft.client.render.model.json.JsonUnbakedModel; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.SpriteIdentifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.function.Function; - -/** - * @see JsonUnbakedModelDataHolder#storeExtraBaker_firmament - */ -@Mixin(targets = "net.minecraft.client.render.model.ModelBaker$BakerImpl") -public abstract class ProvideBakerToJsonUnbakedModelPatch implements Baker { - @WrapOperation(method = "bake(Lnet/minecraft/client/render/model/UnbakedModel;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/json/JsonUnbakedModel;bake(Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;Z)Lnet/minecraft/client/render/model/BakedModel;")) - private BakedModel provideExtraBakerToModel(JsonUnbakedModel instance, Function<SpriteIdentifier, Sprite> function, ModelBakeSettings modelBakeSettings, boolean bl, Operation<BakedModel> original) { - ((JsonUnbakedModelFirmExtra) instance).storeExtraBaker_firmament(this); - return original.call(instance, function, modelBakeSettings, bl); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java deleted file mode 100644 index bb9cd10..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java +++ /dev/null @@ -1,36 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.events.BakeExtraModelsEvent; -import net.minecraft.client.render.model.BlockStatesLoader; -import net.minecraft.client.render.model.ItemModel; -import net.minecraft.client.render.model.ReferencedModelsCollector; -import net.minecraft.client.render.model.UnbakedModel; -import net.minecraft.client.util.ModelIdentifier; -import net.minecraft.util.Identifier; -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; - -@Mixin(ReferencedModelsCollector.class) -public abstract class ReferenceCustomModelsPatch { - @Shadow - protected abstract void addTopLevelModel(ModelIdentifier modelId, UnbakedModel model); - - @Shadow - @Final - private Map<Identifier, UnbakedModel> inputs; - - @Inject(method = "addBlockStates", at = @At("RETURN")) - private void addFirmamentReferencedModels( - BlockStatesLoader.BlockStateDefinition definition, CallbackInfo ci - ) { - BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent( - (modelIdentifier, identifier) -> addTopLevelModel(modelIdentifier, new ItemModel(identifier)))); - - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockBreakSoundPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockBreakSoundPatch.java deleted file mode 100644 index 9401889..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockBreakSoundPatch.java +++ /dev/null @@ -1,27 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.CustomBlockTextures; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(WorldRenderer.class) -public class ReplaceBlockBreakSoundPatch { -// Sadly hypixel does not send a world event here and instead plays the sound on the server directly -// @WrapOperation(method = "processWorldEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/sound/BlockSoundGroup;getBreakSound()Lnet/minecraft/sound/SoundEvent;")) -// private SoundEvent replaceBreakSoundEvent(BlockSoundGroup instance, Operation<SoundEvent> original, -// @Local(argsOnly = true) BlockPos pos, @Local BlockState blockState) { -// var replacement = CustomBlockTextures.getReplacement(blockState, pos); -// if (replacement != null && replacement.getSound() != null) { -// return SoundEvent.of(replacement.getSound()); -// } -// return original.call(instance); -// } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockHitSoundPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockHitSoundPatch.java deleted file mode 100644 index f9a1d0d..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockHitSoundPatch.java +++ /dev/null @@ -1,30 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.CustomBlockTextures; -import net.minecraft.block.BlockState; -import net.minecraft.client.network.ClientPlayerInteractionManager; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ClientPlayerInteractionManager.class) -public class ReplaceBlockHitSoundPatch { - @WrapOperation(method = "updateBlockBreakingProgress", at = @At(value = "NEW", target = "(Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FFLnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/client/sound/PositionedSoundInstance;")) - private PositionedSoundInstance replaceSound( - SoundEvent sound, SoundCategory category, float volume, float pitch, - Random random, BlockPos pos, Operation<PositionedSoundInstance> original, - @Local BlockState blockState) { - var replacement = CustomBlockTextures.getReplacement(blockState, pos); - if (replacement != null && replacement.getSound() != null) { - sound = SoundEvent.of(replacement.getSound()); - } - return original.call(sound, category, volume, pitch, random, pos); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockRenderManagerBlockModel.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockRenderManagerBlockModel.java deleted file mode 100644 index 711b2af..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceBlockRenderManagerBlockModel.java +++ /dev/null @@ -1,38 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.features.texturepack.CustomBlockTextures; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.block.BlockModels; -import net.minecraft.client.render.block.BlockRenderManager; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(BlockRenderManager.class) -public class ReplaceBlockRenderManagerBlockModel { - @WrapOperation(method = "renderBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockRenderManager;getModel(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/model/BakedModel;")) - private BakedModel replaceModelInRenderBlock( - BlockRenderManager instance, BlockState state, Operation<BakedModel> original, @Local(argsOnly = true) BlockPos pos) { - var replacement = CustomBlockTextures.getReplacementModel(state, pos); - if (replacement != null) return replacement; - CustomBlockTextures.enterFallbackCall(); - var fallback = original.call(instance, state); - CustomBlockTextures.exitFallbackCall(); - return fallback; - } - - @WrapOperation(method = "renderDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModels;getModel(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/model/BakedModel;")) - private BakedModel replaceModelInRenderDamage( - BlockModels instance, BlockState state, Operation<BakedModel> original, @Local(argsOnly = true) BlockPos pos) { - var replacement = CustomBlockTextures.getReplacementModel(state, pos); - if (replacement != null) return replacement; - CustomBlockTextures.enterFallbackCall(); - var fallback = original.call(instance, state); - CustomBlockTextures.exitFallbackCall(); - return fallback; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceFallbackBlockModel.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceFallbackBlockModel.java deleted file mode 100644 index 53ab74a..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/ReplaceFallbackBlockModel.java +++ /dev/null @@ -1,21 +0,0 @@ -package moe.nea.firmament.mixins.custommodels; - -import moe.nea.firmament.features.texturepack.CustomBlockTextures; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.block.BlockModels; -import net.minecraft.client.render.model.BakedModel; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(BlockModels.class) -public class ReplaceFallbackBlockModel { - // TODO: add check to BlockDustParticle - @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) - private void getModel(BlockState state, CallbackInfoReturnable<BakedModel> cir) { - var replacement = CustomBlockTextures.getReplacementModel(state, null); - if (replacement != null) - cir.setReturnValue(replacement); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/TestForFirmamentOverridePredicatesPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/TestForFirmamentOverridePredicatesPatch.java deleted file mode 100644 index 63f3cf0..0000000 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/TestForFirmamentOverridePredicatesPatch.java +++ /dev/null @@ -1,68 +0,0 @@ - -package moe.nea.firmament.mixins.custommodels; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import moe.nea.firmament.Firmament; -import moe.nea.firmament.features.texturepack.BakedOverrideData; -import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures; -import moe.nea.firmament.features.texturepack.FirmamentModelPredicate; -import moe.nea.firmament.features.texturepack.ModelOverrideData; -import net.minecraft.client.render.model.json.ModelOverride; -import net.minecraft.client.render.model.json.ModelOverrideList; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; -import org.objectweb.asm.Opcodes; -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.ModifyArg; - -import java.util.List; -import java.util.Objects; - -@Mixin(ModelOverrideList.class) -public class TestForFirmamentOverridePredicatesPatch { - - @Shadow - private Identifier[] conditionTypes; - - @ModifyArg(method = "<init>(Lnet/minecraft/client/render/model/Baker;Ljava/util/List;)V", - at = @At( - value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z" - )) - public Object onInit( - Object element, - @Local ModelOverride modelOverride - ) { - var bakedOverride = (ModelOverrideList.BakedOverride) element; - var modelOverrideData = ModelOverrideData.cast(modelOverride); - BakedOverrideData.cast(bakedOverride) - .setFirmamentOverrides(modelOverrideData.getFirmamentOverrides()); - if (conditionTypes.length == 0 && - modelOverrideData.getFirmamentOverrides() != null && - modelOverrideData.getFirmamentOverrides().length > 0) { - conditionTypes = new Identifier[]{Firmament.INSTANCE.identifier("sentinel/enforce_model_override_evaluation")}; - } - return element; - } - - @ModifyExpressionValue(method = "getModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/json/ModelOverrideList$BakedOverride;test([F)Z")) - public boolean testFirmamentOverrides(boolean originalValue, - @Local ModelOverrideList.BakedOverride bakedOverride, - @Local(argsOnly = true) ItemStack stack) { - if (!originalValue) return false; - var overrideData = (BakedOverrideData) (Object) bakedOverride; - var overrides = overrideData.getFirmamentOverrides(); - if (overrides == null) return true; - if (!CustomSkyBlockTextures.TConfig.INSTANCE.getEnableModelOverrides()) return false; - for (FirmamentModelPredicate firmamentOverride : overrides) { - if (!firmamentOverride.test(stack)) - return false; - } - return true; - } -} |