mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07:00
Move Aikar's EAR 1 into EAR 2 patch
This commit is contained in:
@@ -291,14 +291,6 @@
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
}
|
||||
@@ -385,6 +_,7 @@
|
||||
profilerFiller.pop();
|
||||
}
|
||||
|
||||
+ org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||
this.entityTickList
|
||||
.forEach(
|
||||
entity -> {
|
||||
@@ -461,12 +_,12 @@
|
||||
int minBlockZ = pos.getMinBlockZ();
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
@@ -464,52 +456,22 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -752,15 +_,20 @@
|
||||
entity.tickCount++;
|
||||
@@ -753,6 +_,7 @@
|
||||
profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString());
|
||||
profilerFiller.incrementCounter("tickNonPassenger");
|
||||
+ // Spigot start
|
||||
+ final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2
|
||||
+ if (isActive) {
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
+ } else {entity.inactiveTick();} // Spigot end
|
||||
profilerFiller.pop();
|
||||
|
||||
for (Entity entity1 : entity.getPassengers()) {
|
||||
- this.tickPassenger(entity, entity1);
|
||||
+ this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
|
||||
}
|
||||
}
|
||||
|
||||
- private void tickPassenger(Entity ridingEntity, Entity passengerEntity) {
|
||||
+ private void tickPassenger(Entity ridingEntity, Entity passengerEntity, boolean isActive) { // Paper - EAR 2
|
||||
if (passengerEntity.isRemoved() || passengerEntity.getVehicle() != ridingEntity) {
|
||||
passengerEntity.stopRiding();
|
||||
} else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) {
|
||||
@@ -769,11 +_,21 @@
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
@@ -770,6 +_,7 @@
|
||||
profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString());
|
||||
profilerFiller.incrementCounter("tickPassenger");
|
||||
+ // Paper start - EAR 2
|
||||
+ if (isActive) {
|
||||
passengerEntity.rideTick();
|
||||
+ passengerEntity.postTick(); // CraftBukkit
|
||||
+ } else {
|
||||
+ passengerEntity.setDeltaMovement(Vec3.ZERO);
|
||||
+ passengerEntity.inactiveTick();
|
||||
+ // copied from inside of if (isPassenger()) of passengerTick, but that ifPassenger is unnecessary
|
||||
+ ridingEntity.positionRider(passengerEntity);
|
||||
+ // Paper end - EAR 2
|
||||
+ }
|
||||
profilerFiller.pop();
|
||||
|
||||
for (Entity entity : passengerEntity.getPassengers()) {
|
||||
- this.tickPassenger(passengerEntity, entity);
|
||||
+ this.tickPassenger(passengerEntity, entity, isActive); // Paper - EAR 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -786,6 +_,7 @@
|
||||
public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) {
|
||||
ServerChunkCache chunkSource = this.getChunkSource();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/AgeableMob.java
|
||||
+++ b/net/minecraft/world/entity/AgeableMob.java
|
||||
@@ -20,11 +_,37 @@
|
||||
@@ -20,6 +_,7 @@
|
||||
protected int age;
|
||||
protected int forcedAge;
|
||||
protected int forcedAgeTimer;
|
||||
@@ -8,36 +8,6 @@
|
||||
|
||||
protected AgeableMob(EntityType<? extends AgeableMob> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
+ @Override
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ super.inactiveTick();
|
||||
+ if ( this.level().isClientSide || this.ageLocked )
|
||||
+ { // CraftBukkit
|
||||
+ this.refreshDimensions();
|
||||
+ } else
|
||||
+ {
|
||||
+ int i = this.getAge();
|
||||
+
|
||||
+ if ( i < 0 )
|
||||
+ {
|
||||
+ ++i;
|
||||
+ this.setAge( i );
|
||||
+ } else if ( i > 0 )
|
||||
+ {
|
||||
+ --i;
|
||||
+ this.setAge( i );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
@Override
|
||||
public SpawnGroupData finalizeSpawn(
|
||||
ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnGroupData
|
||||
@@ -66,6 +_,7 @@
|
||||
}
|
||||
|
||||
|
@@ -9,25 +9,6 @@
|
||||
@Nullable
|
||||
public UUID ownerUUID;
|
||||
|
||||
@@ -128,6 +_,18 @@
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
+ // Spigot start - copied from below
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ super.inactiveTick();
|
||||
+
|
||||
+ if (this.tickCount >= this.waitTime + this.duration) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
@@ -177,7 +_,7 @@
|
||||
|
||||
private void serverTick(ServerLevel level) {
|
||||
|
@@ -133,7 +133,7 @@
|
||||
private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0};
|
||||
private long pistonDeltasGameTime;
|
||||
private EntityDimensions dimensions;
|
||||
@@ -250,6 +_,68 @@
|
||||
@@ -250,6 +_,63 @@
|
||||
private final List<Entity.Movement> movementThisTick = new ArrayList<>();
|
||||
private final Set<BlockState> blocksInside = new ReferenceArraySet<>();
|
||||
private final LongSet visitedBlocks = new LongOpenHashSet();
|
||||
@@ -153,12 +153,6 @@
|
||||
+ // Marks an entity, that it was removed by a plugin via Entity#remove
|
||||
+ // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed
|
||||
+ public boolean pluginRemoved = false;
|
||||
+ // Spigot start
|
||||
+ public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
||||
+ public final boolean defaultActivationState;
|
||||
+ public long activatedTick = Integer.MIN_VALUE;
|
||||
+ public void inactiveTick() { }
|
||||
+ // Spigot end
|
||||
+ protected int numCollisions = 0; // Paper - Cap entity collisions
|
||||
+ public boolean fromNetherPortal; // Paper - Add option to nerf pigmen from nether portals
|
||||
+ public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
|
||||
@@ -170,6 +164,7 @@
|
||||
+ public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
+ public boolean fixedPose = false; // Paper - Expand Pose API
|
||||
+ private final int despawnTime; // Paper - entity despawn time limit
|
||||
+ public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges
|
||||
+
|
||||
+ public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) {
|
||||
+ this.origin = location.toVector();
|
||||
@@ -202,20 +197,6 @@
|
||||
|
||||
public Entity(EntityType<?> entityType, Level level) {
|
||||
this.type = entityType;
|
||||
@@ -258,6 +_,13 @@
|
||||
this.position = Vec3.ZERO;
|
||||
this.blockPosition = BlockPos.ZERO;
|
||||
this.chunkPosition = ChunkPos.ZERO;
|
||||
+ // Spigot start
|
||||
+ if (level != null) {
|
||||
+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, level.spigotConfig);
|
||||
+ } else {
|
||||
+ this.defaultActivationState = false;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
SynchedEntityData.Builder builder = new SynchedEntityData.Builder(this);
|
||||
builder.define(DATA_SHARED_FLAGS_ID, (byte)0);
|
||||
builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply());
|
||||
@@ -271,6 +_,7 @@
|
||||
this.entityData = builder.build();
|
||||
this.setPos(0.0, 0.0, 0.0);
|
||||
|
@@ -39,7 +39,7 @@
|
||||
public abstract class LivingEntity extends Entity implements Attackable {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final String TAG_ACTIVE_EFFECTS = "active_effects";
|
||||
@@ -266,11 +_,36 @@
|
||||
@@ -266,11 +_,29 @@
|
||||
EquipmentSlot.class
|
||||
);
|
||||
protected float appliedScale = 1.0F;
|
||||
@@ -59,13 +59,6 @@
|
||||
+ return this.getYHeadRot();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ super.inactiveTick();
|
||||
+ ++this.noActionTime; // Above all the floats
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
protected LivingEntity(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
|
@@ -51,15 +51,12 @@
|
||||
f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
|
||||
}
|
||||
|
||||
@@ -184,11 +_,40 @@
|
||||
@@ -184,8 +_,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!this.level().isClientSide && this.age >= 6000) {
|
||||
- this.discard();
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
|
||||
+ // CraftBukkit start - fire ItemDespawnEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
@@ -68,35 +65,9 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Spigot start - copied from above
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
|
||||
+ --this.pickupDelay;
|
||||
+ }
|
||||
+ if (this.age != -32768) {
|
||||
+ ++this.age;
|
||||
+ }
|
||||
+
|
||||
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
|
||||
+ // CraftBukkit start - fire ItemDespawnEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
+ this.age = 0;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
|
||||
@Override
|
||||
public BlockPos getBlockPosBelowThatAffectsMyMovement() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,9 +_,18 @@
|
||||
|
||||
private void mergeWithNeighbours() {
|
||||
|
@@ -15,24 +15,6 @@
|
||||
public class Villager extends AbstractVillager implements ReputationEventHandler, VillagerDataHolder {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final EntityDataAccessor<VillagerData> DATA_VILLAGER_DATA = SynchedEntityData.defineId(Villager.class, EntityDataSerializers.VILLAGER_DATA);
|
||||
@@ -257,6 +_,17 @@
|
||||
return this.assignProfessionWhenSpawned;
|
||||
}
|
||||
|
||||
+ // Spigot Start
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :(
|
||||
+ if (this.level().spigotConfig.tickInactiveVillagers && this.isEffectiveAi()) {
|
||||
+ this.customServerAiStep((ServerLevel) this.level());
|
||||
+ }
|
||||
+ super.inactiveTick();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
@@ -275,7 +_,7 @@
|
||||
this.increaseProfessionLevelOnUpdate = false;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -63,16 +_,26 @@
|
||||
@@ -63,16 +_,16 @@
|
||||
protected int inGroundTime;
|
||||
public AbstractArrow.Pickup pickup = AbstractArrow.Pickup.DISALLOWED;
|
||||
public int shakeTime;
|
||||
@@ -26,16 +26,6 @@
|
||||
@Nullable
|
||||
- private ItemStack firedFromWeapon = null;
|
||||
+ public ItemStack firedFromWeapon = null; // Paper - private -> public
|
||||
+
|
||||
+ // Spigot Start
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ if (this.isInGround()) {
|
||||
+ this.life += 1;
|
||||
+ }
|
||||
+ super.inactiveTick();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
protected AbstractArrow(EntityType<? extends AbstractArrow> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
|
@@ -8,33 +8,6 @@
|
||||
|
||||
public FireworkRocketEntity(EntityType<? extends FireworkRocketEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -84,6 +_,26 @@
|
||||
this.setOwner(shooter);
|
||||
}
|
||||
|
||||
+ // Spigot Start - copied from tick
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ this.life += 1;
|
||||
+
|
||||
+ if (this.life > this.lifetime) {
|
||||
+ Level world = this.level();
|
||||
+
|
||||
+ if (world instanceof ServerLevel serverLevel) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
|
||||
+ this.explode(serverLevel);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
+ super.inactiveTick();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
builder.define(DATA_ID_FIREWORKS_ITEM, getDefaultItem());
|
||||
@@ -158,7 +_,7 @@
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user