From 4ced05928d5c07195207223888860af749c19d5a Mon Sep 17 00:00:00 2001 From: modmuss50 <modmuss50@gmail.com> Date: Sat, 16 Dec 2023 10:32:34 +0000 Subject: [PATCH] Fix sleeping direction always being null. Closes #3470 Closes #3471 --- .../fabric/mixin/entity/event/LivingEntityMixin.java | 11 +++++------ gradle.properties | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java index 71cfae28a..aed025622 100644 --- a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java +++ b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java @@ -20,7 +20,6 @@ import java.util.Optional; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; @@ -44,6 +43,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.BlockView; import net.minecraft.world.CollisionView; import net.minecraft.world.World; @@ -109,11 +109,10 @@ abstract class LivingEntityMixin { } } - @Inject(method = "getSleepingDirection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BedBlock;getDirection(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/Direction;"), cancellable = true) - private void onGetSleepingDirection(CallbackInfoReturnable<Direction> info, @Local @Nullable BlockPos sleepingPos) { - if (sleepingPos != null) { - info.setReturnValue(EntitySleepEvents.MODIFY_SLEEPING_DIRECTION.invoker().modifySleepDirection((LivingEntity) (Object) this, sleepingPos, info.getReturnValue())); - } + @WrapOperation(method = "getSleepingDirection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BedBlock;getDirection(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/Direction;")) + private Direction onGetSleepingDirection(BlockView world, BlockPos sleepingPos, Operation<Direction> operation) { + final Direction sleepingDirection = operation.call(world, sleepingPos); + return EntitySleepEvents.MODIFY_SLEEPING_DIRECTION.invoker().modifySleepDirection((LivingEntity) (Object) this, sleepingPos, sleepingDirection); } // This is needed 1) so that the vanilla logic in wakeUp runs for modded beds and 2) for the injector below. diff --git a/gradle.properties b/gradle.properties index 241baaa53..485e97c26 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true -version=0.91.2 +version=0.91.3 minecraft_version=1.20.4 yarn_version=+build.1 loader_version=0.15.1 @@ -26,7 +26,7 @@ fabric-content-registries-v0-version=5.0.9 fabric-crash-report-info-v1-version=0.2.22 fabric-data-generation-api-v1-version=13.1.17 fabric-dimensions-v1-version=2.1.60 -fabric-entity-events-v1-version=1.5.27 +fabric-entity-events-v1-version=1.5.28 fabric-events-interaction-v0-version=0.6.14 fabric-events-lifecycle-v0-version=0.2.71 fabric-game-rule-api-v1-version=1.0.45