From 6ddeb980cfc3d0615b56a1a294e93f9a91a94726 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 13 Sep 2019 20:04:43 +1000
Subject: [PATCH] SPIGOT-5317: Create accessors for player absorption hearts

---
 .../craftbukkit/entity/CraftEnderDragonPart.java    | 10 ++++++++++
 .../craftbukkit/entity/CraftLivingEntity.java       | 13 +++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java
index ea4eb6bc0b..e6d050099b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java
@@ -46,6 +46,16 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
         getParent().setHealth(health);
     }
 
+    @Override
+    public double getAbsorptionAmount() {
+        return getParent().getAbsorptionAmount();
+    }
+
+    @Override
+    public void setAbsorptionAmount(double amount) {
+        getParent().setAbsorptionAmount(amount);
+    }
+
     @Override
     public double getMaxHealth() {
         return getParent().getMaxHealth();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 2e007d4ffc..9c1d4e7585 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -1,5 +1,6 @@
 package org.bukkit.craftbukkit.entity;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -114,6 +115,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
         }
     }
 
+    @Override
+    public double getAbsorptionAmount() {
+        return getHandle().getAbsorptionHearts();
+    }
+
+    @Override
+    public void setAbsorptionAmount(double amount) {
+        Preconditions.checkArgument(amount >= 0 && Double.isFinite(amount), "amount < 0 or non-finite");
+
+        getHandle().setAbsorptionHearts((float) amount);
+    }
+
     @Override
     public double getMaxHealth() {
         return getHandle().getMaxHealth();