From 226e14ccb7d9155ac21b99a6f7222d4cb3cacbd3 Mon Sep 17 00:00:00 2001 From: Steveplays28 Date: Wed, 4 Dec 2024 18:20:32 +0100 Subject: [PATCH] Fix cats not dropping gifts after sleeping (#82) --- .../mixin/entity/CatEntityMixin.java | 17 +++++++++++++++++ .../steves_realistic_sleep-common.mixins.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/entity/CatEntityMixin.java diff --git a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/entity/CatEntityMixin.java b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/entity/CatEntityMixin.java new file mode 100644 index 0000000..dd38b7d --- /dev/null +++ b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/entity/CatEntityMixin.java @@ -0,0 +1,17 @@ +package io.github.steveplays28.stevesrealisticsleep.mixin.entity; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(targets = "net/minecraft/entity/passive/CatEntity$SleepWithOwnerGoal") +public class CatEntityMixin { + @Unique + private static final float stevesrealisticsleep$ALLOWED_SKY_ANGLE_FOR_GIFT_DROPS = 0.78f; + + @ModifyExpressionValue(method = "stop", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getSkyAngle(F)F")) + private float stevesrealisticsleep$preventUseOfSkyAngleForGiftDrops(float original) { + return stevesrealisticsleep$ALLOWED_SKY_ANGLE_FOR_GIFT_DROPS; + } +} diff --git a/common/src/main/resources/steves_realistic_sleep-common.mixins.json b/common/src/main/resources/steves_realistic_sleep-common.mixins.json index 8e49762..82fdb55 100644 --- a/common/src/main/resources/steves_realistic_sleep-common.mixins.json +++ b/common/src/main/resources/steves_realistic_sleep-common.mixins.json @@ -9,7 +9,8 @@ "ServerWorldMixin", "SleepManagerMixin", "accessor.AbstractCauldronBlockAccessor", - "accessor.ServerWorldAccessor" + "accessor.ServerWorldAccessor", + "entity.CatEntityMixin" ], "injectors": { "defaultRequire": 1