mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Config to ignore nearby mobs when sleeping
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Encode42 <me@encode42.dev>
|
||||
Date: Mon, 8 Mar 2021 16:46:54 -0500
|
||||
Subject: [PATCH] Config to ignore nearby mobs when sleeping
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 92c0a7609e45a8cdb809ad7579f1713fc15675cf..6467e72fa43469ae065462e1a0720130dee336b3 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1789,7 +1789,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
return entitymonster.isPreventingPlayerRest(this.serverLevel(), this);
|
||||
});
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
+ if (!this.level().purpurConfig.playerSleepNearMonsters && !list.isEmpty()) { // Purpur
|
||||
return Either.left(net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index e196d391b4c1a02211f221ef10dda9df05c5ab5c..aa089685179635e74cc4033b5335c1e79fab08a2 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -349,6 +349,7 @@ public class PurpurWorldConfig {
|
||||
public boolean totemOfUndyingWorksInInventory = false;
|
||||
public boolean playerFixStuckPortal = false;
|
||||
public boolean creativeOnePunch = false;
|
||||
+ public boolean playerSleepNearMonsters = false;
|
||||
private void playerSettings() {
|
||||
if (PurpurConfig.version < 19) {
|
||||
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
|
||||
@@ -366,6 +367,7 @@ public class PurpurWorldConfig {
|
||||
totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
|
||||
playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
|
||||
creativeOnePunch = getBoolean("gameplay-mechanics.player.one-punch-in-creative", creativeOnePunch);
|
||||
+ playerSleepNearMonsters = getBoolean("gameplay-mechanics.player.sleep-ignore-nearby-mobs", playerSleepNearMonsters);
|
||||
}
|
||||
|
||||
public boolean silkTouchEnabled = false;
|
||||
@@ -48,6 +48,15 @@
|
||||
this.setServerLevel(level);
|
||||
this.connection.internalTeleport(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); // CraftBukkit - use internal teleport without event
|
||||
this.connection.resetPosition();
|
||||
@@ -1564,7 +_,7 @@
|
||||
new AABB(vec3.x() - 8.0, vec3.y() - 5.0, vec3.z() - 8.0, vec3.x() + 8.0, vec3.y() + 5.0, vec3.z() + 8.0),
|
||||
monster -> monster.isPreventingPlayerRest(this.serverLevel(), this)
|
||||
);
|
||||
- if (!entitiesOfClass.isEmpty()) {
|
||||
+ if (!this.level().purpurConfig.playerSleepNearMonsters && !entitiesOfClass.isEmpty()) { // Purpur - Config to ignore nearby mobs when sleeping
|
||||
return Either.left(Player.BedSleepingProblem.NOT_SAFE);
|
||||
}
|
||||
}
|
||||
@@ -2014,6 +_,26 @@
|
||||
this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||
}
|
||||
|
||||
@@ -341,6 +341,7 @@ public class PurpurWorldConfig {
|
||||
public boolean totemOfUndyingWorksInInventory = false;
|
||||
public boolean playerFixStuckPortal = false;
|
||||
public boolean creativeOnePunch = false;
|
||||
public boolean playerSleepNearMonsters = false;
|
||||
private void playerSettings() {
|
||||
if (PurpurConfig.version < 19) {
|
||||
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
|
||||
@@ -358,6 +359,7 @@ public class PurpurWorldConfig {
|
||||
totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
|
||||
playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
|
||||
creativeOnePunch = getBoolean("gameplay-mechanics.player.one-punch-in-creative", creativeOnePunch);
|
||||
playerSleepNearMonsters = getBoolean("gameplay-mechanics.player.sleep-ignore-nearby-mobs", playerSleepNearMonsters);
|
||||
}
|
||||
|
||||
public boolean silkTouchEnabled = false;
|
||||
|
||||
Reference in New Issue
Block a user