Void damage configuration API

This commit is contained in:
Axionize 2024-09-29 14:20:42 -07:00
parent 411498e394
commit 66e26ebe48
3 changed files with 125 additions and 75 deletions

View file

@ -411,21 +411,19 @@
} }
protected final AABB makeBoundingBox() { protected final AABB makeBoundingBox() {
@@ -460,12 +732,22 @@ @@ -462,10 +734,20 @@
public void tick() {
this.baseTick(); this.baseTick();
+ } }
+
+ // CraftBukkit start + // CraftBukkit start
+ public void postTick() { + public void postTick() {
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
+ if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities + if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities
+ this.handlePortal(); + this.handlePortal();
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void baseTick() { public void baseTick() {
ProfilerFiller gameprofilerfiller = Profiler.get(); ProfilerFiller gameprofilerfiller = Profiler.get();
@ -472,20 +470,21 @@
} }
} }
@@ -537,7 +823,11 @@ @@ -537,7 +823,12 @@
} }
public void checkBelowWorld() { public void checkBelowWorld() {
- if (this.getY() < (double) (this.level().getMinY() - 64)) { - if (this.getY() < (double) (this.level().getMinY() - 64)) {
+ if (!this.level.getWorld().isVoidDamageEnabled()) return; // Paper - check if void damage is enabled on the world
+ // Paper start - Configurable nether ceiling damage + // Paper start - Configurable nether ceiling damage
+ if (this.getY() < (double) (this.level.getMinY() - 64) || (this.level.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER + if (this.getY() < (double) (this.level.getMinY() + this.level.getWorld().getVoidDamageMinBuildHeightOffset()) || (this.level.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER // Paper - use configured min build height offset
+ && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> this.getY() >= v) + && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> this.getY() >= v)
+ && (!(this instanceof Player player) || !player.getAbilities().invulnerable))) { + && (!(this instanceof Player player) || !player.getAbilities().invulnerable))) {
+ // Paper end - Configurable nether ceiling damage + // Paper end - Configurable nether ceiling damage
this.onBelowWorld(); this.onBelowWorld();
} }
@@ -568,15 +858,32 @@ @@ -568,15 +859,32 @@
public void lavaHurt() { public void lavaHurt() {
if (!this.fireImmune()) { if (!this.fireImmune()) {
@ -520,7 +519,7 @@
} }
} }
@@ -587,9 +894,25 @@ @@ -587,9 +895,25 @@
} }
public final void igniteForSeconds(float seconds) { public final void igniteForSeconds(float seconds) {
@ -547,7 +546,7 @@
public void igniteForTicks(int ticks) { public void igniteForTicks(int ticks) {
if (this.remainingFireTicks < ticks) { if (this.remainingFireTicks < ticks) {
this.setRemainingFireTicks(ticks); this.setRemainingFireTicks(ticks);
@@ -610,7 +933,7 @@ @@ -610,7 +934,7 @@
} }
protected void onBelowWorld() { protected void onBelowWorld() {
@ -556,7 +555,7 @@
} }
public boolean isFree(double offsetX, double offsetY, double offsetZ) { public boolean isFree(double offsetX, double offsetY, double offsetZ) {
@@ -672,6 +995,7 @@ @@ -672,6 +996,7 @@
} }
public void move(MoverType type, Vec3 movement) { public void move(MoverType type, Vec3 movement) {
@ -564,7 +563,7 @@
if (this.noPhysics) { if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else { } else {
@@ -747,8 +1071,30 @@ @@ -747,8 +1072,30 @@
if (movement.y != vec3d1.y) { if (movement.y != vec3d1.y) {
block.updateEntityMovementAfterFallOn(this.level(), this); block.updateEntityMovementAfterFallOn(this.level(), this);
@ -595,7 +594,7 @@
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission(); Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -913,7 +1259,7 @@ @@ -913,7 +1260,7 @@
} }
protected BlockPos getOnPos(float offset) { protected BlockPos getOnPos(float offset) {
@ -604,7 +603,7 @@
BlockPos blockposition = (BlockPos) this.mainSupportingBlockPos.get(); BlockPos blockposition = (BlockPos) this.mainSupportingBlockPos.get();
if (offset <= 1.0E-5F) { if (offset <= 1.0E-5F) {
@@ -1133,6 +1479,20 @@ @@ -1133,6 +1480,20 @@
return SoundEvents.GENERIC_SPLASH; return SoundEvents.GENERIC_SPLASH;
} }
@ -625,7 +624,7 @@
public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) { public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) {
this.movementThisTick.add(new Entity.Movement(oldPos, newPos)); this.movementThisTick.add(new Entity.Movement(oldPos, newPos));
} }
@@ -1599,6 +1959,7 @@ @@ -1599,6 +1960,7 @@
this.setXRot(Mth.clamp(pitch, -90.0F, 90.0F) % 360.0F); this.setXRot(Mth.clamp(pitch, -90.0F, 90.0F) % 360.0F);
this.yRotO = this.getYRot(); this.yRotO = this.getYRot();
this.xRotO = this.getXRot(); this.xRotO = this.getXRot();
@ -633,7 +632,7 @@
} }
public void absMoveTo(double x, double y, double z) { public void absMoveTo(double x, double y, double z) {
@@ -1609,6 +1970,7 @@ @@ -1609,6 +1971,7 @@
this.yo = y; this.yo = y;
this.zo = d4; this.zo = d4;
this.setPos(d3, y, d4); this.setPos(d3, y, d4);
@ -641,7 +640,7 @@
} }
public void moveTo(Vec3 pos) { public void moveTo(Vec3 pos) {
@@ -1628,11 +1990,19 @@ @@ -1628,11 +1991,19 @@
} }
public void moveTo(double x, double y, double z, float yaw, float pitch) { public void moveTo(double x, double y, double z, float yaw, float pitch) {
@ -661,7 +660,7 @@
} }
public final void setOldPosAndRot() { public final void setOldPosAndRot() {
@@ -1701,6 +2071,7 @@ @@ -1701,6 +2072,7 @@
public void push(Entity entity) { public void push(Entity entity) {
if (!this.isPassengerOfSameVehicle(entity)) { if (!this.isPassengerOfSameVehicle(entity)) {
if (!entity.noPhysics && !this.noPhysics) { if (!entity.noPhysics && !this.noPhysics) {
@ -669,7 +668,7 @@
double d0 = entity.getX() - this.getX(); double d0 = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ(); double d1 = entity.getZ() - this.getZ();
double d2 = Mth.absMax(d0, d1); double d2 = Mth.absMax(d0, d1);
@@ -1737,7 +2108,21 @@ @@ -1737,7 +2109,21 @@
} }
public void push(double deltaX, double deltaY, double deltaZ) { public void push(double deltaX, double deltaY, double deltaZ) {
@ -692,7 +691,7 @@
this.hasImpulse = true; this.hasImpulse = true;
} }
@@ -1858,9 +2243,21 @@ @@ -1858,9 +2244,21 @@
} }
public boolean isPushable() { public boolean isPushable() {
@ -714,7 +713,7 @@
public void awardKillScore(Entity entityKilled, DamageSource damageSource) { public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled instanceof ServerPlayer) { if (entityKilled instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource); CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource);
@@ -1889,74 +2286,133 @@ @@ -1889,74 +2287,133 @@
} }
public boolean saveAsPassenger(CompoundTag nbt) { public boolean saveAsPassenger(CompoundTag nbt) {
@ -871,7 +870,7 @@
} }
ListTag nbttaglist; ListTag nbttaglist;
@@ -1972,10 +2428,10 @@ @@ -1972,10 +2429,10 @@
nbttaglist.add(StringTag.valueOf(s)); nbttaglist.add(StringTag.valueOf(s));
} }
@ -884,7 +883,7 @@
if (this.isVehicle()) { if (this.isVehicle()) {
nbttaglist = new ListTag(); nbttaglist = new ListTag();
iterator = this.getPassengers().iterator(); iterator = this.getPassengers().iterator();
@@ -1984,17 +2440,44 @@ @@ -1984,17 +2441,44 @@
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
CompoundTag nbttagcompound1 = new CompoundTag(); CompoundTag nbttagcompound1 = new CompoundTag();
@ -932,10 +931,11 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved");
@@ -2080,6 +2563,71 @@ @@ -2079,7 +2563,72 @@
}
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
} + }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ // Spigot start + // Spigot start
@ -948,7 +948,7 @@
+ // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ if (nbt.contains("Bukkit.MaxAirSupply")) { + if (nbt.contains("Bukkit.MaxAirSupply")) {
+ this.maxAirTicks = nbt.getInt("Bukkit.MaxAirSupply"); + this.maxAirTicks = nbt.getInt("Bukkit.MaxAirSupply");
+ } }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ // CraftBukkit start + // CraftBukkit start
@ -1004,7 +1004,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -2101,6 +2649,12 @@ @@ -2101,6 +2650,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
} }
@ -1017,7 +1017,7 @@
protected abstract void readAdditionalSaveData(CompoundTag nbt); protected abstract void readAdditionalSaveData(CompoundTag nbt);
protected abstract void addAdditionalSaveData(CompoundTag nbt); protected abstract void addAdditionalSaveData(CompoundTag nbt);
@@ -2150,12 +2704,60 @@ @@ -2150,12 +2705,60 @@
@Nullable @Nullable
public ItemEntity spawnAtLocation(ServerLevel world, ItemStack stack, float yOffset) { public ItemEntity spawnAtLocation(ServerLevel world, ItemStack stack, float yOffset) {
@ -1080,7 +1080,7 @@
world.addFreshEntity(entityitem); world.addFreshEntity(entityitem);
return entityitem; return entityitem;
} }
@@ -2184,7 +2786,16 @@ @@ -2184,7 +2787,16 @@
if (this.isAlive() && this instanceof Leashable leashable) { if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == player) { if (leashable.getLeashHolder() == player) {
if (!this.level().isClientSide()) { if (!this.level().isClientSide()) {
@ -1098,7 +1098,7 @@
leashable.removeLeash(); leashable.removeLeash();
} else { } else {
leashable.dropLeash(); leashable.dropLeash();
@@ -2200,6 +2811,14 @@ @@ -2200,6 +2812,14 @@
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) { if (!this.level().isClientSide()) {
@ -1113,7 +1113,7 @@
leashable.setLeashedTo(player, true); leashable.setLeashedTo(player, true);
} }
@@ -2265,15 +2884,15 @@ @@ -2265,15 +2885,15 @@
} }
public boolean showVehicleHealth() { public boolean showVehicleHealth() {
@ -1132,7 +1132,7 @@
return false; return false;
} else { } else {
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
@@ -2285,11 +2904,32 @@ @@ -2285,11 +2905,32 @@
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false; return false;
} else { } else {
@ -1166,7 +1166,7 @@
this.vehicle = entity; this.vehicle = entity;
this.vehicle.addPassenger(this); this.vehicle.addPassenger(this);
entity.getIndirectPassengersStream().filter((entity2) -> { entity.getIndirectPassengersStream().filter((entity2) -> {
@@ -2314,19 +2954,30 @@ @@ -2314,19 +2955,30 @@
} }
public void removeVehicle() { public void removeVehicle() {
@ -1199,7 +1199,7 @@
protected void addPassenger(Entity passenger) { protected void addPassenger(Entity passenger) {
if (passenger.getVehicle() != this) { if (passenger.getVehicle() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
@@ -2349,21 +3000,53 @@ @@ -2349,21 +3001,53 @@
} }
} }
@ -1259,7 +1259,7 @@
} }
protected boolean canAddPassenger(Entity passenger) { protected boolean canAddPassenger(Entity passenger) {
@@ -2464,7 +3147,7 @@ @@ -2464,7 +3148,7 @@
if (teleporttransition != null) { if (teleporttransition != null) {
ServerLevel worldserver1 = teleporttransition.newLevel(); ServerLevel worldserver1 = teleporttransition.newLevel();
@ -1268,7 +1268,7 @@
this.teleport(teleporttransition); this.teleport(teleporttransition);
} }
} }
@@ -2547,7 +3230,7 @@ @@ -2547,7 +3231,7 @@
} }
public boolean isCrouching() { public boolean isCrouching() {
@ -1277,7 +1277,7 @@
} }
public boolean isSprinting() { public boolean isSprinting() {
@@ -2563,7 +3246,7 @@ @@ -2563,7 +3247,7 @@
} }
public boolean isVisuallySwimming() { public boolean isVisuallySwimming() {
@ -1286,7 +1286,7 @@
} }
public boolean isVisuallyCrawling() { public boolean isVisuallyCrawling() {
@@ -2571,6 +3254,13 @@ @@ -2571,6 +3255,13 @@
} }
public void setSwimming(boolean swimming) { public void setSwimming(boolean swimming) {
@ -1300,7 +1300,7 @@
this.setSharedFlag(4, swimming); this.setSharedFlag(4, swimming);
} }
@@ -2609,6 +3299,7 @@ @@ -2609,6 +3300,7 @@
@Nullable @Nullable
public PlayerTeam getTeam() { public PlayerTeam getTeam() {
@ -1308,7 +1308,7 @@
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
} }
@@ -2624,8 +3315,12 @@ @@ -2624,8 +3316,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
} }
@ -1322,7 +1322,7 @@
} }
public boolean getSharedFlag(int index) { public boolean getSharedFlag(int index) {
@@ -2644,7 +3339,7 @@ @@ -2644,7 +3340,7 @@
} }
public int getMaxAirSupply() { public int getMaxAirSupply() {
@ -1331,7 +1331,7 @@
} }
public int getAirSupply() { public int getAirSupply() {
@@ -2652,7 +3347,18 @@ @@ -2652,7 +3348,18 @@
} }
public void setAirSupply(int air) { public void setAirSupply(int air) {
@ -1351,7 +1351,7 @@
} }
public int getTicksFrozen() { public int getTicksFrozen() {
@@ -2679,11 +3385,44 @@ @@ -2679,11 +3386,44 @@
public void thunderHit(ServerLevel world, LightningBolt lightning) { public void thunderHit(ServerLevel world, LightningBolt lightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1); this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -1398,7 +1398,7 @@
} }
public void onAboveBubbleCol(boolean drag) { public void onAboveBubbleCol(boolean drag) {
@@ -2713,7 +3452,7 @@ @@ -2713,7 +3453,7 @@
this.resetFallDistance(); this.resetFallDistance();
} }
@ -1407,7 +1407,7 @@
return true; return true;
} }
@@ -2818,7 +3557,7 @@ @@ -2818,7 +3558,7 @@
public String toString() { public String toString() {
String s = this.level() == null ? "~NULL~" : this.level().toString(); String s = this.level() == null ? "~NULL~" : this.level().toString();
@ -1416,7 +1416,7 @@
} }
public final boolean isInvulnerableToBase(DamageSource damageSource) { public final boolean isInvulnerableToBase(DamageSource damageSource) {
@@ -2838,6 +3577,13 @@ @@ -2838,6 +3578,13 @@
} }
public void restoreFrom(Entity original) { public void restoreFrom(Entity original) {
@ -1430,7 +1430,7 @@
CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag()); CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag());
nbttagcompound.remove("Dimension"); nbttagcompound.remove("Dimension");
@@ -2850,8 +3596,57 @@ @@ -2850,8 +3597,57 @@
public Entity teleport(TeleportTransition teleportTarget) { public Entity teleport(TeleportTransition teleportTarget) {
Level world = this.level(); Level world = this.level();
@ -1488,7 +1488,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel(); ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension(); boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2918,10 +3713,19 @@ @@ -2918,10 +3714,19 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
return null; return null;
} else { } else {
@ -1509,7 +1509,7 @@
Iterator iterator1 = list1.iterator(); Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -2947,7 +3751,7 @@ @@ -2947,7 +3752,7 @@
} }
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@ -1518,7 +1518,7 @@
Iterator iterator = this.getIndirectPassengers().iterator(); Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -2995,9 +3799,17 @@ @@ -2995,9 +3800,17 @@
} }
protected void removeAfterChangingDimensions() { protected void removeAfterChangingDimensions() {
@ -1539,7 +1539,7 @@
} }
} }
@@ -3006,11 +3818,34 @@ @@ -3006,11 +3819,34 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
} }
@ -1574,7 +1574,7 @@
if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) {
Iterator iterator = this.getPassengers().iterator(); Iterator iterator = this.getPassengers().iterator();
@@ -3134,10 +3969,16 @@ @@ -3134,10 +3970,16 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
} }
@ -1594,7 +1594,7 @@
return entity != null; return entity != null;
} }
@@ -3187,7 +4028,7 @@ @@ -3187,7 +4029,7 @@
/** @deprecated */ /** @deprecated */
@Deprecated @Deprecated
protected void fixupDimensions() { protected void fixupDimensions() {
@ -1603,7 +1603,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose); EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize; this.dimensions = entitysize;
@@ -3196,7 +4037,7 @@ @@ -3196,7 +4038,7 @@
public void refreshDimensions() { public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions; EntityDimensions entitysize = this.dimensions;
@ -1612,7 +1612,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose); EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1; this.dimensions = entitysize1;
@@ -3258,10 +4099,29 @@ @@ -3258,10 +4100,29 @@
} }
public final void setBoundingBox(AABB boundingBox) { public final void setBoundingBox(AABB boundingBox) {
@ -1644,7 +1644,7 @@
return this.getDimensions(pose).eyeHeight(); return this.getDimensions(pose).eyeHeight();
} }
@@ -3300,7 +4160,14 @@ @@ -3300,7 +4161,14 @@
public void startSeenByPlayer(ServerPlayer player) {} public void startSeenByPlayer(ServerPlayer player) {}
@ -1660,7 +1660,7 @@
public float rotate(Rotation rotation) { public float rotate(Rotation rotation) {
float f = Mth.wrapDegrees(this.getYRot()); float f = Mth.wrapDegrees(this.getYRot());
@@ -3335,7 +4202,7 @@ @@ -3335,7 +4203,7 @@
} }
@Nullable @Nullable
@ -1669,7 +1669,7 @@
return null; return null;
} }
@@ -3373,20 +4240,34 @@ @@ -3373,20 +4241,34 @@
} }
private Stream<Entity> getIndirectPassengersStream() { private Stream<Entity> getIndirectPassengersStream() {
@ -1704,7 +1704,7 @@
return () -> { return () -> {
return this.getIndirectPassengersStream().iterator(); return this.getIndirectPassengersStream().iterator();
}; };
@@ -3399,6 +4280,7 @@ @@ -3399,6 +4281,7 @@
} }
public boolean hasExactlyOnePlayerPassenger() { public boolean hasExactlyOnePlayerPassenger() {
@ -1712,7 +1712,7 @@
return this.countPlayerPassengers() == 1; return this.countPlayerPassengers() == 1;
} }
@@ -3435,7 +4317,7 @@ @@ -3435,7 +4318,7 @@
} }
public boolean isControlledByLocalInstance() { public boolean isControlledByLocalInstance() {
@ -1721,7 +1721,7 @@
if (entityliving instanceof Player entityhuman) { if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer(); return entityhuman.isLocalPlayer();
@@ -3445,7 +4327,7 @@ @@ -3445,7 +4328,7 @@
} }
public boolean isControlledByClient() { public boolean isControlledByClient() {
@ -1730,7 +1730,7 @@
return entityliving != null && entityliving.isControlledByClient(); return entityliving != null && entityliving.isControlledByClient();
} }
@@ -3463,7 +4345,7 @@ @@ -3463,7 +4346,7 @@
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
} }
@ -1739,7 +1739,7 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
} }
@@ -3489,8 +4371,37 @@ @@ -3489,8 +4372,37 @@
return 1; return 1;
} }
@ -1778,7 +1778,7 @@
} }
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3551,6 +4462,11 @@ @@ -3551,6 +4463,11 @@
vec3d = vec3d.add(vec3d1); vec3d = vec3d.add(vec3d1);
++k1; ++k1;
} }
@ -1790,7 +1790,7 @@
} }
} }
} }
@@ -3613,7 +4529,7 @@ @@ -3613,7 +4530,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry); return new ClientboundAddEntityPacket(this, entityTrackerEntry);
} }
@ -1799,7 +1799,7 @@
return this.type.getDimensions(); return this.type.getDimensions();
} }
@@ -3714,7 +4630,39 @@ @@ -3714,7 +4631,39 @@
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
} }
@ -1839,7 +1839,7 @@
if (this.position.x != x || this.position.y != y || this.position.z != z) { if (this.position.x != x || this.position.y != y || this.position.z != z) {
this.position = new Vec3(x, y, z); this.position = new Vec3(x, y, z);
int i = Mth.floor(x); int i = Mth.floor(x);
@@ -3732,6 +4680,12 @@ @@ -3732,6 +4681,12 @@
this.levelCallback.onMove(); this.levelCallback.onMove();
} }
@ -1852,7 +1852,7 @@
} }
public void checkDespawn() {} public void checkDespawn() {}
@@ -3818,8 +4772,17 @@ @@ -3818,8 +4773,17 @@
@Override @Override
public final void setRemoved(Entity.RemovalReason reason) { public final void setRemoved(Entity.RemovalReason reason) {
@ -1871,7 +1871,7 @@
} }
if (this.removalReason.shouldDestroy()) { if (this.removalReason.shouldDestroy()) {
@@ -3827,14 +4790,30 @@ @@ -3827,14 +4791,30 @@
} }
this.getPassengers().forEach(Entity::stopRiding); this.getPassengers().forEach(Entity::stopRiding);
@ -1904,7 +1904,7 @@
@Override @Override
public void setLevelCallback(EntityInLevelCallback changeListener) { public void setLevelCallback(EntityInLevelCallback changeListener) {
this.levelCallback = changeListener; this.levelCallback = changeListener;
@@ -3887,7 +4866,7 @@ @@ -3887,7 +4867,7 @@
} }
public Vec3 getKnownMovement() { public Vec3 getKnownMovement() {
@ -1913,7 +1913,7 @@
if (entityliving instanceof Player entityhuman) { if (entityliving instanceof Player entityhuman) {
if (this.isAlive()) { if (this.isAlive()) {
@@ -3962,4 +4941,14 @@ @@ -3962,4 +4942,14 @@
void accept(Entity entity, double x, double y, double z); void accept(Entity entity, double x, double y, double z);
} }

View file

@ -1356,6 +1356,15 @@
this.setHealth(0.0F); this.setHealth(0.0F);
this.die(this.damageSources().generic()); this.die(this.damageSources().generic());
} }
@@ -2083,7 +2704,7 @@
@Override
protected void onBelowWorld() {
- this.hurt(this.damageSources().fellOutOfWorld(), 4.0F);
+ this.hurt(this.damageSources().fellOutOfWorld(), this.level().getWorld().getVoidDamageAmount()); // Paper - use configured void damage amount
}
protected void updateSwingTime() {
@@ -2182,6 +2803,12 @@ @@ -2182,6 +2803,12 @@
public abstract ItemStack getItemBySlot(EquipmentSlot slot); public abstract ItemStack getItemBySlot(EquipmentSlot slot);
@ -1755,7 +1764,7 @@
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand); + org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper + event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
+ this.level().getCraftServer().getPluginManager().callEvent(event); + this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // Update client + // Update client
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE); + Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
@ -1779,7 +1788,7 @@
+ } + }
+ // Paper end + // Paper end
+ // CraftBukkit end + // CraftBukkit end
+
if (itemstack != this.useItem) { if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack); this.setItemInHand(enumhand, itemstack);
} }

