mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 11:20:55 -04:00
Fix dedicated dev server crash #1670
This commit is contained in:
parent
077fc48468
commit
62e33f4127
3 changed files with 6 additions and 5 deletions
build.gradle
fabric-entity-events-v1
|
@ -19,7 +19,7 @@ plugins {
|
|||
def ENV = System.getenv()
|
||||
|
||||
class Globals {
|
||||
static def baseVersion = "0.39.1"
|
||||
static def baseVersion = "0.39.2"
|
||||
static def mcVersion = "1.17.1"
|
||||
static def yarnVersion = "+build.1"
|
||||
static def loaderVersion = "0.11.3"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
archivesBaseName = "fabric-entity-events-v1"
|
||||
version = getSubprojectVersion(project, "1.2.1")
|
||||
version = getSubprojectVersion(project, "1.2.2")
|
||||
|
||||
moduleDependencies(project, [
|
||||
'fabric-api-base'
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -32,7 +33,7 @@ import net.minecraft.world.World;
|
|||
import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
abstract class PlayerEntityMixin extends LivingEntityMixin {
|
||||
abstract class PlayerEntityMixin {
|
||||
@Inject(method = "trySleep", at = @At("HEAD"), cancellable = true)
|
||||
private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) {
|
||||
PlayerEntity.SleepFailureReason failureReason = EntitySleepEvents.ALLOW_SLEEPING.invoker().allowSleep((PlayerEntity) (Object) this, pos);
|
||||
|
@ -46,8 +47,8 @@ abstract class PlayerEntityMixin extends LivingEntityMixin {
|
|||
private boolean redirectDaySleepCheck(World world) {
|
||||
boolean day = world.isDay();
|
||||
|
||||
if (getSleepingPosition().isPresent()) {
|
||||
BlockPos pos = getSleepingPosition().get();
|
||||
if (((LivingEntity) (Object) this).getSleepingPosition().isPresent()) {
|
||||
BlockPos pos = ((LivingEntity) (Object) this).getSleepingPosition().get();
|
||||
ActionResult result = EntitySleepEvents.ALLOW_SLEEP_TIME.invoker().allowSleepTime((PlayerEntity) (Object) this, pos, !day);
|
||||
|
||||
if (result != ActionResult.PASS) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue