From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Tue, 9 Mar 2021 16:10:39 -0500
Subject: [PATCH] Add back player spawned endermite API


diff --git a/src/main/java/net/minecraft/world/entity/monster/Endermite.java b/src/main/java/net/minecraft/world/entity/monster/Endermite.java
index d9e2bc9d37968430910c8de33390004ba5db22a6..1578a8196f860995370a1b8938b6d71040f5d3a9 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Endermite.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Endermite.java
@@ -30,6 +30,7 @@ import net.minecraft.world.level.block.state.BlockState;
 public class Endermite extends Monster {
     private static final int MAX_LIFE = 2400;
     private int life;
+    private boolean isPlayerSpawned; // Purpur
 
     public Endermite(EntityType<? extends Endermite> type, Level world) {
         super(type, world);
@@ -51,6 +52,14 @@ public class Endermite extends Monster {
     public void initAttributes() {
         this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.endermiteMaxHealth);
     }
+
+    public boolean isPlayerSpawned() {
+        return this.isPlayerSpawned;
+    }
+
+    public void setPlayerSpawned(boolean playerSpawned) {
+        this.isPlayerSpawned = playerSpawned;
+    }
     // Purpur end
 
     @Override
@@ -104,12 +113,14 @@ public class Endermite extends Monster {
     public void readAdditionalSaveData(CompoundTag nbt) {
         super.readAdditionalSaveData(nbt);
         this.life = nbt.getInt("Lifetime");
+        this.isPlayerSpawned = nbt.getBoolean("PlayerSpawned"); // Purpur
     }
 
     @Override
     public void addAdditionalSaveData(CompoundTag nbt) {
         super.addAdditionalSaveData(nbt);
         nbt.putInt("Lifetime", this.life);
+        nbt.putBoolean("PlayerSpawned", this.isPlayerSpawned); // Purpur
     }
 
     @Override
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
index c2db9485e69b9679a33a57bc84cf2c76c1de2a42..6e4cffa397d07c9c0910f2a1ec0fb8bf04a1b6ba 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -72,6 +72,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
                         if (this.random.nextFloat() < this.level.purpurConfig.enderPearlEndermiteChance && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { // Purpur
                             Endermite entityendermite = (Endermite) EntityType.ENDERMITE.create(this.level);
 
+                            entityendermite.setPlayerSpawned(true); // Purpur
                             entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
                             this.level.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
                         }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java
index 04976616da8c85b1278dad33ff05554aa74a6b33..046e0e174119e65686e74eaf11853e6832b90e80 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java
@@ -27,11 +27,11 @@ public class CraftEndermite extends CraftMonster implements Endermite {
 
     @Override
     public boolean isPlayerSpawned() {
-        return false;
+        return getHandle().isPlayerSpawned(); // Purpur
     }
 
     @Override
     public void setPlayerSpawned(boolean playerSpawned) {
-        // Nop
+        getHandle().setPlayerSpawned(playerSpawned); // Purpur
     }
 }
