9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0090-Renewable-sponges.patch
MC_XiaoHei 90080d238e 1.21.10 (#752)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
2025-11-28 03:15:54 +08:00

40 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Mon, 22 Jan 2024 11:41:13 +0800
Subject: [PATCH] Renewable sponges
diff --git a/net/minecraft/world/entity/monster/Guardian.java b/net/minecraft/world/entity/monster/Guardian.java
index c907feb2ab6862d980f89f6341402131a8a966f2..daad38e533360501529f2f7a0bdfee213ac56ca6 100644
--- a/net/minecraft/world/entity/monster/Guardian.java
+++ b/net/minecraft/world/entity/monster/Guardian.java
@@ -453,6 +453,28 @@ public class Guardian extends Monster {
}
}
+ // Leaves start - renewable sponges
+ @Override
+ public void thunderHit(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.LightningBolt lightning) {
+ if (org.leavesmc.leaves.LeavesConfig.modify.renewableSponges && !this.isRemoved() && !(this instanceof ElderGuardian)) {
+ ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level());
+ elderGuardian.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ elderGuardian.finalizeSpawn(level ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null);
+ elderGuardian.setNoAi(this.isNoAi());
+
+ if (this.hasCustomName()) {
+ elderGuardian.setCustomName(this.getCustomName());
+ elderGuardian.setCustomNameVisible(this.isCustomNameVisible());
+ }
+
+ this.level().addFreshEntity(elderGuardian);
+ this.discard();
+ } else {
+ super.thunderHit(level, lightning);
+ }
+ }
+ // Leaves end - renewable sponges
+
static class GuardianMoveControl extends MoveControl {
private final Guardian guardian;