CavePVP-Stuff/cSpigot-master/spigot-server-Patches/0049-Backport-EntityActivationRange-fixes.patch

93 lines
3.9 KiB
Diff
Raw Normal View History

2023-05-01 20:59:40 +02:00
From 97a1114f80519b2475834e865b32a1868eee066a Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Thu, 2 Apr 2015 15:22:20 -0500
Subject: [PATCH] Backport EntityActivationRange fixes
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 28749c15b..48e28fac7 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -104,7 +104,7 @@ public abstract class Entity {
protected DataWatcher datawatcher;
private double g;
private double h;
- public boolean ag;
+ public boolean ag; public boolean isAddedToChunk() { return ag; } // PaperSpigot - EAR backport
public int ah;
public int ai;
public int aj;
@@ -126,7 +126,7 @@ public abstract class Entity {
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
- public long activatedTick = 0;
+ public long activatedTick = Integer.MIN_VALUE; // PaperSpigot - EAR backport
public boolean fromMobSpawner;
public void inactiveTick() { }
// Spigot end
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index a61e91a17..97830f357 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -137,6 +137,28 @@ public class EntityItem extends Entity {
}
}
+ // PaperSpigot start - copied from above
+ @Override
+ public void inactiveTick() {
+ // CraftBukkit start - Use wall time for pickup and despawn timers
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.pickupDelay -= elapsedTicks;
+ this.age += elapsedTicks;
+ this.lastTick = MinecraftServer.currentTick;
+ // CraftBukkit end
+
+ if (!this.world.isStatic && this.age >= world.spigotConfig.itemDespawnRate) { // Spigot
+ // CraftBukkit start - fire ItemDespawnEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
+ this.age = 0;
+ return;
+ }
+ // CraftBukkit end
+ this.die();
+ }
+ }
+ // PaperSpigot end
+
private void k() {
// Spigot start
double radius = world.spigotConfig.itemMerge;
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 903172a93..6fea40336 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -12,6 +12,7 @@ import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.EntityCreature;
import net.minecraft.server.EntityEnderCrystal;
import net.minecraft.server.EntityEnderDragon;
+import net.minecraft.server.EntityFallingBlock; // PaperSpigot
import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityFireworks;
import net.minecraft.server.EntityHuman;
@@ -262,6 +263,15 @@ public class ActivationRange
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
+
+ // PaperSpigot start - EAR backport
+ // Never safe to skip fireworks or entities not yet added to chunk and we don't skip falling blocks
+ if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks || entity instanceof EntityFallingBlock ) {
+ SpigotTimings.checkIfActiveTimer.stopTiming();
+ return true;
+ }
+ // PaperSpigot end
+
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
// Should this entity tick?
--
2.13.3