-
-
Notifications
You must be signed in to change notification settings - Fork 347
/
0097-Add-option-to-disable-saving-projectiles-to-disk.patch
179 lines (164 loc) · 8.63 KB
/
0097-Add-option-to-disable-saving-projectiles-to-disk.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
From 2a32d1e318c8d4b1e9178fcd1db43b4ee7cdbf64 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 18 Feb 2020 20:07:08 -0600
Subject: [PATCH] Add option to disable saving projectiles to disk
---
.../net/minecraft/server/ChunkRegionLoader.java | 2 +-
src/main/java/net/minecraft/server/Entity.java | 6 ++++++
.../java/net/minecraft/server/EntityArrow.java | 7 +++++++
.../net/minecraft/server/EntityEnderSignal.java | 7 +++++++
.../net/minecraft/server/EntityFireworks.java | 7 +++++++
.../net/minecraft/server/EntityLlamaSpit.java | 7 +++++++
.../net/minecraft/server/EntityProjectile.java | 7 +++++++
.../java/net/pl3x/purpur/PurpurWorldConfig.java | 16 ++++++++++++++++
8 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index d529b795c5..e883365b0b 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -1,6 +1,5 @@
package net.minecraft.server;
-import co.aikar.timings.Timings;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -445,6 +444,7 @@ public class ChunkRegionLoader {
while (iterator1.hasNext()) {
Entity entity = (Entity) iterator1.next();
+ if (!entity.canSaveToDisk()) continue; // Purpur
NBTTagCompound nbttagcompound4 = new NBTTagCompound();
// Paper start
if ((int) Math.floor(entity.locX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.locZ()) >> 4 != chunk.getPos().z) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 00a8df8a7f..dd174f5065 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1648,6 +1648,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
+ // Purpur start
+ public boolean canSaveToDisk() {
+ return true;
+ }
+ // Purpur end
+
public boolean c(NBTTagCompound nbttagcompound) {
String s = this.getSaveID();
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 9c97edf9c9..48da1e662a 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -68,6 +68,13 @@ public abstract class EntityArrow extends Entity implements IProjectile {
}
+ // Purpur start
+ @Override
+ public boolean canSaveToDisk() {
+ return world != null && world.purpurConfig.saveProjectilesToDisk;
+ }
+ // Purpur end
+
public void a(SoundEffect soundeffect) {
this.av = soundeffect;
}
diff --git a/src/main/java/net/minecraft/server/EntityEnderSignal.java b/src/main/java/net/minecraft/server/EntityEnderSignal.java
index 7ebd7da1c5..74f8257ecd 100644
--- a/src/main/java/net/minecraft/server/EntityEnderSignal.java
+++ b/src/main/java/net/minecraft/server/EntityEnderSignal.java
@@ -19,6 +19,13 @@ public class EntityEnderSignal extends Entity {
this.setPosition(d0, d1, d2);
}
+ // Purpur start
+ @Override
+ public boolean canSaveToDisk() {
+ return world != null && world.purpurConfig.saveProjectilesToDisk;
+ }
+ // Purpur end
+
public void b(ItemStack itemstack) {
if (itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) {
this.getDataWatcher().set(EntityEnderSignal.b, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // Purpur - decompile error
diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java
index 5c3731f68a..ce3168e5de 100644
--- a/src/main/java/net/minecraft/server/EntityFireworks.java
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -21,6 +21,13 @@ public class EntityFireworks extends Entity implements IProjectile {
super(entitytypes, world);
}
+ // Purpur start
+ @Override
+ public boolean canSaveToDisk() {
+ return world != null && world.purpurConfig.saveProjectilesToDisk;
+ }
+ // Purpur end
+
// Spigot Start - copied from tick
@Override
public void inactiveTick() {
diff --git a/src/main/java/net/minecraft/server/EntityLlamaSpit.java b/src/main/java/net/minecraft/server/EntityLlamaSpit.java
index b7a92e1002..b95ee50a4e 100644
--- a/src/main/java/net/minecraft/server/EntityLlamaSpit.java
+++ b/src/main/java/net/minecraft/server/EntityLlamaSpit.java
@@ -19,6 +19,13 @@ public class EntityLlamaSpit extends Entity implements IProjectile {
this.setPosition(entityllama.locX() - (double) (entityllama.getWidth() + 1.0F) * 0.5D * (double) MathHelper.sin(entityllama.aI * 0.017453292F), entityllama.getHeadY() - 0.10000000149011612D, entityllama.locZ() + (double) (entityllama.getWidth() + 1.0F) * 0.5D * (double) MathHelper.cos(entityllama.aI * 0.017453292F));
}
+ // Purpur start
+ @Override
+ public boolean canSaveToDisk() {
+ return world != null && world.purpurConfig.saveProjectilesToDisk;
+ }
+ // Purpur end
+
@Override
public void tick() {
super.tick();
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
index f5c8074dcf..674f2ccc7f 100644
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
@@ -35,6 +35,13 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
}
+ // Purpur start
+ @Override
+ public boolean canSaveToDisk() {
+ return world != null && world.purpurConfig.saveProjectilesToDisk;
+ }
+ // Purpur end
+
public void a(Entity entity, float f, float f1, float f2, float f3, float f4) {
float f5 = -MathHelper.sin(f1 * 0.017453292F) * MathHelper.cos(f * 0.017453292F);
float f6 = -MathHelper.sin((f + f2) * 0.017453292F);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index e88157cc69..1db7e5433f 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -173,6 +173,7 @@ public class PurpurWorldConfig {
public boolean playerSleepOnlyWithCondition = false;
public String playerSleepCondition = "time >= 12541 && time <= 23458";
public boolean useBetterMending = false;
+ public boolean saveProjectilesToDisk = true;
private void gameplayMechanicsSettings() {
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
@@ -201,6 +202,21 @@ public class PurpurWorldConfig {
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);
+ if (PurpurConfig.version < 4) {
+ Object oldVal = PurpurConfig.config.get("world-settings.default.gameplay-mechanics.saveProjectilesToDisk");
+ if (oldVal instanceof Boolean) {
+ PurpurConfig.config.addDefault("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", oldVal);
+ PurpurConfig.config.set("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", oldVal);
+ saveProjectilesToDisk = (boolean) oldVal;
+ }
+ oldVal = PurpurConfig.config.get("world-settings." + worldName + ".gameplay-mechanics.saveProjectilesToDisk");
+ if (oldVal instanceof Boolean) {
+ PurpurConfig.config.set("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", oldVal);
+ saveProjectilesToDisk = (boolean) oldVal;
+ }
+ set("gameplay-mechanics.saveProjectilesToDisk", null);
+ }
+ saveProjectilesToDisk = getBoolean("gameplay-mechanics.save-projectiles-to-disk", saveProjectilesToDisk);
}
public int elytraDamagePerSecond = 1;
--
2.24.0