From 972b6a6f186b613203929ff7da71a54e43d31078 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sat, 3 Oct 2020 21:39:16 -0500 Subject: [PATCH] Entity#isTicking --- .../minecraft/world/entity/Entity.java.patch | 28 +++++++++++-------- .../craftbukkit/entity/CraftEntity.java | 7 +++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index d950e667de..5687b10e37 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -61,7 +61,7 @@ +// CraftBukkit end public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { - ++ + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first setPositionRotation @@ -151,7 +151,7 @@ + } + return this.bukkitEntity; + } -+ + + // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + public int getDefaultMaxAirSupply() { + return Entity.TOTAL_AIR_SUPPLY; @@ -831,11 +831,10 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); -@@ -2079,7 +2520,69 @@ - } +@@ -2080,6 +2521,68 @@ } else { throw new IllegalStateException("Entity has invalid position"); -+ } + } + + // CraftBukkit start + // Spigot start @@ -858,7 +857,7 @@ + boolean bukkitInvisible = nbt.getBoolean("Bukkit.invisible"); + this.setInvisible(bukkitInvisible); + this.persistentInvisibility = bukkitInvisible; - } ++ } + // CraftBukkit end + + // Paper start @@ -1480,7 +1479,7 @@ + + // CraftBukkit start + private final CommandSource commandSource = new CommandSource() { -+ + + @Override + public void sendSystemMessage(Component message) { + } @@ -1506,21 +1505,22 @@ + } + }; + // CraftBukkit end - ++ public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel world) { - return new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this); + return new CommandSourceStack(this.commandSource, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this); // CraftBukkit } public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { -@@ -3551,6 +4308,11 @@ +@@ -3550,7 +4307,12 @@ + vec3d = vec3d.add(vec3d1); ++k1; - } ++ } + // CraftBukkit start - store last lava contact location + if (tag == FluidTags.LAVA) { + this.lastLavaContact = blockposition_mutableblockposition.immutable(); -+ } + } + // CraftBukkit end } } @@ -1615,7 +1615,7 @@ if (entityliving instanceof Player entityhuman) { if (this.isAlive()) { -@@ -3962,4 +4760,10 @@ +@@ -3962,4 +4760,14 @@ void accept(Entity entity, double x, double y, double z); } @@ -1624,5 +1624,9 @@ + public static int nextEntityId() { + return ENTITY_COUNTER.incrementAndGet(); + } ++ ++ public boolean isTicking() { ++ return ((net.minecraft.server.level.ServerLevel) this.level).isPositionEntityTicking(this.blockPosition()); ++ } + // Paper end - Expose entity id counter } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 609c768ba4..dbb1a52b1e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1058,4 +1058,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return getHandle().isInLava(); } // Paper end - entity liquid API + + // Paper start - isTicking API + @Override + public boolean isTicking() { + return getHandle().isTicking(); + } + // Paper end - isTicking API }