Skip to content

Commit

Permalink
fix #1386
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Jul 29, 2023
1 parent fdae7e7 commit a2e9644
Showing 1 changed file with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,53 @@ Subject: [PATCH] Config for changing the blocks that turn into dirt paths


diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
index c7195f2e12bbd6545f7bffcc2b4ba5cc3d48df20..5e730bc9c8ff94b16ac2bf8567dda8aea2ee4b2a 100644
index 21212462e6b415e96536a27b2c009d1562f18946..98f4870ab82b25ed8bb144835f74c581ad9b9134 100644
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
@@ -34,7 +34,7 @@ public class ShovelItem extends DiggerItem {
@@ -34,13 +34,20 @@ public class ShovelItem extends DiggerItem {
return InteractionResult.PASS;
} else {
Player player = context.getPlayer();
- BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
+ BlockState blockState2 = level.purpurConfig.shovelTurnsBlockToGrassPath.contains(blockState.getBlock()) ? Blocks.DIRT_PATH.defaultBlockState() : null; // Purpur
+ // Purpur start
+ BlockState blockState2 = level.purpurConfig.shovelTurnsBlockToGrassPath.contains(blockState.getBlock()) ? Blocks.DIRT_PATH.defaultBlockState() : null;
+ boolean isUniqueFlattenable;
+ // Purpur end
BlockState blockState3 = null;
Runnable afterAction = null; // Paper
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
- afterAction = () -> level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
+ // Purpur start
+ isUniqueFlattenable = FLATTENABLES.get(blockState.getBlock()) == null;
+ afterAction = () -> level.playSound(isUniqueFlattenable ? null : player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
+ // Purpur end
blockState3 = blockState2;
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
+ isUniqueFlattenable = false; // Purpur
afterAction = () -> { // Paper
if (!level.isClientSide()) {
level.levelEvent((Player)null, 1009, blockPos, 0);
@@ -50,6 +57,11 @@ public class ShovelItem extends DiggerItem {
}; // Paper
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
}
+ // Purpur start
+ else {
+ isUniqueFlattenable = false;
+ }
+ // Purpur end

if (blockState3 != null) {
if (!level.isClientSide) {
@@ -68,7 +80,7 @@ public class ShovelItem extends DiggerItem {
}
}

- return InteractionResult.sidedSuccess(level.isClientSide);
+ return isUniqueFlattenable ? InteractionResult.SUCCESS : InteractionResult.sidedSuccess(level.isClientSide); // Purpur
} else {
return InteractionResult.PASS;
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index c8596997a2d0ef53ca028373da8ddad321fb44c5..6c6de8b218bc0ebb183d6a63fc3dee6b777af03a 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
Expand Down

0 comments on commit a2e9644

Please sign in to comment.