View file

@ -168,6 +168,41 @@ public class CraftWorld extends CraftRegionAccessor implements World {
private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>(); private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>();
private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftWorld.DATA_TYPE_REGISTRY); private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftWorld.DATA_TYPE_REGISTRY);
private net.kyori.adventure.pointer.Pointers adventure$pointers; // Paper - implement pointers private net.kyori.adventure.pointer.Pointers adventure$pointers; // Paper - implement pointers
// Paper start - void damage configuration
private boolean voidDamageEnabled;
private float voidDamageAmount;
private double voidDamageMinBuildHeightOffset;
@Override
public boolean isVoidDamageEnabled() {
return this.voidDamageEnabled;
}
@Override
public void setVoidDamageEnabled(final boolean enabled) {
this.voidDamageEnabled = enabled;
}
@Override
public float getVoidDamageAmount() {
return this.voidDamageAmount;
}
@Override
public void setVoidDamageAmount(float voidDamageAmount) {
this.voidDamageAmount = voidDamageAmount;
}
@Override
public double getVoidDamageMinBuildHeightOffset() {
return this.voidDamageMinBuildHeightOffset;
}
@Override
public void setVoidDamageMinBuildHeightOffset(double minBuildHeightOffset) {
this.voidDamageMinBuildHeightOffset = minBuildHeightOffset;
}
// Paper end - void damage configuration
// Paper start - Provide fast information methods // Paper start - Provide fast information methods
@Override @Override
@ -268,6 +303,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
} }
} }
// Paper end - per world spawn limits // Paper end - per world spawn limits
// Paper start - per world void damage height
this.voidDamageEnabled = this.world.paperConfig().environment.voidDamageAmount.enabled();
this.voidDamageMinBuildHeightOffset = this.world.paperConfig().environment.voidDamageMinBuildHeightOffset;
this.voidDamageAmount = (float) this.world.paperConfig().environment.voidDamageAmount.or(0);
// Paper end - per world void damage height
} }
@Override @Override