9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

Renewable sponges (#29)

This commit is contained in:
violetc
2024-01-22 11:42:58 +08:00
parent acc7bf5695
commit 10feee4083
2 changed files with 46 additions and 2 deletions

View File

@@ -78,10 +78,10 @@ index dd95c9d931da5ee2cb3e620c71cc90d178c51fbc..d1ebe4f340c53f987a42fffcc462f2ea
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b558395d65921b097fd1ab6230496c93f6c97c3
index 0000000000000000000000000000000000000000..4eac1921b5cb8616881bcb56b889336ac559920e
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,873 @@
@@ -0,0 +1,876 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
@@ -546,6 +546,9 @@ index 0000000000000000000000000000000000000000..9b558395d65921b097fd1ab6230496c9
+ @GlobalConfig(name = "renewable-deepslate", category = "modify")
+ public static boolean renewableDeepslate = false;
+
+ @GlobalConfig(name = "renewable-sponges", category = "modify")
+ public static boolean renewableSponges = false;
+
+ // Leaves start - modify - removed
+
+ @RemovedConfig

View File

@@ -0,0 +1,41 @@
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;