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 d0b46ac94b..4bd9de4f7f 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; @@ -170,7 +170,7 @@ private static final EntityDataAccessor DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT); private EntityInLevelCallback levelCallback; private final VecDeltaCodec packetPositionCodec; -@@ -253,6 +386,64 @@ +@@ -253,7 +386,65 @@ private final List movementThisTick; private final Set blocksInside; private final LongSet visitedBlocks; @@ -203,7 +203,7 @@ + private org.bukkit.util.Vector origin; + @javax.annotation.Nullable + private UUID originWorld; -+ + + public void setOrigin(@javax.annotation.Nonnull Location location) { + this.origin = location.toVector(); + this.originWorld = location.getWorld().getUID(); @@ -232,9 +232,10 @@ + return this.dimensions.makeBoundingBox(x, y, z); + } + // Paper end - ++ public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); + this.passengers = ImmutableList.of(); @@ -261,7 +452,7 @@ this.bb = Entity.INITIAL_AABB; this.stuckSpeedMultiplier = Vec3.ZERO; @@ -594,7 +595,15 @@ this.setPosRaw(x, y, z); this.setYRot(yaw); this.setXRot(pitch); -@@ -1737,7 +2084,21 @@ +@@ -1701,6 +2048,7 @@ + public void push(Entity entity) { + if (!this.isPassengerOfSameVehicle(entity)) { + if (!entity.noPhysics && !this.noPhysics) { ++ if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant + double d0 = entity.getX() - this.getX(); + double d1 = entity.getZ() - this.getZ(); + double d2 = Mth.absMax(d0, d1); +@@ -1737,7 +2085,21 @@ } public void push(double deltaX, double deltaY, double deltaZ) { @@ -617,7 +626,7 @@ this.hasImpulse = true; } -@@ -1858,9 +2219,21 @@ +@@ -1858,9 +2220,21 @@ } public boolean isPushable() { @@ -639,7 +648,7 @@ public void awardKillScore(Entity entityKilled, DamageSource damageSource) { if (entityKilled instanceof ServerPlayer) { CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource); -@@ -1889,16 +2262,22 @@ +@@ -1889,16 +2263,22 @@ } public boolean saveAsPassenger(CompoundTag nbt) { @@ -665,7 +674,7 @@ return true; } } -@@ -1909,54 +2288,98 @@ +@@ -1909,54 +2289,98 @@ } public CompoundTag saveWithoutId(CompoundTag nbt) { @@ -784,7 +793,7 @@ } ListTag nbttaglist; -@@ -1972,10 +2395,10 @@ +@@ -1972,10 +2396,10 @@ nbttaglist.add(StringTag.valueOf(s)); } @@ -797,7 +806,7 @@ if (this.isVehicle()) { nbttaglist = new ListTag(); iterator = this.getPassengers().iterator(); -@@ -1984,17 +2407,41 @@ +@@ -1984,17 +2408,41 @@ Entity entity = (Entity) iterator.next(); CompoundTag nbttagcompound1 = new CompoundTag(); @@ -842,7 +851,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); -@@ -2080,6 +2527,68 @@ +@@ -2080,6 +2528,68 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -911,7 +920,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -2101,6 +2610,12 @@ +@@ -2101,6 +2611,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -924,7 +933,7 @@ protected abstract void readAdditionalSaveData(CompoundTag nbt); protected abstract void addAdditionalSaveData(CompoundTag nbt); -@@ -2153,9 +2668,23 @@ +@@ -2153,9 +2669,23 @@ if (stack.isEmpty()) { return null; } else { @@ -949,7 +958,7 @@ world.addFreshEntity(entityitem); return entityitem; } -@@ -2184,6 +2713,12 @@ +@@ -2184,6 +2714,12 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -962,7 +971,7 @@ if (player.hasInfiniteMaterials()) { leashable.removeLeash(); } else { -@@ -2200,6 +2735,13 @@ +@@ -2200,6 +2736,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -976,7 +985,7 @@ leashable.setLeashedTo(player, true); } -@@ -2265,7 +2807,7 @@ +@@ -2265,7 +2808,7 @@ } public boolean showVehicleHealth() { @@ -985,7 +994,7 @@ } public boolean startRiding(Entity entity, boolean force) { -@@ -2273,7 +2815,7 @@ +@@ -2273,7 +2816,7 @@ return false; } else if (!entity.couldAcceptPassenger()) { return false; @@ -994,7 +1003,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2285,11 +2827,32 @@ +@@ -2285,11 +2828,32 @@ if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -1028,7 +1037,7 @@ this.vehicle = entity; this.vehicle.addPassenger(this); entity.getIndirectPassengersStream().filter((entity2) -> { -@@ -2314,19 +2877,30 @@ +@@ -2314,19 +2878,30 @@ } public void removeVehicle() { @@ -1061,7 +1070,7 @@ protected void addPassenger(Entity passenger) { if (passenger.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); -@@ -2349,21 +2923,53 @@ +@@ -2349,21 +2924,53 @@ } } @@ -1121,7 +1130,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2464,7 +3070,7 @@ +@@ -2464,7 +3071,7 @@ if (teleporttransition != null) { ServerLevel worldserver1 = teleporttransition.newLevel(); @@ -1130,7 +1139,7 @@ this.teleport(teleporttransition); } } -@@ -2547,7 +3153,7 @@ +@@ -2547,7 +3154,7 @@ } public boolean isCrouching() { @@ -1139,7 +1148,7 @@ } public boolean isSprinting() { -@@ -2563,7 +3169,7 @@ +@@ -2563,7 +3170,7 @@ } public boolean isVisuallySwimming() { @@ -1148,7 +1157,7 @@ } public boolean isVisuallyCrawling() { -@@ -2571,6 +3177,13 @@ +@@ -2571,6 +3178,13 @@ } public void setSwimming(boolean swimming) { @@ -1162,7 +1171,7 @@ this.setSharedFlag(4, swimming); } -@@ -2609,6 +3222,7 @@ +@@ -2609,6 +3223,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1170,7 +1179,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2624,8 +3238,12 @@ +@@ -2624,8 +3239,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; } @@ -1184,7 +1193,7 @@ } public boolean getSharedFlag(int index) { -@@ -2644,7 +3262,7 @@ +@@ -2644,7 +3263,7 @@ } public int getMaxAirSupply() { @@ -1193,7 +1202,7 @@ } public int getAirSupply() { -@@ -2652,7 +3270,18 @@ +@@ -2652,7 +3271,18 @@ } public void setAirSupply(int air) { @@ -1213,7 +1222,7 @@ } public int getTicksFrozen() { -@@ -2679,11 +3308,40 @@ +@@ -2679,11 +3309,40 @@ public void thunderHit(ServerLevel world, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1256,7 +1265,7 @@ } public void onAboveBubbleCol(boolean drag) { -@@ -2713,7 +3371,7 @@ +@@ -2713,7 +3372,7 @@ this.resetFallDistance(); } @@ -1265,7 +1274,7 @@ return true; } -@@ -2818,7 +3476,7 @@ +@@ -2818,7 +3477,7 @@ public String toString() { String s = this.level() == null ? "~NULL~" : this.level().toString(); @@ -1274,7 +1283,7 @@ } public final boolean isInvulnerableToBase(DamageSource damageSource) { -@@ -2850,8 +3508,34 @@ +@@ -2850,8 +3509,34 @@ public Entity teleport(TeleportTransition teleportTarget) { Level world = this.level(); @@ -1309,7 +1318,7 @@ ServerLevel worldserver1 = teleportTarget.newLevel(); boolean flag = worldserver1.dimension() != worldserver.dimension(); -@@ -2918,10 +3602,19 @@ +@@ -2918,10 +3603,19 @@ gameprofilerfiller.pop(); return null; } else { @@ -1330,7 +1339,7 @@ Iterator iterator1 = list1.iterator(); while (iterator1.hasNext()) { -@@ -2947,7 +3640,7 @@ +@@ -2947,7 +3641,7 @@ } private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { @@ -1339,7 +1348,7 @@ Iterator iterator = this.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -2995,8 +3688,9 @@ +@@ -2995,8 +3689,9 @@ } protected void removeAfterChangingDimensions() { @@ -1350,7 +1359,7 @@ leashable.removeLeash(); } -@@ -3004,13 +3698,28 @@ +@@ -3004,13 +3699,28 @@ public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) { return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); @@ -1379,7 +1388,7 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { Iterator iterator = this.getPassengers().iterator(); -@@ -3134,10 +3843,16 @@ +@@ -3134,10 +3844,16 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } @@ -1399,7 +1408,7 @@ return entity != null; } -@@ -3187,7 +3902,7 @@ +@@ -3187,7 +3903,7 @@ /** @deprecated */ @Deprecated protected void fixupDimensions() { @@ -1408,7 +1417,7 @@ EntityDimensions entitysize = this.getDimensions(entitypose); this.dimensions = entitysize; -@@ -3196,7 +3911,7 @@ +@@ -3196,7 +3912,7 @@ public void refreshDimensions() { EntityDimensions entitysize = this.dimensions; @@ -1417,7 +1426,7 @@ EntityDimensions entitysize1 = this.getDimensions(entitypose); this.dimensions = entitysize1; -@@ -3258,10 +3973,29 @@ +@@ -3258,10 +3974,29 @@ } public final void setBoundingBox(AABB boundingBox) { @@ -1449,7 +1458,7 @@ return this.getDimensions(pose).eyeHeight(); } -@@ -3335,7 +4069,7 @@ +@@ -3335,7 +4070,7 @@ } @Nullable @@ -1458,7 +1467,7 @@ return null; } -@@ -3435,7 +4169,7 @@ +@@ -3435,7 +4170,7 @@ } public boolean isControlledByLocalInstance() { @@ -1467,7 +1476,7 @@ if (entityliving instanceof Player entityhuman) { return entityhuman.isLocalPlayer(); -@@ -3445,7 +4179,7 @@ +@@ -3445,7 +4180,7 @@ } public boolean isControlledByClient() { @@ -1476,7 +1485,7 @@ return entityliving != null && entityliving.isControlledByClient(); } -@@ -3463,7 +4197,7 @@ +@@ -3463,7 +4198,7 @@ return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); } @@ -1485,7 +1494,7 @@ return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); } -@@ -3489,8 +4223,37 @@ +@@ -3489,8 +4224,37 @@ return 1; } @@ -1524,7 +1533,7 @@ } public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { -@@ -3551,6 +4314,11 @@ +@@ -3551,6 +4315,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -1536,7 +1545,7 @@ } } } -@@ -3613,7 +4381,7 @@ +@@ -3613,7 +4382,7 @@ return new ClientboundAddEntityPacket(this, entityTrackerEntry); } @@ -1545,7 +1554,7 @@ return this.type.getDimensions(); } -@@ -3713,8 +4481,40 @@ +@@ -3713,8 +4482,40 @@ public double getRandomZ(double widthScale) { return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); } @@ -1586,7 +1595,7 @@ if (this.position.x != x || this.position.y != y || this.position.z != z) { this.position = new Vec3(x, y, z); int i = Mth.floor(x); -@@ -3732,6 +4532,12 @@ +@@ -3732,6 +4533,12 @@ this.levelCallback.onMove(); } @@ -1599,7 +1608,7 @@ } public void checkDespawn() {} -@@ -3818,8 +4624,16 @@ +@@ -3818,8 +4625,16 @@ @Override public final void setRemoved(Entity.RemovalReason reason) { @@ -1617,7 +1626,7 @@ } if (this.removalReason.shouldDestroy()) { -@@ -3827,8 +4641,8 @@ +@@ -3827,8 +4642,8 @@ } this.getPassengers().forEach(Entity::stopRiding); @@ -1628,7 +1637,7 @@ } public void unsetRemoved() { -@@ -3887,7 +4701,7 @@ +@@ -3887,7 +4702,7 @@ } public Vec3 getKnownMovement() { @@ -1637,7 +1646,7 @@ if (entityliving instanceof Player entityhuman) { if (this.isAlive()) { -@@ -3962,4 +4776,14 @@ +@@ -3962,4 +4777,14 @@ void accept(Entity entity, double x, double y, double z); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index 5981350c5e..28b20b3791 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -39,8 +39,11 @@ return true; } -@@ -182,9 +198,29 @@ +@@ -180,11 +196,32 @@ + + @Override public void push(Entity entity) { ++ if (!this.level().paperConfig().collisions.allowVehicleCollisions && this.level().paperConfig().collisions.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper - Collision option for requiring a player participant if (entity instanceof AbstractBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start @@ -69,7 +72,7 @@ super.push(entity); } -@@ -247,6 +283,7 @@ +@@ -247,6 +284,7 @@ return this.getDirection().getClockWise(); } @@ -77,7 +80,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -287,6 +324,21 @@ +@@ -287,6 +325,21 @@ this.setDeltaMovement(Vec3.ZERO); } @@ -99,7 +102,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -790,11 +842,18 @@ +@@ -790,11 +843,18 @@ @Override public void remove(Entity.RemovalReason reason) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index a22e8138be..c3f8a4e351 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -106,9 +106,11 @@ } } -@@ -521,6 +563,14 @@ +@@ -520,7 +562,16 @@ + public void push(Entity entity) { if (!this.level().isClientSide) { if (!entity.noPhysics && !this.noPhysics) { ++ if (!this.level().paperConfig().collisions.allowVehicleCollisions && this.level().paperConfig().collisions.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper - Collision option for requiring a player participant if (!this.hasPassenger(entity)) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); @@ -121,7 +123,7 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; -@@ -645,4 +695,27 @@ +@@ -645,4 +696,27 @@ public boolean isFurnace() { return false; }