mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 10:27:44 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes:a219c497bdDont register multiple ASK_SERVER suggestions under one parent node (#7188)329912b816Expose isFuel and canSmelt methods to FurnaceInventory (#7181)7b833ca18fFix bees aging inside hives (#6466)a99a33cdd9Bucketable API (#7204)721f14842f[ci skip] Change test logging settings to log by default (#7203)2d458ee14fCheck player world in endPortalSoundRadius (#6226)686bbd33d4Fix EntityLoadCrossbowEvent Sync Issue (#5739)64f9225c94Fix riding distance statistics (#7021/SPIGOT-6475) (#7033)
62 lines
3.2 KiB
Diff
62 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
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<Block, BlockState> 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<ItemStack> 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 68c2b381abecc4221b2ca250fdc9c04d994fce3e..ce8098e9058b9d401eab38db9052dedce0eebc42 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -499,6 +499,7 @@ public class PurpurWorldConfig {
|
|
public Map<Block, Waxable> axeWaxables = new HashMap<>();
|
|
public Map<Block, Weatherable> axeWeatherables = new HashMap<>();
|
|
public Map<Block, Tillable> hoeTillables = new HashMap<>();
|
|
+ public boolean hoeReplantsCrops = false;
|
|
private void toolSettings() {
|
|
axeStrippables.clear();
|
|
axeWaxables.clear();
|
|
@@ -640,6 +641,7 @@ public class PurpurWorldConfig {
|
|
});
|
|
hoeTillables.put(block, new Tillable(condition, into, drops));
|
|
});
|
|
+ hoeReplantsCrops = getBoolean("tools.hoe.replant-crops", hoeReplantsCrops);
|
|
}
|
|
|
|
public boolean useBetterMending = false;
|