mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 2e37979 Use cause and cancel component in PlayerGameModeChanteEvent (#6192) b41b5b5 Catch desynced block breaks (#6193) 5a9c14b Fix distanceSq check on block breaking (#6195) a5acf36 Fix PaperTickList (#6191) Tuinity Changes: 08c0050 Update paper 9cabf00 Do not run filtered rebuild 23229b9 Add async catchers to chunk ticking status change ab2aeb0 Update paper bdd7bb4 Update paper
90 lines
4.9 KiB
Diff
90 lines
4.9 KiB
Diff
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 689ad22925b2561f7c8db961743eb1f821dbb25f..fa3c960992cc240161817e54659d83fed259f2fe 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java
|
|
@@ -5,7 +5,7 @@ import net.minecraft.network.protocol.Packet;
|
|
|
|
public class ClientboundSetTimePacket implements Packet<ClientGamePacketListener> {
|
|
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 % 192000; // Paper - fix guardian beam
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 7944a33cf36878c9e4853637bfb9cba22ba8bc4d..3bc63f24bf8c07b89562887bdc8cf7569d7b33b4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -196,6 +196,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
final Int2ObjectMap<EnderDragonPart> dragonParts;
|
|
private final StructureFeatureManager structureFeatureManager;
|
|
private final boolean tickTime;
|
|
+ private double fakeTime; // Purpur
|
|
// Tuinity start - execute chunk tasks mid tick
|
|
public long lastMidTickExecuteFailure;
|
|
// Tuinity end - execute chunk tasks mid tick
|
|
@@ -573,6 +574,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
|
|
|
this.asyncChunkTaskManager = new com.destroystokyo.paper.io.chunk.ChunkTaskManager(this); // Paper
|
|
+ this.fakeTime = this.serverLevelData.getDayTime(); // Purpur
|
|
}
|
|
|
|
public void setWeatherParameters(int clearDuration, int rainDuration, boolean raining, boolean thundering) {
|
|
@@ -825,6 +827,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.liquidTicks.nextTick(); // Paper
|
|
this.serverLevelData.getScheduledEvents().tick(this.server, i);
|
|
if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
|
+ // Purpur start
|
|
+ double incrementTimeBy = 12000.0D / (double) (isDay() ? this.purpurConfig.daytimeTicks : this.purpurConfig.nighttimeTicks);
|
|
+ if (incrementTimeBy != 1.0D) {
|
|
+ this.fakeTime += incrementTimeBy;
|
|
+ this.setDayTime(this.fakeTime);
|
|
+ net.minecraft.network.protocol.game.ClientboundSetTimePacket packet = new net.minecraft.network.protocol.game.ClientboundSetTimePacket(getGameTime(), getDayTime(), true);
|
|
+ for (ServerPlayer player : this.players) {
|
|
+ packet.setDayTime(player.getPlayerTime());
|
|
+ player.connection.send(packet);
|
|
+ }
|
|
+ } else
|
|
+ // Purpur end
|
|
this.setDayTime(this.levelData.getDayTime() + 1L);
|
|
}
|
|
|
|
@@ -833,6 +847,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
public void setDayTime(long timeOfDay) {
|
|
this.serverLevelData.setDayTime(timeOfDay);
|
|
+ // Purpur start
|
|
+ this.fakeTime = timeOfDay;
|
|
+ }
|
|
+ public void setDayTime(double i) {
|
|
+ this.serverLevelData.setDayTime((long) i);
|
|
+ // Purpur end
|
|
}
|
|
|
|
public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 6fc344bacb5943971a49e5ae6ceb22443525eeb1..0d924990f60019c6a6b9d1ac37e176af43cae93c 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -103,6 +103,13 @@ public class PurpurWorldConfig {
|
|
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
|
|
}
|
|
|
|
+ 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 boolean elytraIgnoreUnbreaking = false;
|