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 1d29ff3feaf95628dc84b67f430ddfc88b7bd507..fd3aff71f8e4ffd4faabc2650d8d83c8e6e85946 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4303,5 +4303,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
     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 f52420f27f51d9dbf214f96a0530c0f17f2bc5fc..12cd1b453150e098975c34e00ec9277ff9730c75 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
@@ -192,6 +192,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 91d692e9337c2ec6824829259ea6ea1ad343d21a..6c9b139cfb1dfa1eb80fdb72651c8c3f921e74ea 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.entityPerChunkSaveLimits.getOrDefault(entityType, -1);
diff --git a/src/main/java/net/pl3x/purpur/entity/DolphinSpit.java b/src/main/java/net/pl3x/purpur/entity/DolphinSpit.java
index fda24d4ecff91cc28d2a7a45fbb55ea734261153..3cabafb00c293cbbcc60a0cc98479c2d62ddaa2d 100644
--- a/src/main/java/net/pl3x/purpur/entity/DolphinSpit.java
+++ b/src/main/java/net/pl3x/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/net/pl3x/purpur/entity/PhantomFlames.java b/src/main/java/net/pl3x/purpur/entity/PhantomFlames.java
index b196bee2ea6e67897b367d2be1800f16a89a6167..d8a9f3296c46f12e156f1611811cb55470703b03 100644
--- a/src/main/java/net/pl3x/purpur/entity/PhantomFlames.java
+++ b/src/main/java/net/pl3x/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();
 
