9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00
Files
LeavesMC/patches/server/0108-Renewable-sponges.patch
violetc de4f3fe832 1.21.3 (#382)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
2024-12-02 12:52:54 +08:00

40 lines
1.9 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/src/main/java/net/minecraft/world/entity/monster/Guardian.java b/src/main/java/net/minecraft/world/entity/monster/Guardian.java
index 951f46684623582980901c1ebc1870aa5bcf25a1..4c42999ae3f92ede0e7908e9bb4b4efa59b63cfb 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Guardian.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Guardian.java
@@ -342,6 +342,28 @@ public class Guardian extends Monster {
}
+ // Leaves start - renewable sponges
+ @Override
+ public void thunderHit(net.minecraft.server.level.ServerLevel world, 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.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ elderGuardian.finalizeSpawn(world ,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(world, lightning);
+ }
+ }
+ // Leaves end - renewable sponges
+
private static class GuardianMoveControl extends MoveControl {
private final Guardian guardian;