2024-09-30 00:06:13 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Axionize <154778082+Axionize@users.noreply.github.com>
|
|
|
|
Date: Sun, 29 Sep 2024 14:20:42 -0700
|
|
|
|
Subject: [PATCH] Void damage configuration API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-11 20:17:36 +01:00
|
|
|
index 20fcfb7d7d2541731452454d78f6967215c4fcd7..5949cbccb569ab1d518508d200e69ad9d7d0ba9a 100644
|
2024-09-30 00:06:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -854,8 +854,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-09-30 00:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void checkBelowWorld() {
|
|
|
|
+ if (!this.level.getWorld().isVoidDamageEnabled()) return; // Paper - check if void damage is enabled on the world
|
|
|
|
// Paper start - Configurable nether ceiling damage
|
2024-10-25 12:28:34 +02:00
|
|
|
- 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
|
2024-09-30 00:06:13 +02:00
|
|
|
&& this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> this.getY() >= v)
|
|
|
|
&& (!(this instanceof Player player) || !player.getAbilities().invulnerable))) {
|
|
|
|
// Paper end - Configurable nether ceiling damage
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Rework async chunk api implementation
Firstly, the old methods all routed to the CompletableFuture method.
However, the CF method could not guarantee that if the caller
was off-main that the future would be "completed" on-main. Since
the callback methods used the CF one, this meant that the callback
methods did not guarantee that the callbacks were to be called on
the main thread.
Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb)
so that the methods with the callback are guaranteed to invoke
the callback on the main thread. The CF behavior remains unchanged;
it may still appear to complete on main if invoked off-main.
Secondly, remove the scheduleOnMain invocation in the async
chunk completion. This unnecessarily delays the callback
by 1 tick.
Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which
will load chunks within an area. This method is provided as a helper
as keeping all chunks loaded within an area can be complicated to
implement for plugins (due to the lacking ticket API), and is
already implemented internally anyways.
Fourthly, remove the ticket addition that occured with getChunkAt
and getChunkAtAsync. The ticket addition may delay the unloading
of the chunk unnecessarily. It also fixes a very rare timing bug
where the future/callback would be completed after the chunk
unloads.
2024-11-19 07:34:32 +01:00
|
|
|
index f2708479ccf994278ad1ab4665edc46672001e8a..59c992173fda6153c58722caae061b0e6bee86a1 100644
|
2024-09-30 00:06:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -2701,7 +2701,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-09-30 00:06:13 +02:00
|
|
|
|
|
|
|
@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() {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-12-03 15:47:48 +01:00
|
|
|
index c79c4db56fc4f43498d7886dcb3248798a4c509e..cd2e74ebadc1aa8282b3d5b89696ddbc053b2708 100644
|
2024-09-30 00:06:13 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-12-03 15:47:48 +01:00
|
|
|
@@ -168,6 +168,41 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2024-09-30 00:06:13 +02:00
|
|
|
private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>();
|
|
|
|
private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftWorld.DATA_TYPE_REGISTRY);
|
|
|
|
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
|
|
|
|
@Override
|
2024-12-03 15:47:48 +01:00
|
|
|
@@ -268,6 +303,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2024-09-30 00:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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
|