mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-21 05:55:08 +01:00
93 lines
4.7 KiB
Diff
93 lines
4.7 KiB
Diff
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
|
|
index 89e898e14c0a6388bbd76a2f74828cf6cd46e7a9..4304beeca3c0cd7ef224f9ed74ec49066f1e22a0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -858,8 +858,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
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
|
|
- 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 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
|
|
index 75afe539b1dcb8cdccc0cad3c2b8974872e21a63..4277d59f466e800e93770cecb45ab9c76c16aab8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -2712,7 +2712,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
@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
|
|
index afbe7fd926d20d6aef0807663c34838a7f63cd2b..4ecd7a33adf950f192bd14028d8dafdf285a2eb6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -168,6 +168,41 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
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
|
|
@@ -268,6 +303,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
}
|
|
}
|
|
// 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
|