mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
[ci skip] drop old migration patch
This commit is contained in:
107
patches/server/0094-Configurable-daylight-cycle.patch
Normal file
107
patches/server/0094-Configurable-daylight-cycle.patch
Normal file
@@ -0,0 +1,107 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 10 Oct 2020 14:29:55 -0500
|
||||
Subject: [PATCH] Configurable daylight cycle
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java
|
||||
index 76ef195a5074006b009acd9cc1744667c6aecbb9..659577549e132754281df76a7a1bfd884443c56a 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java
|
||||
@@ -10,7 +10,7 @@ public class ClientboundSetTimePacket implements Packet<ClientGamePacketListener
|
||||
ClientboundSetTimePacket::write, ClientboundSetTimePacket::new
|
||||
);
|
||||
private final long gameTime;
|
||||
- private final long dayTime;
|
||||
+ private long dayTime; public void setDayTime(long dayTime) { this.dayTime = dayTime; } // Purpur
|
||||
|
||||
public ClientboundSetTimePacket(long time, long timeOfDay, boolean doDaylightCycle) {
|
||||
this.gameTime = time;
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index b2ce50799ff158ff2160b0d75404e52e34d54805..f514c421b5ff7e46b2d211f895dcb0d7a375704f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1784,7 +1784,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
long worldTime = level.getGameTime();
|
||||
final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight);
|
||||
for (Player entityhuman : level.players()) {
|
||||
- if (!(entityhuman instanceof ServerPlayer) || (tickCount + entityhuman.getId()) % 20 != 0) {
|
||||
+ if (!(entityhuman instanceof ServerPlayer) || (!level.isForceTime() && (tickCount + entityhuman.getId()) % 20 != 0)) { // Purpur
|
||||
continue;
|
||||
}
|
||||
ServerPlayer entityplayer = (ServerPlayer) entityhuman;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 9eeb5a5304a25f8709288bc78ec8458b70e18649..e077c6cb1880ee19e696d2430b07d1101e330919 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -221,6 +221,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
private final StructureManager structureManager;
|
||||
private final StructureCheck structureCheck;
|
||||
private final boolean tickTime;
|
||||
+ private double preciseTime; // Purpur
|
||||
+ private boolean forceTime; // Purpur
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -608,6 +610,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this, ca.spottedleaf.moonrise.common.util.MoonriseCommon.WORKER_POOL);
|
||||
// Paper end - rewrite chunk system
|
||||
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
+ this.preciseTime = this.serverLevelData.getDayTime(); // Purpur
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -798,6 +801,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
this.serverLevelData.setGameTime(i);
|
||||
this.serverLevelData.getScheduledEvents().tick(this.server, i);
|
||||
if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
+ // Purpur start
|
||||
+ int incrementTicks = isDay() ? this.purpurConfig.daytimeTicks : this.purpurConfig.nighttimeTicks;
|
||||
+ if (incrementTicks != 12000) {
|
||||
+ this.preciseTime += 12000 / (double) incrementTicks;
|
||||
+ this.setDayTime(this.preciseTime);
|
||||
+ } else
|
||||
+ // Purpur end
|
||||
this.setDayTime(this.levelData.getDayTime() + 1L);
|
||||
}
|
||||
|
||||
@@ -806,7 +816,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
|
||||
public void setDayTime(long timeOfDay) {
|
||||
this.serverLevelData.setDayTime(timeOfDay);
|
||||
+ // Purpur start
|
||||
+ this.preciseTime = timeOfDay;
|
||||
+ this.forceTime = false;
|
||||
}
|
||||
+ public void setDayTime(double i) {
|
||||
+ this.serverLevelData.setDayTime((long) i);
|
||||
+ this.forceTime = true;
|
||||
+ // Purpur end
|
||||
+ }
|
||||
+
|
||||
+ // Purpur start
|
||||
+ public boolean isForceTime() {
|
||||
+ return this.forceTime;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
|
||||
public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) {
|
||||
Iterator iterator = this.customSpawners.iterator();
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 0abf6598e8bf4ac59ea4387ee07d4de68032076b..ac473b14269e124bbb60d063ee869103800e7cbc 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -119,6 +119,13 @@ public class PurpurWorldConfig {
|
||||
raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);
|
||||
}
|
||||
|
||||
+ public int daytimeTicks = 12000;
|
||||
+ public int nighttimeTicks = 12000;
|
||||
+ private void daytimeCycleSettings() {
|
||||
+ daytimeTicks = getInt("gameplay-mechanics.daylight-cycle-ticks.daytime", daytimeTicks);
|
||||
+ nighttimeTicks = getInt("gameplay-mechanics.daylight-cycle-ticks.nighttime", nighttimeTicks);
|
||||
+ }
|
||||
+
|
||||
public int elytraDamagePerSecond = 1;
|
||||
public double elytraDamageMultiplyBySpeed = 0;
|
||||
public int elytraDamagePerFireworkBoost = 0;
|
||||
Reference in New Issue
Block a user