diff --git a/build.gradle b/build.gradle index 3378b08..f974e5e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "1.6-SNAPSHOT" + id "fabric-loom" version "1.8-SNAPSHOT" id "io.github.juuxel.loom-quiltflower" version "1.8.0" } diff --git a/gradle.properties b/gradle.properties index ae75003..23cdf1b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version = 1.21 - yarn_mappings = 1.21+build.2 - fabric_loader = 0.15.11 + minecraft_version = 1.21.3 + yarn_mappings = 1.21.3+build.2 + fabric_loader = 0.16.7 # Mod Properties - mod_version = 1.9.72 + mod_version = 2.0 maven_group = ru.tpsd.eatinganimationmod archives_base_name = eating-animation # Dependencies - fabric_api = 0.100.1+1.21 + fabric_api = 0.107.0+1.21.3 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 509c4a2..707e499 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/ru/tpsd/eatinganimationmod/EatingAnimationClientMod.java b/src/main/java/ru/tpsd/eatinganimationmod/EatingAnimationClientMod.java index 51a61e1..5e5fd34 100644 --- a/src/main/java/ru/tpsd/eatinganimationmod/EatingAnimationClientMod.java +++ b/src/main/java/ru/tpsd/eatinganimationmod/EatingAnimationClientMod.java @@ -6,25 +6,15 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.item.ModelPredicateProviderRegistry; import net.minecraft.client.network.OtherClientPlayerEntity; -import net.minecraft.component.DataComponentTypes; import net.minecraft.item.Item; -import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.registry.Registries; -import java.util.ArrayList; - public class EatingAnimationClientMod implements ClientModInitializer { - private static final ArrayList FOOD_ITEMS = new ArrayList<>(Registries.ITEM.stream().filter( - p -> p.getDefaultStack().getComponents().contains(DataComponentTypes.FOOD)).toList()); - static { - FOOD_ITEMS.add(Items.MILK_BUCKET); - } - @Override public void onInitializeClient() { - for (Item item : FOOD_ITEMS) { + for (Item item : Registries.ITEM) { ModelPredicateProviderRegistry.register(item, Identifier.of("eat"), (itemStack, clientWorld, livingEntity, i) -> { if (livingEntity == null) { return 0.0F; diff --git a/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextLegacyMixin.java b/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextLegacyMixin.java index 41ad2e3..57d9621 100644 --- a/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextLegacyMixin.java +++ b/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextLegacyMixin.java @@ -1,79 +1,78 @@ -package ru.tpsd.eatinganimationmod.mixin; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.DiffuseLighting; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.json.ModelTransformationMode; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.resource.SynchronousResourceReloader; -import net.minecraft.world.World; -import org.joml.Matrix4f; -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; - -@Mixin(DrawContext.class) -public abstract class DrawContextLegacyMixin implements SynchronousResourceReloader { - - @Shadow - @Final - private MinecraftClient client; - - @Shadow - @Final - private MatrixStack matrices; - - @Shadow - @Final - private VertexConsumerProvider.Immediate vertexConsumers; - - @Shadow - public void draw() { - RenderSystem.disableDepthTest(); - this.vertexConsumers.draw(); - RenderSystem.enableDepthTest(); - } - - @Shadow - public VertexConsumerProvider.Immediate getVertexConsumers() { - return this.vertexConsumers; - } - - @SuppressWarnings("all") - @Inject(method = "drawItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;IIII)V", at = @At("HEAD"), cancellable = true) - void innerRenderInGui(LivingEntity entity, World world, ItemStack stack, int x, int y, int seed, int z, CallbackInfo ci) { - if (!stack.isEmpty() && stack.contains(DataComponentTypes.FOOD)) { - BakedModel bakedModel = this.client.getItemRenderer().getModels().getModel(stack); - this.matrices.push(); - this.matrices.translate((float)(x + 8), (float)(y + 8), (float)(150 + (bakedModel.hasDepth() ? z : 0))); - this.matrices.multiplyPositionMatrix(new Matrix4f().scaling(1.0F, -1.0F, 1.0F)); - this.matrices.scale(16.0F, 16.0F, 16.0F); - - boolean bl = !bakedModel.isSideLit(); - if (bl) { - DiffuseLighting.disableGuiDepthLighting(); - } - - this.client - .getItemRenderer() - .renderItem(stack, ModelTransformationMode.GUI, false, this.matrices, this.getVertexConsumers(), 15728880, OverlayTexture.DEFAULT_UV, bakedModel); - this.draw(); - if (bl) { - DiffuseLighting.enableGuiDepthLighting(); - } - - matrices.pop(); - ci.cancel(); - } - } -} \ No newline at end of file +//package ru.tpsd.eatinganimationmod.mixin; +// +//import com.mojang.blaze3d.systems.RenderSystem; +//import net.minecraft.client.MinecraftClient; +//import net.minecraft.client.gui.DrawContext; +//import net.minecraft.client.render.DiffuseLighting; +//import net.minecraft.client.render.OverlayTexture; +//import net.minecraft.client.render.VertexConsumerProvider; +//import net.minecraft.client.render.model.BakedModel; +//import net.minecraft.client.util.math.MatrixStack; +//import net.minecraft.component.DataComponentTypes; +//import net.minecraft.entity.LivingEntity; +//import net.minecraft.item.ItemStack; +//import net.minecraft.resource.SynchronousResourceReloader; +//import net.minecraft.world.World; +//import org.joml.Matrix4f; +//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; +// +//@Mixin(DrawContext.class) +//public abstract class DrawContextLegacyMixin implements SynchronousResourceReloader { +// +// @Shadow +// @Final +// private MinecraftClient client; +// +// @Shadow +// @Final +// private MatrixStack matrices; +// +// @Shadow +// @Final +// private VertexConsumerProvider.Immediate vertexConsumers; +// +// @Shadow +// public void draw() { +// RenderSystem.disableDepthTest(); +// this.vertexConsumers.draw(); +// RenderSystem.enableDepthTest(); +// } +// +// @Shadow +// public VertexConsumerProvider.Immediate getVertexConsumers() { +// return this.vertexConsumers; +// } +// +// @SuppressWarnings("all") +// @Inject(method = "drawItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;IIII)V", at = @At("HEAD"), cancellable = true) +// void innerRenderInGui(LivingEntity entity, World world, ItemStack stack, int x, int y, int seed, int z, CallbackInfo ci) { +// if (!stack.isEmpty() && stack.contains(DataComponentTypes.FOOD)) { +// BakedModel bakedModel = this.client.getItemRenderer().getModels().getModel(stack); +// this.matrices.push(); +// this.matrices.translate((float)(x + 8), (float)(y + 8), (float)(150 + (bakedModel.hasDepth() ? z : 0))); +// this.matrices.multiplyPositionMatrix(new Matrix4f().scaling(1.0F, -1.0F, 1.0F)); +// this.matrices.scale(16.0F, 16.0F, 16.0F); +// +// boolean bl = !bakedModel.isSideLit(); +// if (bl) { +// DiffuseLighting.disableGuiDepthLighting(); +// } +// +// this.client +// .getItemRenderer() +// .renderItem(stack, ModelTransformationMode.GUI, false, this.matrices, this.getVertexConsumers(), 15728880, OverlayTexture.DEFAULT_UV, bakedModel); +// this.draw(); +// if (bl) { +// DiffuseLighting.enableGuiDepthLighting(); +// } +// +// matrices.pop(); +// ci.cancel(); +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextMixin.java b/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextMixin.java index e65b641..60bcf38 100644 --- a/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextMixin.java +++ b/src/main/java/ru/tpsd/eatinganimationmod/mixin/DrawContextMixin.java @@ -1,43 +1,43 @@ -package ru.tpsd.eatinganimationmod.mixin; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -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.ModifyVariable; - -@Mixin(DrawContext.class) -public abstract class DrawContextMixin { - - @Shadow @Final private MinecraftClient client; - - @SuppressWarnings(value = "all") - @ModifyVariable(method = "drawItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;IIII)V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/render/item/ItemRenderer;getModel(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Lnet/minecraft/client/render/model/BakedModel;")) - private BakedModel getModel(BakedModel bakedModel, @Nullable LivingEntity entity, @Nullable World world, ItemStack stack, int x, int y, int seed, int z) { - if(stack.contains(DataComponentTypes.FOOD) && stack.get(DataComponentTypes.CUSTOM_MODEL_DATA) == null) { - return this.getHeldFoodItemModel(stack, entity, seed); - } - return client.getItemRenderer().getModel(stack, world, entity, seed); - } - - @Unique - public BakedModel getHeldFoodItemModel(ItemStack stack, @Nullable LivingEntity entity, int seed) { - - BakedModel currentItemBakedModel = client.getItemRenderer().getModels().getModel(stack); - - BakedModel itemBakedModel = stack.contains(DataComponentTypes.FOOD) - ? client.getItemRenderer().getModels().getModel(stack) - : currentItemBakedModel.getOverrides().apply(currentItemBakedModel, stack, client.world, entity, seed); - - return itemBakedModel == null ? client.getItemRenderer().getModels().getModelManager().getMissingModel() : itemBakedModel; - } -} \ No newline at end of file +//package ru.tpsd.eatinganimationmod.mixin; +// +//import net.minecraft.client.MinecraftClient; +//import net.minecraft.client.gui.DrawContext; +//import net.minecraft.client.render.model.BakedModel; +//import net.minecraft.component.DataComponentTypes; +//import net.minecraft.entity.LivingEntity; +//import net.minecraft.item.ItemStack; +//import net.minecraft.world.World; +//import org.jetbrains.annotations.Nullable; +//import org.spongepowered.asm.mixin.Final; +//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.ModifyVariable; +// +//@Mixin(DrawContext.class) +//public abstract class DrawContextMixin { +// +// @Shadow @Final private MinecraftClient client; +// +// @SuppressWarnings(value = "all") +// @ModifyVariable(method = "drawItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;IIII)V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/render/item/ItemRenderer;getModel(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Lnet/minecraft/client/render/model/BakedModel;")) +// private BakedModel getModel(BakedModel bakedModel, @Nullable LivingEntity entity, @Nullable World world, ItemStack stack, int x, int y, int seed, int z) { +// if(stack.contains(DataComponentTypes.FOOD) && stack.get(DataComponentTypes.CUSTOM_MODEL_DATA) == null) { +// return this.getHeldFoodItemModel(stack, entity, seed); +// } +// return client.getItemRenderer().getModel(stack, world, entity, seed); +// } +// +// @Unique +// public BakedModel getHeldFoodItemModel(ItemStack stack, @Nullable LivingEntity entity, int seed) { +// +// BakedModel currentItemBakedModel = client.getItemRenderer().getModels().getModel(stack); +// +// BakedModel itemBakedModel = stack.contains(DataComponentTypes.FOOD) +// ? client.getItemRenderer().getModels().getModel(stack) +// : currentItemBakedModel.getOverrides().apply(currentItemBakedModel, stack, client.world, entity, seed); +// +// return itemBakedModel == null ? client.getItemRenderer().getModels().getModelManager().getMissingModel() : itemBakedModel; +// } +//} \ No newline at end of file diff --git a/src/main/resources/eatinganimation.mixins.json b/src/main/resources/eatinganimation.mixins.json index 2e2ec06..738b18f 100644 --- a/src/main/resources/eatinganimation.mixins.json +++ b/src/main/resources/eatinganimation.mixins.json @@ -3,9 +3,7 @@ "minVersion": "0.8", "package": "ru.tpsd.eatinganimationmod.mixin", "compatibilityLevel": "JAVA_21", - "client": [ - "DrawContextMixin" - ], + "client": [], "server": [], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bb531ea..86413b2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "depends": { "fabricloader": "*", "fabric-api": "*", - "minecraft": ">=1.21", + "minecraft": ">=1.21.3", "java": ">=21" } } diff --git a/src/main/resources/resourcepacks/supporteatinganimation/pack.mcmeta b/src/main/resources/resourcepacks/supporteatinganimation/pack.mcmeta index d6a20b9..ab8f288 100644 --- a/src/main/resources/resourcepacks/supporteatinganimation/pack.mcmeta +++ b/src/main/resources/resourcepacks/supporteatinganimation/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 34, + "pack_format": 42, "description": "\u00A7c\u00A7lEating Animation\n\u00A7c\u00A7lmods support" } } \ No newline at end of file