mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Ability for hoe to replant crops
This commit is contained in:
61
patches/server/0249-Ability-for-hoe-to-replant-crops.patch
Normal file
61
patches/server/0249-Ability-for-hoe-to-replant-crops.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user