9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-30 20:39:15 +00:00
Files
LeavesMC/patches/server/0128-Renewable-sponges.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +08:00

42 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 6c2e2fd5826a5f8070502e20d1d140c3d70bd0d3..661a589b8b2e624a24ae8b1405d1b116a9220844 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Guardian.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Guardian.java
@@ -345,6 +345,30 @@ 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.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()), MobSpawnType.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;