Purpur/patches/server/0063-Add-canSaveToDisk-to-Entity.patch
BillyGalbreath a60a01188e
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@0193a9d Add EntityPortalReadyEvent (#5619)
PaperMC/Paper@4952c04 Don't use level random in entity constructors (#8122)
PaperMC/Paper@1a8bea7 Fix wrong world being passed into portal event (#8174)
2022-07-22 20:52:13 -05:00

81 lines
4.0 KiB
Diff

From 0000000000000000000000000000000000000000 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 canSaveToDisk to Entity
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index c1e8dd926e9d2612f54c6afdaaa1c295da61f13d..f5ec7124e31b2cd8e810033521d2b59329f19bda 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4588,5 +4588,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public boolean processClick(InteractionHand hand) {
return false;
}
+
+ public boolean canSaveToDisk() {
+ return true;
+ }
// Purpur end
}
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 606fa521d577f832cd7a82c1c6c67414e1a01589..7c2c5b5205c7b422903fb6984f2b411d20189b22 100644
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -220,6 +220,11 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
// do not hit rider
return target != rider && super.canHitEntity(target);
}
+
+ @Override
+ public boolean canSaveToDisk() {
+ return false;
+ }
};
skull.setPosRaw(headX, headY, headZ);
level.addFreshEntity(skull);
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
index 2bc0384728f89b7c64a8beec78a1b77dc063d37b..e4af49d85c8f6265b550c0a7cbea7d495f47150a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
@@ -92,6 +92,7 @@ public class EntityStorage implements EntityPersistentStorage<Entity> {
ListTag listTag = new ListTag();
final java.util.Map<net.minecraft.world.entity.EntityType<?>, Integer> savedEntityCounts = new java.util.HashMap<>(); // Paper
dataList.getEntities().forEach((entity) -> {
+ if (!entity.canSaveToDisk()) return; // Purpur
// Paper start
final EntityType<?> entityType = entity.getType();
final int saveLimit = this.level.paperConfig().chunks.entityPerChunkSaveLimit.getOrDefault(entityType, -1);
diff --git a/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java b/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
index d55f7611599b2a339293688861100cb8dae9f6c6..5e99789e5156e8ffbf125e77114c547e1f8e7925 100644
--- a/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
+++ b/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
@@ -35,6 +35,11 @@ public class DolphinSpit extends LlamaSpit {
dolphin.getZ() + (double) (dolphin.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(dolphin.yBodyRot * 0.017453292F));
}
+ @Override
+ public boolean canSaveToDisk() {
+ return false;
+ }
+
public void tick() {
super_tick();
diff --git a/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
index 2eca8317e991ec46cc88a4c7d6d8b50152ba4ea7..b6a594cd6b08c687cf51c2f5494297ef96ec4b92 100644
--- a/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
+++ b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
@@ -38,6 +38,11 @@ public class PhantomFlames extends LlamaSpit {
phantom.getZ() + (double) (phantom.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(phantom.yBodyRot * 0.017453292F));
}
+ @Override
+ public boolean canSaveToDisk() {
+ return false;
+ }
+
public void tick() {
super_tick();