mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 8ce3dd5f [CI-SKIP] Fix Mojang API Brigadier dep - THIS IS NOT A NEW BUILD 00d760a5 Fix build due to spigot changing the build timestamp process 842e040c Updated Upstream (Bukkit/CraftBukkit/Spigot) c03260a2 Add getter and setter for villager's numberOfRestocksToday (#3231) fe366fbe null check tracker for entity metadata update - Fixes #3070 fdf41b74 Implement Brigadier Mojang API e0ea2e0e Entity Activation Range 2.0! Major improvements to restoring behavior 10396d28 Fix Tracking Range mismatch on Vehicle/Passenger checks
80 lines
3.8 KiB
Diff
80 lines
3.8 KiB
Diff
From 79f43a500717fdc8e061212aff96adaaf6f543a8 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sat, 30 Nov 2019 03:30:17 -0600
|
|
Subject: [PATCH] Add sleep options
|
|
|
|
---
|
|
.../net/minecraft/server/EntityHuman.java | 19 +++++++++++++++++--
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 4 ++++
|
|
2 files changed, 21 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index d62174e9c..22e17e3de 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -143,6 +143,21 @@ public abstract class EntityHuman extends EntityLiving {
|
|
this.datawatcher.register(EntityHuman.bt, new NBTTagCompound());
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino");
|
|
+
|
|
+ private boolean unableToSleepRightNow() {
|
|
+ if (world.purpurConfig.playerSleepOnlyWithCondition) {
|
|
+ try {
|
|
+ scriptEngine.eval("time = " + world.getDayTime());
|
|
+ return !(Boolean) scriptEngine.eval(world.purpurConfig.playerSleepCondition);
|
|
+ } catch (Exception ignore) {
|
|
+ }
|
|
+ }
|
|
+ return world.isDay();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public void tick() {
|
|
this.noclip = this.isSpectator();
|
|
@@ -160,7 +175,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
this.sleepTicks = 100;
|
|
}
|
|
|
|
- if (!this.world.isClientSide && this.world.isDay()) {
|
|
+ if (!this.world.isClientSide && unableToSleepRightNow()) { // Purpur
|
|
this.wakeup(false, true);
|
|
}
|
|
} else if (this.sleepTicks > 0) {
|
|
@@ -1334,7 +1349,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
|
|
}
|
|
|
|
- if (this.world.isDay()) {
|
|
+ if (unableToSleepRightNow()) { // Purpur
|
|
this.setRespawnPosition(blockposition, false, true);
|
|
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 647bece31..08fb0bae3 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -150,6 +150,8 @@ public class PurpurWorldConfig {
|
|
public boolean disableDropsOnCrammingDeath = false;
|
|
public boolean fixClimbingBypassingCrammingRule = false;
|
|
public boolean milkCuresBadOmen = true;
|
|
+ public boolean playerSleepOnlyWithCondition = false;
|
|
+ public String playerSleepCondition = "time >= 12541 && time <= 23458";
|
|
public boolean useBetterMending = false;
|
|
private void gameplayMechanicsSettings() {
|
|
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
|
|
@@ -174,6 +176,8 @@ public class PurpurWorldConfig {
|
|
disableDropsOnCrammingDeath = getBoolean("gameplay-mechanics.disable-drops-on-cramming-death", disableDropsOnCrammingDeath);
|
|
fixClimbingBypassingCrammingRule = getBoolean("gameplay-mechanics.fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
|
|
milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen);
|
|
+ playerSleepOnlyWithCondition = getBoolean("gameplay-mechanics.player.sleep.only-with-condition", playerSleepOnlyWithCondition);
|
|
+ playerSleepCondition = getString("gameplay-mechanics.player.sleep.condition", playerSleepCondition);
|
|
useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
|
|
}
|
|
|
|
--
|
|
2.24.0
|
|
|