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 fd41ef66e2e12ec3a888bb376ef4363343914fcd..2719623d856ad33fa1164c566fddd8bd24dfc8bd 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Guardian.java +++ b/src/main/java/net/minecraft/world/entity/monster/Guardian.java @@ -364,6 +364,30 @@ public class Guardian extends Monster { return new Vector3f(0.0F, dimensions.height + 0.125F * scaleFactor, 0.0F); } + // Leaves start - renewable sponges + + @Override + public void thunderHit(net.minecraft.server.level.ServerLevel world, net.minecraft.world.entity.LightningBolt lightning) { + if (top.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, 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;