9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-06 15:51:33 +00:00
Files
LeavesMC/patches/server/0052-Renewable-Elytra.patch
2023-03-19 17:30:46 +08:00

58 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Mon, 12 Dec 2022 16:41:52 +0800
Subject: [PATCH] Renewable Elytra
This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition)
diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
index 97fb1d2110a51498f6419841081b500b3f190370..8fb8bc48342183b978b4bfb0845f2cc2af159ac2 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
@@ -36,6 +36,8 @@ import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import net.minecraft.world.entity.animal.Cat;
import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.Heightmap;
@@ -250,6 +252,20 @@ public class Phantom extends FlyingMob implements Enemy {
return (double) this.getEyeHeight();
}
+ // Leaves start - renewable elytra
+ @Override
+ protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) {
+ super.dropFromLootTable(source, causedByPlayer);
+ if (top.leavesmc.leaves.LeavesConfig.renewableElytra > 0.0D) {
+ if (source.getEntity() instanceof Shulker && this.random.nextDouble() < top.leavesmc.leaves.LeavesConfig.renewableElytra) {
+ ItemStack item = new ItemStack(Items.ELYTRA);
+ item.setDamageValue(432);
+ this.spawnAtLocation(item);
+ }
+ }
+ }
+ // Leaves end - renewable elytra
+
// Paper start
java.util.UUID spawningEntity;
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 929fff5e31c0d13da63991e2e532e346ab7eab46..214ba777f1f6a9e81a4bdd772b4412796e1bbbfc 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -441,6 +441,11 @@ public final class LeavesConfig {
playerOperationLimiter = getBoolean("settings.modify.player-operation-limiter", playerOperationLimiter);
}
+ public static double renewableElytra = -1.0;
+ private static void renewableElytra() {
+ renewableElytra = getDouble("settings.modify.renewable-elytra", renewableElytra);
+ }
+
public static final class WorldConfig {
public final String worldName;