Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21.3 #68

Open
wants to merge 1 commit into
base: 1.21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
//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();
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -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;
}
}
//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;
// }
//}
4 changes: 1 addition & 3 deletions src/main/resources/eatinganimation.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"minVersion": "0.8",
"package": "ru.tpsd.eatinganimationmod.mixin",
"compatibilityLevel": "JAVA_21",
"client": [
"DrawContextMixin"
],
"client": [],
"server": [],
"injectors": {
"defaultRequire": 1
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"depends": {
"fabricloader": "*",
"fabric-api": "*",
"minecraft": ">=1.21",
"minecraft": ">=1.21.3",
"java": ">=21"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 34,
"pack_format": 42,
"description": "\u00A7c\u00A7lEating Animation\n\u00A7c\u00A7lmods support"
}
}