|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: MidnightTale < [email protected]> |
| 3 | +Date: Mon, 21 Jul 2025 17:02:07 +0700 |
| 4 | +Subject: [PATCH] Native Void Descend Gamerule |
| 5 | + |
| 6 | + |
| 7 | +As part of: Descend (https://github.com/MidnightTale/Descend/blob/26dc4dca932e7315fca5fed22ae4aa01ae765803/src/main/java/fun/mntale/descend/Descend.java) |
| 8 | + |
| 9 | +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java |
| 10 | +index d55a6989fd68f0bcf7bd05e9420fda1115afa6c0..c9722df404a6df65fa2f42a7eee50f5cf0775667 100644 |
| 11 | +--- a/net/minecraft/world/entity/LivingEntity.java |
| 12 | ++++ b/net/minecraft/world/entity/LivingEntity.java |
| 13 | +@@ -2734,8 +2734,60 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin |
| 14 | + |
| 15 | + @Override |
| 16 | + protected void onBelowWorld() { |
| 17 | +- this.hurt(this.damageSources().fellOutOfWorld(), this.level().getWorld().getVoidDamageAmount()); // Paper - use configured void damage amount |
| 18 | ++ // atDeprecated start |
| 19 | ++ if (!this.voidDescendIfEnabled()) { |
| 20 | ++ this.hurt(this.damageSources().fellOutOfWorld(), ((ServerLevel) this.level()).getWorld().getVoidDamageAmount()); |
| 21 | ++ } |
| 22 | ++ // atDeprecated end |
| 23 | ++ } |
| 24 | ++ |
| 25 | ++ // atDeprecated start |
| 26 | ++ /** |
| 27 | ++ * Custom void descend logic, called from onBelowWorld(). |
| 28 | ++ * Returns true if custom logic handled the event, false to fall back to vanilla. |
| 29 | ++ */ |
| 30 | ++ public boolean voidDescendIfEnabled() { |
| 31 | ++ ServerLevel level = (ServerLevel) this.level(); |
| 32 | ++ if (!level.getGameRules().getBoolean(net.minecraft.world.level.GameRules.VOID_DESCEND_ENABLED)) { |
| 33 | ++ return false; |
| 34 | ++ } |
| 35 | ++ double x = this.getX(); |
| 36 | ++ double z = this.getZ(); |
| 37 | ++ ServerLevel targetWorld = level; |
| 38 | ++ double targetY; |
| 39 | ++ ResourceKey<Level> dim = level.dimension(); |
| 40 | ++ if (dim == net.minecraft.world.level.Level.OVERWORLD) { |
| 41 | ++ targetY = 320; |
| 42 | ++ } else if (dim == net.minecraft.world.level.Level.NETHER) { |
| 43 | ++ targetY = 128; |
| 44 | ++ } else if (dim == net.minecraft.world.level.Level.END) { |
| 45 | ++ targetWorld = level.getServer().overworld(); |
| 46 | ++ targetY = 640; |
| 47 | ++ } else { |
| 48 | ++ targetY = 320; |
| 49 | ++ } |
| 50 | ++ level.sendParticles(net.minecraft.core.particles.ParticleTypes.PORTAL, x, this.getY(), z, 100, 1, 1, 1, 0.1); |
| 51 | ++ level.playSound(null, x, this.getY(), z, net.minecraft.sounds.SoundEvents.PORTAL_TRIGGER, net.minecraft.sounds.SoundSource.BLOCKS, 0.5f, 0.7f); |
| 52 | ++ final ServerLevel finalTargetWorld = targetWorld; |
| 53 | ++ final double finalTargetY = targetY; |
| 54 | ++ this.teleportAsync( |
| 55 | ++ finalTargetWorld, |
| 56 | ++ new net.minecraft.world.phys.Vec3(x, finalTargetY, z), |
| 57 | ++ this.getYRot(), |
| 58 | ++ this.getXRot(), |
| 59 | ++ this.getDeltaMovement(), |
| 60 | ++ org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.PLUGIN, |
| 61 | ++ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, |
| 62 | ++ (entity) -> { |
| 63 | ++ finalTargetWorld.sendParticles(net.minecraft.core.particles.ParticleTypes.PORTAL, x, finalTargetY, z, 100, 1, 1, 1, 0.1); |
| 64 | ++ finalTargetWorld.playSound(null, x, finalTargetY, z, net.minecraft.sounds.SoundEvents.PORTAL_TRIGGER, net.minecraft.sounds.SoundSource.BLOCKS, 0.3f, 0.4f); |
| 65 | ++ this.addEffect(new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.SLOW_FALLING, 10 * 20, 0, true, true, true)); |
| 66 | ++ this.addEffect(new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BLINDNESS, 7 * 20, 0, true, true, true)); |
| 67 | ++ } |
| 68 | ++ ); |
| 69 | ++ return true; |
| 70 | + } |
| 71 | ++ // atDeprecated end |
| 72 | + |
| 73 | + protected void updateSwingTime() { |
| 74 | + if (!this.swinging && this.swingTime == 0) return; // Leaf - Lithium - entity.fast_hand_swing |
| 75 | +diff --git a/net/minecraft/world/level/GameRules.java b/net/minecraft/world/level/GameRules.java |
| 76 | +index a6277c587f9e3bdae3b00d2862dea7f4c06253bd..1c1e39b7cdf9c05503192101c5aff9547eda2232 100644 |
| 77 | +--- a/net/minecraft/world/level/GameRules.java |
| 78 | ++++ b/net/minecraft/world/level/GameRules.java |
| 79 | +@@ -262,6 +262,9 @@ public class GameRules { |
| 80 | + public static final GameRules.Key<GameRules.IntegerValue> RULE_DEATH_XP_DROP_PERCENTAGE = register( |
| 81 | + "deathXpDropPercentage", GameRules.Category.PLAYER, GameRules.IntegerValue.create(70, 0, 100, FeatureFlagSet.of(), (server, value) -> {}) |
| 82 | + ); |
| 83 | ++ public static final GameRules.Key<GameRules.BooleanValue> VOID_DESCEND_ENABLED = register( |
| 84 | ++ "voidDescendEnabled", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true) |
| 85 | ++ ); |
| 86 | + // atDeprecated end |
| 87 | + private final Map<GameRules.Key<?>, GameRules.Value<?>> rules; |
| 88 | + private final FeatureFlagSet enabledFeatures; |
0 commit comments