mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
Remove Add-back-EntityCreatePortalEvent-for-EnderDragon.patch
This commit is contained in:
95
patches/server/0085-Add-sleep-options.patch
Normal file
95
patches/server/0085-Add-sleep-options.patch
Normal file
@@ -0,0 +1,95 @@
|
||||
From f6eae13433bd413fc12bac0945ea602f7560dbc3 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 | 25 ++++++++++++++++---
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 7 ++++++
|
||||
2 files changed, 29 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index 9d26bd1e4..7b54b02e2 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -14,6 +14,11 @@ import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+// Purpur start
|
||||
+import javax.script.ScriptEngine;
|
||||
+import javax.script.ScriptEngineManager;
|
||||
+import javax.script.ScriptException;
|
||||
+// Purpur end
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
@@ -25,7 +30,6 @@ import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
-import org.bukkit.util.Vector;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class EntityHuman extends EntityLiving {
|
||||
@@ -143,6 +147,21 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
this.datawatcher.register(EntityHuman.bt, new NBTTagCompound());
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ private ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
+
|
||||
+ private boolean unableToSleepRightNow() {
|
||||
+ if (world.purpurConfig.playerSleepOnlyWithCondition) {
|
||||
+ try {
|
||||
+ scriptEngine.eval("time = " + world.getDayTime());
|
||||
+ return !(Boolean) scriptEngine.eval(world.purpurConfig.playerSleepCondition);
|
||||
+ } catch (ScriptException ignore) {
|
||||
+ }
|
||||
+ }
|
||||
+ return world.isDay();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
this.noclip = this.isSpectator();
|
||||
@@ -160,7 +179,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 +1353,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 de793add4..f81c0cde3 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -178,6 +178,13 @@ public class PurpurWorldConfig {
|
||||
elytraDamagePerTridentBoost = getInt("elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
||||
}
|
||||
|
||||
+ public boolean playerSleepOnlyWithCondition = false;
|
||||
+ public String playerSleepCondition = "time >= 12541 && time <= 23458";
|
||||
+ private void playerSettings() {
|
||||
+ playerSleepOnlyWithCondition = getBoolean("player.sleep.only-with-condition", playerSleepOnlyWithCondition);
|
||||
+ playerSleepCondition = getString("player.sleep.condition", playerSleepCondition);
|
||||
+ }
|
||||
+
|
||||
public int chickenEggsHatchWhenDespawnedMax = 0;
|
||||
public int chickenEggsHatchWhenDespawnedRange = 10;
|
||||
private void chickenSettings() {
|
||||
--
|
||||
2.24.0
|
||||
|
||||
Reference in New Issue
Block a user