From 679c2f7c9fa186da0513a68542d2a44b25309d84 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 14 Dec 2024 13:05:27 +0100 Subject: [PATCH] More more entity classes --- .../world/entity/AgeableMob.java.patch | 49 +++--- .../world/entity/AreaEffectCloud.java.patch | 117 +++++++++++++ .../world/entity/ConversionParams.java.patch | 4 +- .../world/entity/ConversionType.java.patch | 11 ++ .../minecraft/world/entity/Display.java.patch | 11 ++ .../world/entity/EntitySelector.java.patch | 49 ++++++ .../world/entity/Interaction.java.patch | 20 +++ .../world/entity/ItemBasedSteering.java.patch | 4 +- .../world/entity/AreaEffectCloud.java.patch | 160 ------------------ .../world/entity/ConversionType.java.patch | 46 ----- .../minecraft/world/entity/Display.java.patch | 11 -- .../world/entity/EntitySelector.java.patch | 49 ------ .../world/entity/Interaction.java.patch | 42 ----- 13 files changed, 236 insertions(+), 337 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/AgeableMob.java.patch (54%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ConversionParams.java.patch (88%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ItemBasedSteering.java.patch (84%) delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/AreaEffectCloud.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/ConversionType.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/Display.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/EntitySelector.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/Interaction.java.patch diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/AgeableMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch similarity index 54% rename from paper-server/patches/unapplied/net/minecraft/world/entity/AgeableMob.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch index 5748ed58a8..c9a6111f89 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/AgeableMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -21,12 +21,38 @@ +@@ -20,11 +_,37 @@ protected int age; protected int forcedAge; protected int forcedAgeTimer; + public boolean ageLocked; // CraftBukkit - protected AgeableMob(EntityType type, Level world) { - super(type, world); + protected AgeableMob(EntityType entityType, Level level) { + super(entityType, level); } + // Spigot start - @Override ++ @Override + public void inactiveTick() + { + super.inactiveTick(); @@ -35,35 +35,34 @@ + } + // Spigot end + -+ @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData entityData) { - if (entityData == null) { - entityData = new AgeableMob.AgeableMobGroupData(true); -@@ -60,6 +86,7 @@ + @Override + public SpawnGroupData finalizeSpawn( + ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnGroupData +@@ -66,6 +_,7 @@ } - public void ageUp(int age, boolean overGrow) { + public void ageUp(int amount, boolean forced) { + if (this.ageLocked) return; // Paper - Honor ageLock - int j = this.getAge(); - int k = j; - -@@ -104,6 +131,7 @@ - super.addAdditionalSaveData(nbt); - nbt.putInt("Age", this.getAge()); - nbt.putInt("ForcedAge", this.forcedAge); -+ nbt.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit + int age = this.getAge(); + age += amount * 20; + if (age > 0) { +@@ -104,6 +_,7 @@ + super.addAdditionalSaveData(tag); + tag.putInt("Age", this.getAge()); + tag.putInt("ForcedAge", this.forcedAge); ++ tag.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit } @Override -@@ -111,6 +139,7 @@ - super.readAdditionalSaveData(nbt); - this.setAge(nbt.getInt("Age")); - this.forcedAge = nbt.getInt("ForcedAge"); -+ this.ageLocked = nbt.getBoolean("AgeLocked"); // CraftBukkit +@@ -111,6 +_,7 @@ + super.readAdditionalSaveData(tag); + this.setAge(tag.getInt("Age")); + this.forcedAge = tag.getInt("ForcedAge"); ++ this.ageLocked = tag.getBoolean("AgeLocked"); // CraftBukkit } @Override -@@ -125,7 +154,7 @@ +@@ -125,7 +_,7 @@ @Override public void aiStep() { super.aiStep(); @@ -71,4 +70,4 @@ + if (this.level().isClientSide || this.ageLocked) { // CraftBukkit if (this.forcedAgeTimer > 0) { if (this.forcedAgeTimer % 4 == 0) { - this.level().addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D); + this.level().addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0), this.getRandomY() + 0.5, this.getRandomZ(1.0), 0.0, 0.0, 0.0); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch new file mode 100644 index 0000000000..1f6b41bf6d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -0,0 +1,117 @@ +--- a/net/minecraft/world/entity/AreaEffectCloud.java ++++ b/net/minecraft/world/entity/AreaEffectCloud.java +@@ -47,7 +_,7 @@ + public float radiusOnUse; + public float radiusPerTick; + @Nullable +- private LivingEntity owner; ++ private net.minecraft.world.entity.LivingEntity owner; + @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) { + if (this.tickCount >= this.waitTime + this.duration) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } else { + boolean isWaiting = this.isWaiting(); + boolean flag = this.tickCount < this.waitTime; +@@ -190,7 +_,7 @@ + if (this.radiusPerTick != 0.0F) { + radius += this.radiusPerTick; + if (radius < 0.5F) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } + +@@ -220,6 +_,7 @@ + list.addAll(this.potionContents.customEffects()); + List entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); + if (!entitiesOfClass.isEmpty()) { ++ List entities = new java.util.ArrayList<>(); // CraftBukkit + for (LivingEntity livingEntity : entitiesOfClass) { + if (!this.victims.containsKey(livingEntity) + && livingEntity.isAffectedByPotions() +@@ -228,6 +_,17 @@ + double d1 = livingEntity.getZ() - this.getZ(); + double d2 = d * d + d1 * d1; + if (d2 <= radius * radius) { ++ // CraftBukkit start ++ entities.add((org.bukkit.entity.LivingEntity) livingEntity.getBukkitEntity()); ++ } ++ } ++ } ++ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); ++ if (!event.isCancelled()) { ++ for (org.bukkit.entity.LivingEntity entity : event.getAffectedEntities()) { ++ if (entity instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity) { ++ net.minecraft.world.entity.LivingEntity livingEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity).getHandle(); ++ // CraftBukkit end + this.victims.put(livingEntity, this.tickCount + this.reapplicationDelay); + + for (MobEffectInstance mobEffectInstance1 : list) { +@@ -236,14 +_,14 @@ + .value() + .applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance1.getAmplifier(), 0.5); + } else { +- livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this); ++ livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + } + } + + if (this.radiusOnUse != 0.0F) { + radius += this.radiusOnUse; + if (radius < 0.5F) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } + +@@ -253,7 +_,7 @@ + if (this.durationOnUse != 0) { + this.duration = this.duration + this.durationOnUse; + if (this.duration <= 0) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } + } +@@ -299,14 +_,14 @@ + this.waitTime = waitTime; + } + +- public void setOwner(@Nullable LivingEntity owner) { ++ public void setOwner(@Nullable net.minecraft.world.entity.LivingEntity owner) { + this.owner = owner; + this.ownerUUID = owner == null ? null : owner.getUUID(); + } + + @Nullable + @Override +- public LivingEntity getOwner() { ++ public net.minecraft.world.entity.LivingEntity getOwner() { + if (this.owner != null && !this.owner.isRemoved()) { + return this.owner; + } else { diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ConversionParams.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ConversionParams.java.patch similarity index 88% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ConversionParams.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ConversionParams.java.patch index 3673cd3667..2be9008a50 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ConversionParams.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ConversionParams.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ConversionParams.java +++ b/net/minecraft/world/entity/ConversionParams.java -@@ -12,4 +12,11 @@ +@@ -12,4 +_,11 @@ public interface AfterConversion { - void finalizeConversion(T convertedEntity); + void finalizeConversion(T mob); } + + // Paper start - entity zap event - allow conversion to be cancelled during finalization diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch new file mode 100644 index 0000000000..1bd938bdbe --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ConversionType.java ++++ b/net/minecraft/world/entity/ConversionType.java +@@ -21,7 +_,7 @@ + + for (Entity entity : newMob.getPassengers()) { + entity.stopRiding(); +- entity.remove(Entity.RemovalReason.DISCARDED); ++ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause + } + + firstPassenger.startRiding(newMob); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch new file mode 100644 index 0000000000..467ae36f2f --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/Display.java ++++ b/net/minecraft/world/entity/Display.java +@@ -213,7 +_,7 @@ + if (tag.contains("transformation")) { + Transformation.EXTENDED_CODEC + .decode(NbtOps.INSTANCE, tag.get("transformation")) +- .resultOrPartial(Util.prefix("Display entity", LOGGER::error)) ++ .result() // Paper - Hide text display error on spawn + .ifPresent(pair -> this.setTransformation(pair.getFirst())); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch new file mode 100644 index 0000000000..5ecfaf92e4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/entity/EntitySelector.java ++++ b/net/minecraft/world/entity/EntitySelector.java +@@ -16,6 +_,23 @@ + public static final Predicate NO_SPECTATORS = entity -> !entity.isSpectator(); + public static final Predicate CAN_BE_COLLIDED_WITH = NO_SPECTATORS.and(Entity::canBeCollidedWith); + public static final Predicate CAN_BE_PICKED = NO_SPECTATORS.and(Entity::isPickable); ++ // Paper start - Ability to control player's insomnia and phantoms ++ public static Predicate IS_INSOMNIAC = (player) -> { ++ net.minecraft.server.level.ServerPlayer serverPlayer = (net.minecraft.server.level.ServerPlayer) player; ++ int playerInsomniaTicks = serverPlayer.level().paperConfig().entities.behavior.playerInsomniaStartTicks; ++ ++ if (playerInsomniaTicks <= 0) { ++ return false; ++ } ++ ++ return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks; ++ }; ++ // Paper end - Ability to control player's insomnia and phantoms ++ // Paper start - Affects Spawning API ++ public static final Predicate PLAYER_AFFECTS_SPAWNING = (entity) -> { ++ return !entity.isSpectator() && entity.isAlive() && entity instanceof Player player && player.affectsSpawning; ++ }; ++ // Paper end - Affects Spawning API + + private EntitySelector() { + } +@@ -26,15 +_,20 @@ + } + + public static Predicate pushableBy(Entity entity) { ++ // Paper start - Climbing should not bypass cramming gamerule ++ return pushable(entity, false); ++ } ++ public static Predicate pushable(Entity entity, boolean ignoreClimbing) { ++ // Paper end - Climbing should not bypass cramming gamerule + Team team = entity.getTeam(); + Team.CollisionRule collisionRule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule(); + return (Predicate)(collisionRule == Team.CollisionRule.NEVER + ? Predicates.alwaysFalse() + : NO_SPECTATORS.and( + pushedEntity -> { +- if (!pushedEntity.isPushable()) { ++ if (!pushedEntity.isCollidable(ignoreClimbing) || !pushedEntity.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(pushedEntity)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule + return false; +- } else if (!entity.level().isClientSide || pushedEntity instanceof Player && ((Player)pushedEntity).isLocalPlayer()) { ++ } else if (pushedEntity instanceof Player && entity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions) { // Paper - Configurable player collision + Team team1 = pushedEntity.getTeam(); + Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule(); + if (collisionRule1 == Team.CollisionRule.NEVER) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch new file mode 100644 index 0000000000..3d9857c808 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/Interaction.java ++++ b/net/minecraft/world/entity/Interaction.java +@@ -130,9 +_,16 @@ + @Override + public boolean skipAttackInteraction(Entity entity) { + if (entity instanceof Player player) { ++ // CraftBukkit start ++ DamageSource source = player.damageSources().playerAttack(player); ++ org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false); ++ if (event.isCancelled()) { ++ return true; ++ } ++ // CraftBukkit end + this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime()); + if (player instanceof ServerPlayer serverPlayer) { +- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, 1.0F, false); ++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order + } + + return !this.getResponse(); diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ItemBasedSteering.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch similarity index 84% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ItemBasedSteering.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch index 2f4eab4bc8..cd34eb69a7 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ItemBasedSteering.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ItemBasedSteering.java +++ b/net/minecraft/world/entity/ItemBasedSteering.java -@@ -53,6 +53,14 @@ - return (Integer) this.entityData.get(this.boostTimeAccessor); +@@ -51,6 +_,14 @@ + return this.entityData.get(this.boostTimeAccessor); } + // CraftBukkit add setBoostTicks(int) diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/AreaEffectCloud.java.patch deleted file mode 100644 index 835489e22c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/AreaEffectCloud.java.patch +++ /dev/null @@ -1,160 +0,0 @@ ---- a/net/minecraft/world/entity/AreaEffectCloud.java -+++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -33,6 +33,12 @@ - import net.minecraft.world.level.material.PushReaction; - import org.slf4j.Logger; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.entity.CraftLivingEntity; -+import org.bukkit.entity.LivingEntity; -+import org.bukkit.event.entity.EntityRemoveEvent; -+// CraftBukkit end -+ - public class AreaEffectCloud extends Entity implements TraceableEntity { - - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -54,7 +60,7 @@ - public float radiusOnUse; - public float radiusPerTick; - @Nullable -- private LivingEntity owner; -+ private net.minecraft.world.entity.LivingEntity owner; - @Nullable - public UUID ownerUUID; - -@@ -145,7 +151,19 @@ - this.duration = duration; - } - -+ // Spigot start - copied from below - @Override -+ public void inactiveTick() { -+ super.inactiveTick(); -+ -+ if (this.tickCount >= this.waitTime + this.duration) { -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause -+ return; -+ } -+ } -+ // Spigot end -+ -+ @Override - public void tick() { - super.tick(); - Level world = this.level(); -@@ -200,7 +218,7 @@ - - private void serverTick(ServerLevel world) { - if (this.tickCount >= this.waitTime + this.duration) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } else { - boolean flag = this.isWaiting(); - boolean flag1 = this.tickCount < this.waitTime; -@@ -215,7 +233,7 @@ - if (this.radiusPerTick != 0.0F) { - f += this.radiusPerTick; - if (f < 0.5F) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } - -@@ -244,16 +262,17 @@ - } - - list.addAll(this.potionContents.customEffects()); -- List list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); -+ List list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, this.getBoundingBox()); - - if (!list1.isEmpty()) { - Iterator iterator1 = list1.iterator(); - -+ List entities = new java.util.ArrayList(); // CraftBukkit - while (iterator1.hasNext()) { -- LivingEntity entityliving = (LivingEntity) iterator1.next(); -+ net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator1.next(); - - if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { -- Stream stream = list.stream(); -+ Stream stream = list.stream(); // CraftBukkit - decompile error - - Objects.requireNonNull(entityliving); - if (!stream.noneMatch(entityliving::canBeAffected)) { -@@ -262,6 +281,19 @@ - double d2 = d0 * d0 + d1 * d1; - - if (d2 <= (double) (f * f)) { -+ // CraftBukkit start -+ entities.add((LivingEntity) entityliving.getBukkitEntity()); -+ } -+ } -+ } -+ } -+ { -+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); -+ if (!event.isCancelled()) { -+ for (LivingEntity entity : event.getAffectedEntities()) { -+ if (entity instanceof CraftLivingEntity) { -+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) entity).getHandle(); -+ // CraftBukkit end - this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); - Iterator iterator2 = list.iterator(); - -@@ -271,14 +303,14 @@ - if (((MobEffect) mobeffect1.getEffect().value()).isInstantenous()) { - ((MobEffect) mobeffect1.getEffect().value()).applyInstantenousEffect(world, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); - } else { -- entityliving.addEffect(new MobEffectInstance(mobeffect1), this); -+ entityliving.addEffect(new MobEffectInstance(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit - } - } - - if (this.radiusOnUse != 0.0F) { - f += this.radiusOnUse; - if (f < 0.5F) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } - -@@ -288,7 +320,7 @@ - if (this.durationOnUse != 0) { - this.duration += this.durationOnUse; - if (this.duration <= 0) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } - } -@@ -336,14 +368,14 @@ - this.waitTime = waitTime; - } - -- public void setOwner(@Nullable LivingEntity owner) { -+ public void setOwner(@Nullable net.minecraft.world.entity.LivingEntity owner) { - this.owner = owner; - this.ownerUUID = owner == null ? null : owner.getUUID(); - } - - @Nullable - @Override -- public LivingEntity getOwner() { -+ public net.minecraft.world.entity.LivingEntity getOwner() { - if (this.owner != null && !this.owner.isRemoved()) { - return this.owner; - } else { -@@ -353,10 +385,10 @@ - if (world instanceof ServerLevel) { - ServerLevel worldserver = (ServerLevel) world; - Entity entity = worldserver.getEntity(this.ownerUUID); -- LivingEntity entityliving; -+ net.minecraft.world.entity.LivingEntity entityliving; - -- if (entity instanceof LivingEntity) { -- LivingEntity entityliving1 = (LivingEntity) entity; -+ if (entity instanceof net.minecraft.world.entity.LivingEntity) { -+ net.minecraft.world.entity.LivingEntity entityliving1 = (net.minecraft.world.entity.LivingEntity) entity; - - entityliving = entityliving1; - } else { diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ConversionType.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/ConversionType.java.patch deleted file mode 100644 index ed6daf39bf..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ConversionType.java.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/net/minecraft/world/entity/ConversionType.java -+++ b/net/minecraft/world/entity/ConversionType.java -@@ -4,6 +4,7 @@ - import java.util.Objects; - import java.util.Optional; - import java.util.Set; -+import net.minecraft.core.BlockPos; - import net.minecraft.world.effect.MobEffectInstance; - import net.minecraft.world.entity.ai.Brain; - import net.minecraft.world.entity.ai.memory.MemoryModuleType; -@@ -11,6 +12,8 @@ - import net.minecraft.world.entity.monster.Zombie; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.scores.Scoreboard; -+import org.bukkit.event.entity.EntityRemoveEvent; -+// CraftBukkit end - - public enum ConversionType { - -@@ -31,7 +34,7 @@ - while (iterator.hasNext()) { - entity1 = (Entity) iterator.next(); - entity1.stopRiding(); -- entity1.remove(Entity.RemovalReason.DISCARDED); -+ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause - } - - entity.startRiding(newEntity); -@@ -64,7 +67,7 @@ - newEntity.hurtTime = oldEntity.hurtTime; - newEntity.yBodyRot = oldEntity.yBodyRot; - newEntity.setOnGround(oldEntity.onGround()); -- Optional optional = oldEntity.getSleepingPos(); -+ Optional optional = oldEntity.getSleepingPos(); // CraftBukkit - decompile error - - Objects.requireNonNull(newEntity); - optional.ifPresent(newEntity::setSleepingPos); -@@ -156,7 +159,7 @@ - newEntity.setNoGravity(oldEntity.isNoGravity()); - newEntity.setPortalCooldown(oldEntity.getPortalCooldown()); - newEntity.setSilent(oldEntity.isSilent()); -- Set set = oldEntity.getTags(); -+ Set set = oldEntity.getTags(); // CraftBukkit - decompile error - - Objects.requireNonNull(newEntity); - set.forEach(newEntity::addTag); diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/Display.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/Display.java.patch deleted file mode 100644 index 893b7a911c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/Display.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/Display.java -+++ b/net/minecraft/world/entity/Display.java -@@ -903,7 +903,7 @@ - b = loadFlag(b, nbt, "default_background", (byte)4); - Optional optional = Display.TextDisplay.Align.CODEC - .decode(NbtOps.INSTANCE, nbt.get("alignment")) -- .resultOrPartial(Util.prefix("Display entity", Display.LOGGER::error)) -+ .result() // Paper - Hide text display error on spawn - .map(Pair::getFirst); - if (optional.isPresent()) { - b = switch ((Display.TextDisplay.Align)optional.get()) { diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/EntitySelector.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/EntitySelector.java.patch deleted file mode 100644 index e79a8f240b..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/EntitySelector.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/world/entity/EntitySelector.java -+++ b/net/minecraft/world/entity/EntitySelector.java -@@ -27,8 +27,25 @@ - }; - public static final Predicate CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith); - public static final Predicate CAN_BE_PICKED = EntitySelector.NO_SPECTATORS.and(Entity::isPickable); -+ // Paper start - Ability to control player's insomnia and phantoms -+ public static Predicate IS_INSOMNIAC = (player) -> { -+ net.minecraft.server.level.ServerPlayer serverPlayer = (net.minecraft.server.level.ServerPlayer) player; -+ int playerInsomniaTicks = serverPlayer.level().paperConfig().entities.behavior.playerInsomniaStartTicks; - -+ if (playerInsomniaTicks <= 0) { -+ return false; -+ } -+ -+ return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks; -+ }; -+ // Paper end - Ability to control player's insomnia and phantoms -+ - private EntitySelector() {} -+ // Paper start - Affects Spawning API -+ public static final Predicate PLAYER_AFFECTS_SPAWNING = (entity) -> { -+ return !entity.isSpectator() && entity.isAlive() && entity instanceof Player player && player.affectsSpawning; -+ }; -+ // Paper end - Affects Spawning API - - public static Predicate withinDistance(double x, double y, double z, double max) { - double d4 = max * max; -@@ -39,13 +56,18 @@ - } - - public static Predicate pushableBy(Entity entity) { -+ // Paper start - Climbing should not bypass cramming gamerule -+ return pushable(entity, false); -+ } -+ public static Predicate pushable(Entity entity, boolean ignoreClimbing) { -+ // Paper end - Climbing should not bypass cramming gamerule - PlayerTeam scoreboardteam = entity.getTeam(); - Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteam == null ? Team.CollisionRule.ALWAYS : scoreboardteam.getCollisionRule(); - - return (Predicate) (scoreboardteambase_enumteampush == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : EntitySelector.NO_SPECTATORS.and((entity1) -> { -- if (!entity1.isPushable()) { -+ if (!entity1.isCollidable(ignoreClimbing) || !entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule - return false; -- } else if (entity.level().isClientSide && (!(entity1 instanceof Player) || !((Player) entity1).isLocalPlayer())) { -+ } else if (entity1 instanceof Player && entity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions) { // Paper - Configurable player collision - return false; - } else { - PlayerTeam scoreboardteam1 = entity1.getTeam(); diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/Interaction.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/Interaction.java.patch deleted file mode 100644 index 4ee0117128..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/Interaction.java.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/net/minecraft/world/entity/Interaction.java -+++ b/net/minecraft/world/entity/Interaction.java -@@ -27,6 +27,12 @@ - import net.minecraft.world.phys.Vec3; - import org.slf4j.Logger; - -+// CraftBukkit start -+import net.minecraft.world.damagesource.DamageSource; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityDamageEvent; -+// CraftBukkit end -+ - public class Interaction extends Entity implements Attackable, Targeting { - - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -65,7 +71,7 @@ - this.setHeight(nbt.getFloat("height")); - } - -- DataResult dataresult; -+ DataResult> dataresult; // CraftBukkit - decompile error - Logger logger; - - if (nbt.contains("attack")) { -@@ -145,9 +151,16 @@ - @Override - public boolean skipAttackInteraction(Entity attacker) { - if (attacker instanceof Player entityhuman) { -+ // CraftBukkit start -+ DamageSource source = entityhuman.damageSources().playerAttack(entityhuman); -+ EntityDamageEvent event = CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false); -+ if (event.isCancelled()) { -+ return true; -+ } -+ // CraftBukkit end - this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level().getGameTime()); - if (entityhuman instanceof ServerPlayer entityplayer) { -- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, 1.0F, false); -+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order - } - - return !this.getResponse();