From 9ff21585db300b54a9442a81eaf750764e715677 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Tue, 11 Oct 2022 15:43:10 +0300 Subject: [PATCH] Expose isUnderWater to Entity (#8454) --- patches/api/Add-entity-liquid-API.patch | 17 +++++++++++------ patches/api/Entity-isTicking.patch | 4 ++-- patches/api/Expose-Tracked-Players.patch | 2 +- patches/server/Add-entity-liquid-API.patch | 13 ++++++++++++- patches/server/Entity-isTicking.patch | 11 ++--------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/patches/api/Add-entity-liquid-API.patch b/patches/api/Add-entity-liquid-API.patch index dc0e58a454..6aa0146405 100644 --- a/patches/api/Add-entity-liquid-API.patch +++ b/patches/api/Add-entity-liquid-API.patch @@ -14,33 +14,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason(); + + /** ++ * Check if entity is underwater ++ */ ++ boolean isUnderWater(); ++ ++ /** + * Check if entity is in rain + */ -+ public boolean isInRain(); ++ boolean isInRain(); + + /** + * Check if entity is in bubble column + */ -+ public boolean isInBubbleColumn(); ++ boolean isInBubbleColumn(); + + /** + * Check if entity is in water or rain + */ -+ public boolean isInWaterOrRain(); ++ boolean isInWaterOrRain(); + + /** + * Check if entity is in water or bubble column + */ -+ public boolean isInWaterOrBubbleColumn(); ++ boolean isInWaterOrBubbleColumn(); + + /** + * Check if entity is in water or rain or bubble column + */ -+ public boolean isInWaterOrRainOrBubbleColumn(); ++ boolean isInWaterOrRainOrBubbleColumn(); + + /** + * Check if entity is in lava + */ -+ public boolean isInLava(); ++ boolean isInLava(); // Paper end } diff --git a/patches/api/Entity-isTicking.patch b/patches/api/Entity-isTicking.patch index 7cab16fc87..794195992c 100644 --- a/patches/api/Entity-isTicking.patch +++ b/patches/api/Entity-isTicking.patch @@ -11,11 +11,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * Check if entity is in lava */ - public boolean isInLava(); + boolean isInLava(); + + /** + * Check if entity is inside a ticking chunk + */ -+ public boolean isTicking(); ++ boolean isTicking(); // Paper end } diff --git a/patches/api/Expose-Tracked-Players.patch b/patches/api/Expose-Tracked-Players.patch index f8ed1b1d3f..942789cd77 100644 --- a/patches/api/Expose-Tracked-Players.patch +++ b/patches/api/Expose-Tracked-Players.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * Check if entity is inside a ticking chunk */ - public boolean isTicking(); + boolean isTicking(); + + /** + * Returns a set of {@link Player Players} within this entity's tracking range (players that can "see" this entity). diff --git a/patches/server/Add-entity-liquid-API.patch b/patches/server/Add-entity-liquid-API.patch index 6551761c5a..5267310f13 100644 --- a/patches/server/Add-entity-liquid-API.patch +++ b/patches/server/Add-entity-liquid-API.patch @@ -13,26 +13,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return getHandle().spawnReason; } + ++ @Override ++ public boolean isUnderWater() { ++ return getHandle().isUnderWater(); ++ } ++ ++ @Override + public boolean isInRain() { + return getHandle().isInRain(); + } + ++ @Override + public boolean isInBubbleColumn() { + return getHandle().isInBubbleColumn(); + } + ++ @Override + public boolean isInWaterOrRain() { + return getHandle().isInWaterOrRain(); + } + ++ @Override + public boolean isInWaterOrBubbleColumn() { + return getHandle().isInWaterOrBubble(); + } -+ ++ ++ @Override + public boolean isInWaterOrRainOrBubbleColumn() { + return getHandle().isInWaterRainOrBubble(); + } + ++ @Override + public boolean isInLava() { + return getHandle().isInLava(); + } diff --git a/patches/server/Entity-isTicking.patch b/patches/server/Entity-isTicking.patch index ba7684604e..effca8bcd9 100644 --- a/patches/server/Entity-isTicking.patch +++ b/patches/server/Entity-isTicking.patch @@ -8,21 +8,13 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ import net.minecraft.resources.ResourceKey; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.MCUtil; - import net.minecraft.server.MinecraftServer; -+import net.minecraft.server.level.ServerChunkCache; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.server.level.TicketType; @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public static int nextEntityId() { return ENTITY_COUNTER.incrementAndGet(); } + + public boolean isTicking() { -+ return ((ServerChunkCache) level.getChunkSource()).isPositionTicking(this); ++ return ((net.minecraft.server.level.ServerChunkCache) level.getChunkSource()).isPositionTicking(this); + } // Paper end } @@ -35,6 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return getHandle().isInLava(); } + ++ @Override + public boolean isTicking() { + return getHandle().isTicking(); + }