Skip to content

Commit

Permalink
Renewable sponges (LeavesMC#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china authored and Lumine1909 committed May 5, 2024
1 parent 847d7d8 commit ba3bde2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
7 changes: 5 additions & 2 deletions patches/server/0005-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions patches/server/0131-Renewable-sponges.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
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;

0 comments on commit ba3bde2

Please sign in to comment.