diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch index ce4f7224e8..afdc4205f7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -126,8 +126,65 @@ +@@ -126,8 +126,67 @@ import org.joml.Vector3f; import org.slf4j.Logger; @@ -28,7 +28,9 @@ +import org.bukkit.entity.Pose; +import org.bukkit.event.entity.EntityAirChangeEvent; +import org.bukkit.event.entity.EntityCombustEvent; ++import org.bukkit.event.entity.EntityDismountEvent; +import org.bukkit.event.entity.EntityDropItemEvent; ++import org.bukkit.event.entity.EntityMountEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.EntityPoseChangeEvent; +import org.bukkit.event.player.PlayerTeleportEvent; @@ -66,7 +68,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -242,6 +299,29 @@ +@@ -242,6 +301,29 @@ public boolean hasVisualFire; @Nullable private IBlockData feetBlockState; @@ -96,7 +98,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -375,6 +455,12 @@ +@@ -375,6 +457,12 @@ public void onClientRemoval() {} public void setPose(EntityPose entitypose) { @@ -109,7 +111,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -399,6 +485,33 @@ +@@ -399,6 +487,33 @@ } protected void setRot(float f, float f1) { @@ -143,7 +145,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -440,6 +553,15 @@ +@@ -440,6 +555,15 @@ this.baseTick(); } @@ -159,7 +161,7 @@ public void baseTick() { this.level().getProfiler().push("entityBaseTick"); this.feetBlockState = null; -@@ -454,7 +576,7 @@ +@@ -454,7 +578,7 @@ this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -168,7 +170,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -489,6 +611,10 @@ +@@ -489,6 +613,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -179,7 +181,7 @@ } this.checkBelowWorld(); -@@ -540,15 +666,48 @@ +@@ -540,15 +668,48 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -229,7 +231,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -699,6 +858,28 @@ +@@ -699,6 +860,28 @@ block.updateEntityAfterFallOn(this.level(), this); } @@ -258,7 +260,7 @@ if (this.onGround()) { block.stepOn(this.level(), blockposition, iblockdata, this); } -@@ -1026,6 +1207,20 @@ +@@ -1026,6 +1209,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -279,7 +281,7 @@ protected void checkInsideBlocks() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); -@@ -1440,6 +1635,7 @@ +@@ -1440,6 +1637,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -287,7 +289,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1634,6 +1830,12 @@ +@@ -1634,6 +1832,12 @@ return false; } @@ -300,7 +302,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1662,16 +1864,22 @@ +@@ -1662,16 +1866,22 @@ } public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { @@ -325,7 +327,7 @@ return true; } } -@@ -1682,16 +1890,38 @@ +@@ -1682,16 +1892,38 @@ } public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { @@ -368,7 +370,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1699,7 +1929,28 @@ +@@ -1699,7 +1931,28 @@ nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); @@ -398,7 +400,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1748,7 +1999,7 @@ +@@ -1748,7 +2001,7 @@ nbttagcompound.put("Tags", nbttaglist); } @@ -407,7 +409,7 @@ if (this.isVehicle()) { nbttaglist = new NBTTagList(); iterator = this.getPassengers().iterator(); -@@ -1757,7 +2008,7 @@ +@@ -1757,7 +2010,7 @@ Entity entity = (Entity) iterator.next(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -416,7 +418,7 @@ nbttaglist.add(nbttagcompound1); } } -@@ -1767,6 +2018,11 @@ +@@ -1767,6 +2020,11 @@ } } @@ -428,7 +430,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1850,6 +2106,45 @@ +@@ -1850,6 +2108,45 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -474,7 +476,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1871,6 +2166,12 @@ +@@ -1871,6 +2168,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -487,7 +489,7 @@ protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); -@@ -1925,9 +2226,22 @@ +@@ -1925,9 +2228,22 @@ } else if (this.level().isClientSide) { return null; } else { @@ -510,7 +512,7 @@ this.level().addFreshEntity(entityitem); return entityitem; } -@@ -2025,6 +2339,18 @@ +@@ -2025,6 +2341,27 @@ if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -525,11 +527,20 @@ + return false; + } + } ++ ++ EntityMountEvent event = new EntityMountEvent(this.getBukkitEntity(), entity.getBukkitEntity()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event.isCancelled()) { ++ return false; ++ } + // CraftBukkit end if (this.isPassenger()) { this.stopRiding(); } -@@ -2058,7 +2384,7 @@ +@@ -2058,7 +2395,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -538,7 +549,7 @@ } } -@@ -2089,10 +2415,29 @@ +@@ -2089,10 +2426,38 @@ } } @@ -565,11 +576,20 @@ + return false; + } + } ++ ++ EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event.isCancelled()) { ++ return false; ++ } + // CraftBukkit end if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -2104,6 +2449,7 @@ +@@ -2104,6 +2469,7 @@ entity.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } @@ -577,7 +597,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2190,14 +2536,20 @@ +@@ -2190,14 +2556,20 @@ if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getServer(); @@ -601,7 +621,7 @@ this.level().getProfiler().pop(); } -@@ -2321,6 +2673,13 @@ +@@ -2321,6 +2693,13 @@ } public void setSwimming(boolean flag) { @@ -615,7 +635,7 @@ this.setSharedFlag(4, flag); } -@@ -2370,8 +2729,12 @@ +@@ -2370,8 +2749,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -629,7 +649,7 @@ } public boolean getSharedFlag(int i) { -@@ -2390,7 +2753,7 @@ +@@ -2390,7 +2773,7 @@ } public int getMaxAirSupply() { @@ -638,7 +658,7 @@ } public int getAirSupply() { -@@ -2398,7 +2761,18 @@ +@@ -2398,7 +2781,18 @@ } public void setAirSupply(int i) { @@ -658,7 +678,7 @@ } public int getTicksFrozen() { -@@ -2425,11 +2799,41 @@ +@@ -2425,11 +2819,41 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -702,7 +722,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2594,15 +2998,38 @@ +@@ -2594,15 +3018,38 @@ @Nullable public Entity changeDimension(WorldServer worldserver) { @@ -743,7 +763,7 @@ this.level().getProfiler().popPush("reloading"); Entity entity = this.getType().create(worldserver); -@@ -2610,10 +3037,22 @@ +@@ -2610,10 +3057,22 @@ entity.restoreFrom(this); entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.setDeltaMovement(shapedetectorshape.speed); @@ -769,7 +789,7 @@ } this.removeAfterChangingDimensions(); -@@ -2634,20 +3073,34 @@ +@@ -2634,20 +3093,34 @@ @Nullable protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { @@ -809,7 +829,7 @@ IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2664,8 +3117,8 @@ +@@ -2664,8 +3137,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } @@ -820,7 +840,7 @@ } } else { BlockPosition blockposition1; -@@ -2675,8 +3128,14 @@ +@@ -2675,8 +3148,14 @@ } else { blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } @@ -836,7 +856,7 @@ } } -@@ -2684,8 +3143,23 @@ +@@ -2684,8 +3163,23 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -862,7 +882,7 @@ } public boolean canChangeDimensions() { -@@ -2806,6 +3280,12 @@ +@@ -2806,6 +3300,12 @@ } } @@ -875,7 +895,7 @@ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); -@@ -2825,7 +3305,11 @@ +@@ -2825,7 +3325,11 @@ entity.moveTo(d0, d1, d2, f, f2); entity.setYHeadRot(f); this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); @@ -888,7 +908,7 @@ } return true; -@@ -2931,7 +3415,26 @@ +@@ -2931,7 +3435,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -916,7 +936,7 @@ } protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { -@@ -3246,6 +3749,11 @@ +@@ -3246,6 +3769,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index dc3ed57237..372b2376be 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -46,7 +46,9 @@ public class Commodore { )); private static final Map RENAMES = Map.of( - "org/bukkit/entity/TextDisplay$TextAligment", "org/bukkit/entity/TextDisplay$TextAlignment" // SPIGOT-7335 + "org/bukkit/entity/TextDisplay$TextAligment", "org/bukkit/entity/TextDisplay$TextAlignment", // SPIGOT-7335 + "org/spigotmc/event/entity/EntityMountEvent", "org/bukkit/event/entity/EntityMountEvent", + "org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent" ); public static void main(String[] args) {