From 3670515051270877baae2c30835f81d0a460e8cb Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sun, 2 Jan 2022 23:17:23 -0600 Subject: [PATCH] Add nether warts to hoe replant patch --- ...oe-to-replant-crops-and-nether-warts.patch | 97 +++++++++++++++++++ ...248-Ability-for-hoe-to-replant-crops.patch | 61 ------------ ...aring-jeb-produces-random-color-wool.patch | 6 +- ...Turtle-eggs-random-tick-crack-chance.patch | 4 +- .../0251-Mob-head-visibility-percent.patch | 16 +-- 5 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 patches/server/0248-Ability-for-hoe-to-replant-crops-and-nether-warts.patch delete mode 100644 patches/server/0248-Ability-for-hoe-to-replant-crops.patch diff --git a/patches/server/0248-Ability-for-hoe-to-replant-crops-and-nether-warts.patch b/patches/server/0248-Ability-for-hoe-to-replant-crops-and-nether-warts.patch new file mode 100644 index 000000000..d72187c1d --- /dev/null +++ b/patches/server/0248-Ability-for-hoe-to-replant-crops-and-nether-warts.patch @@ -0,0 +1,97 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Tue, 28 Dec 2021 16:22:20 -0600 +Subject: [PATCH] Ability for hoe to replant crops and nether warts + + +diff --git a/src/main/java/net/minecraft/world/level/block/BushBlock.java b/src/main/java/net/minecraft/world/level/block/BushBlock.java +index 1f8cf302d2309aec2955832ffafd87f14934e141..4dbadec09f38e63b4b19ea127ce43a822baff081 100644 +--- a/src/main/java/net/minecraft/world/level/block/BushBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BushBlock.java +@@ -50,4 +50,24 @@ public class BushBlock extends Block { + public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) { + return type == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(state, world, pos, type); + } ++ ++ // Purpur start ++ public void playerDestroyAndReplant(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, BlockPos pos, BlockState state, @javax.annotation.Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.world.item.ItemStack itemInHand, net.minecraft.world.level.ItemLike itemToReplant) { ++ player.awardStat(net.minecraft.stats.Stats.BLOCK_MINED.get(this)); ++ player.causeFoodExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); ++ java.util.List dropList = Block.getDrops(state, (ServerLevel) world, pos, blockEntity, player, itemInHand); ++ ++ boolean planted = false; ++ for (net.minecraft.world.item.ItemStack itemToDrop : dropList) { ++ if (!planted && itemToDrop.getItem() == itemToReplant) { ++ world.setBlock(pos, defaultBlockState(), 3); ++ itemToDrop.setCount(itemToDrop.getCount() - 1); ++ planted = true; ++ } ++ Block.popResource(world, pos, itemToDrop); ++ } ++ ++ state.spawnAfterBreak((ServerLevel) world, pos, itemInHand); ++ } ++ // Purpur end + } +diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java +index e054edf9e7c4eef231e155516433c6faeb2ca540..8f035b1f1486f0e4d00e586fccf1a008ef8aaf36 100644 +--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java +@@ -199,4 +199,15 @@ public class CropBlock extends BushBlock implements BonemealableBlock { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(CropBlock.AGE); + } ++ ++ // Purpur start ++ @Override ++ public void playerDestroy(Level world, net.minecraft.world.entity.player.Player player, BlockPos pos, BlockState state, @javax.annotation.Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, ItemStack itemInHand) { ++ if (world.purpurConfig.hoeReplantsCrops && itemInHand.getItem() instanceof net.minecraft.world.item.HoeItem) { ++ super.playerDestroyAndReplant(world, player, pos, state, blockEntity, itemInHand, getBaseSeedId()); ++ } else { ++ super.playerDestroy(world, player, pos, state, blockEntity, itemInHand); ++ } ++ } ++ // Purpur end + } +diff --git a/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java b/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java +index cc8e94dc7ad93a9b7cf71315f5910daa35bc0778..c0ef9c9c438a2716f5d2cd589a0b4e8538b5b347 100644 +--- a/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java +@@ -60,4 +60,15 @@ public class NetherWartBlock extends BushBlock { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(NetherWartBlock.AGE); + } ++ ++ // Purpur start ++ @Override ++ public void playerDestroy(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, BlockPos pos, BlockState state, @javax.annotation.Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, ItemStack itemInHand) { ++ if (world.purpurConfig.hoeReplantsNetherWarts && itemInHand.getItem() instanceof net.minecraft.world.item.HoeItem) { ++ super.playerDestroyAndReplant(world, player, pos, state, blockEntity, itemInHand, Items.NETHER_WART); ++ } else { ++ super.playerDestroy(world, player, pos, state, blockEntity, itemInHand); ++ } ++ } ++ // Purpur end + } +diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +index 9532ab3e75f67cc3b59d52c3b7b4a59414bc556a..1ca8076fc9e1ecbd76d818fe1519c7684655dd74 100644 +--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java ++++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +@@ -544,6 +544,8 @@ public class PurpurWorldConfig { + public Map axeWaxables = new HashMap<>(); + public Map axeWeatherables = new HashMap<>(); + public Map hoeTillables = new HashMap<>(); ++ public boolean hoeReplantsCrops = false; ++ public boolean hoeReplantsNetherWarts = false; + private void toolSettings() { + axeStrippables.clear(); + axeWaxables.clear(); +@@ -685,6 +687,8 @@ public class PurpurWorldConfig { + }); + hoeTillables.put(block, new Tillable(condition, into, drops)); + }); ++ hoeReplantsCrops = getBoolean("tools.hoe.replant-crops", hoeReplantsCrops); ++ hoeReplantsNetherWarts = getBoolean("tools.hoe.replant-nether-warts", hoeReplantsNetherWarts); + } + + public boolean anvilAllowColors = false; diff --git a/patches/server/0248-Ability-for-hoe-to-replant-crops.patch b/patches/server/0248-Ability-for-hoe-to-replant-crops.patch deleted file mode 100644 index 3c3321a6c..000000000 --- a/patches/server/0248-Ability-for-hoe-to-replant-crops.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Tue, 28 Dec 2021 16:22:20 -0600 -Subject: [PATCH] Ability for hoe to replant crops - - -diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java -index e054edf9e7c4eef231e155516433c6faeb2ca540..cf7bbe5516d9d1ae0115b3e03d54b932961c53c2 100644 ---- a/src/main/java/net/minecraft/world/level/block/CropBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java -@@ -199,4 +199,30 @@ public class CropBlock extends BushBlock implements BonemealableBlock { - protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(CropBlock.AGE); - } -+ -+ // Purpur start -+ @Override -+ public void playerDestroy(Level world, net.minecraft.world.entity.player.Player player, BlockPos pos, BlockState state, @javax.annotation.Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, ItemStack itemInHand) { -+ if (world.purpurConfig.hoeReplantsCrops && itemInHand.getItem() instanceof net.minecraft.world.item.HoeItem) { -+ player.awardStat(net.minecraft.stats.Stats.BLOCK_MINED.get(this)); -+ player.causeFoodExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); -+ -+ java.util.List dropList = Block.getDrops(state, (ServerLevel) world, pos, blockEntity, player, itemInHand); -+ -+ boolean planted = false; -+ for (ItemStack itemToDrop : dropList) { -+ if (!planted && itemToDrop.getItem() == getBaseSeedId()) { -+ world.setBlock(pos, defaultBlockState(), 3); -+ itemToDrop.setCount(itemToDrop.getCount() - 1); -+ planted = true; -+ } -+ Block.popResource(world, pos, itemToDrop); -+ } -+ -+ state.spawnAfterBreak((ServerLevel) world, pos, itemInHand); -+ } else { -+ super.playerDestroy(world, player, pos, state, blockEntity, itemInHand); -+ } -+ } -+ // Purpur end - } -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 9532ab3e75f67cc3b59d52c3b7b4a59414bc556a..9dd621c32bbacd213a04f1b7024c223a5755e807 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -544,6 +544,7 @@ public class PurpurWorldConfig { - public Map axeWaxables = new HashMap<>(); - public Map axeWeatherables = new HashMap<>(); - public Map hoeTillables = new HashMap<>(); -+ public boolean hoeReplantsCrops = false; - private void toolSettings() { - axeStrippables.clear(); - axeWaxables.clear(); -@@ -685,6 +686,7 @@ public class PurpurWorldConfig { - }); - hoeTillables.put(block, new Tillable(condition, into, drops)); - }); -+ hoeReplantsCrops = getBoolean("tools.hoe.replant-crops", hoeReplantsCrops); - } - - public boolean anvilAllowColors = false; diff --git a/patches/server/0249-Shearing-jeb-produces-random-color-wool.patch b/patches/server/0249-Shearing-jeb-produces-random-color-wool.patch index dbb67e429..bb9577a04 100644 --- a/patches/server/0249-Shearing-jeb-produces-random-color-wool.patch +++ b/patches/server/0249-Shearing-jeb-produces-random-color-wool.patch @@ -18,10 +18,10 @@ index 860e03111b29f9178a1cd361357985308a39d254..3e72abd93bc5b9f97c2bd62702273d63 if (entityitem != null) { diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 9dd621c32bbacd213a04f1b7024c223a5755e807..41c607fee946e3c3ade50954b2c8866a38ab997d 100644 +index 1ca8076fc9e1ecbd76d818fe1519c7684655dd74..1282f5be4d7812c64f3feda70f68be1b13ad565b 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -2147,6 +2147,7 @@ public class PurpurWorldConfig { +@@ -2149,6 +2149,7 @@ public class PurpurWorldConfig { public boolean sheepBypassMobGriefing = false; public boolean sheepTakeDamageFromWater = false; public boolean sheepAlwaysDropExp = false; @@ -29,7 +29,7 @@ index 9dd621c32bbacd213a04f1b7024c223a5755e807..41c607fee946e3c3ade50954b2c8866a private void sheepSettings() { sheepRidable = getBoolean("mobs.sheep.ridable", sheepRidable); sheepRidableInWater = getBoolean("mobs.sheep.ridable-in-water", sheepRidableInWater); -@@ -2160,6 +2161,7 @@ public class PurpurWorldConfig { +@@ -2162,6 +2163,7 @@ public class PurpurWorldConfig { sheepBypassMobGriefing = getBoolean("mobs.sheep.bypass-mob-griefing", sheepBypassMobGriefing); sheepTakeDamageFromWater = getBoolean("mobs.sheep.takes-damage-from-water", sheepTakeDamageFromWater); sheepAlwaysDropExp = getBoolean("mobs.sheep.always-drop-exp", sheepAlwaysDropExp); diff --git a/patches/server/0250-Turtle-eggs-random-tick-crack-chance.patch b/patches/server/0250-Turtle-eggs-random-tick-crack-chance.patch index 43635aa28..536266b1c 100644 --- a/patches/server/0250-Turtle-eggs-random-tick-crack-chance.patch +++ b/patches/server/0250-Turtle-eggs-random-tick-crack-chance.patch @@ -32,10 +32,10 @@ index 5b29f3fced5435e172dd69f6f4eb265e760b6454..f22be8ecef77ba73be758dce40acad6e @Override diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 41c607fee946e3c3ade50954b2c8866a38ab997d..c85f8a53f65fd9a142c18401129693888030adb7 100644 +index 1282f5be4d7812c64f3feda70f68be1b13ad565b..a15ecffbb7285668b3c317ec8dae79b5fba92145 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -974,11 +974,13 @@ public class PurpurWorldConfig { +@@ -976,11 +976,13 @@ public class PurpurWorldConfig { public boolean turtleEggsBreakFromItems = true; public boolean turtleEggsBreakFromMinecarts = true; public boolean turtleEggsBypassMobGriefing = false; diff --git a/patches/server/0251-Mob-head-visibility-percent.patch b/patches/server/0251-Mob-head-visibility-percent.patch index 7db1454c1..15c06a9c8 100644 --- a/patches/server/0251-Mob-head-visibility-percent.patch +++ b/patches/server/0251-Mob-head-visibility-percent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Mob head visibility percent diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index b6022415925d365931a1110f727d5a22a04b9cee..49238d8b25f4d8a477bd5bbf02e655fe02a99058 100644 +index 30893ad4ea69562c7b77ad1733639f7f7ff1067c..502a41fb2a35eed422d46b8a752cb58a584d496b 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -992,9 +992,17 @@ public abstract class LivingEntity extends Entity { @@ -29,10 +29,10 @@ index b6022415925d365931a1110f727d5a22a04b9cee..49238d8b25f4d8a477bd5bbf02e655fe // Purpur start if (entity instanceof LivingEntity entityliving) { diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a47c2a7840 100644 +index a15ecffbb7285668b3c317ec8dae79b5fba92145..3bd820de8f7ddf74f4e0f606265f33833134e977 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1234,6 +1234,7 @@ public class PurpurWorldConfig { +@@ -1236,6 +1236,7 @@ public class PurpurWorldConfig { public boolean creeperExplodeWhenKilled = false; public boolean creeperHealthRadius = false; public boolean creeperAlwaysDropExp = false; @@ -40,7 +40,7 @@ index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a4 private void creeperSettings() { creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable); creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater); -@@ -1250,6 +1251,7 @@ public class PurpurWorldConfig { +@@ -1252,6 +1253,7 @@ public class PurpurWorldConfig { creeperExplodeWhenKilled = getBoolean("mobs.creeper.explode-when-killed", creeperExplodeWhenKilled); creeperHealthRadius = getBoolean("mobs.creeper.health-impacts-explosion", creeperHealthRadius); creeperAlwaysDropExp = getBoolean("mobs.creeper.always-drop-exp", creeperAlwaysDropExp); @@ -48,7 +48,7 @@ index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a4 } public boolean dolphinRidable = false; -@@ -2221,6 +2223,7 @@ public class PurpurWorldConfig { +@@ -2223,6 +2225,7 @@ public class PurpurWorldConfig { public double skeletonMaxHealth = 20.0D; public boolean skeletonTakeDamageFromWater = false; public boolean skeletonAlwaysDropExp = false; @@ -56,7 +56,7 @@ index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a4 private void skeletonSettings() { skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable); skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater); -@@ -2232,6 +2235,7 @@ public class PurpurWorldConfig { +@@ -2234,6 +2237,7 @@ public class PurpurWorldConfig { skeletonMaxHealth = getDouble("mobs.skeleton.attributes.max_health", skeletonMaxHealth); skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater); skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp); @@ -64,7 +64,7 @@ index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a4 } public boolean skeletonHorseRidableInWater = true; -@@ -2704,6 +2708,7 @@ public class PurpurWorldConfig { +@@ -2706,6 +2710,7 @@ public class PurpurWorldConfig { public boolean zombieBypassMobGriefing = false; public boolean zombieTakeDamageFromWater = false; public boolean zombieAlwaysDropExp = false; @@ -72,7 +72,7 @@ index c85f8a53f65fd9a142c18401129693888030adb7..b0e97fcbbaf445143cf5a02cc3e125a4 private void zombieSettings() { zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable); zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater); -@@ -2721,6 +2726,7 @@ public class PurpurWorldConfig { +@@ -2723,6 +2728,7 @@ public class PurpurWorldConfig { zombieBypassMobGriefing = getBoolean("mobs.zombie.bypass-mob-griefing", zombieBypassMobGriefing); zombieTakeDamageFromWater = getBoolean("mobs.zombie.takes-damage-from-water", zombieTakeDamageFromWater); zombieAlwaysDropExp = getBoolean("mobs.zombie.always-drop-exp", zombieAlwaysDropExp);