Fix sleeping direction always being null.

Closes 
Closes 
This commit is contained in:
modmuss50 2023-12-16 10:32:34 +00:00
parent 33cef71655
commit 4ced05928d
2 changed files with 7 additions and 8 deletions
fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event
gradle.properties

View file

@ -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.

View file

@ -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