mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
81 lines
4.2 KiB
Diff
81 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: 12emin34 <macanovic.emin@gmail.com>
|
|
Date: Thu, 29 Apr 2021 23:56:02 +0200
|
|
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 21212462e6b415e96536a27b2c009d1562f18946..98f4870ab82b25ed8bb144835f74c581ad9b9134 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
@@ -34,13 +34,20 @@ public class ShovelItem extends DiggerItem {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
Player player = context.getPlayer();
|
|
- BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
|
|
+ // 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
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -449,6 +449,21 @@ public class PurpurWorldConfig {
|
|
snowballDamage = getInt("gameplay-mechanics.projectile-damage.snowball", snowballDamage);
|
|
}
|
|
|
|
+ public List<Block> shovelTurnsBlockToGrassPath = new ArrayList<>();
|
|
+ private void shovelSettings() {
|
|
+ getList("gameplay-mechanics.shovel-turns-block-to-grass-path", new ArrayList<String>(){{
|
|
+ add("minecraft:coarse_dirt");
|
|
+ add("minecraft:dirt");
|
|
+ add("minecraft:grass_block");
|
|
+ add("minecraft:mycelium");
|
|
+ add("minecraft:podzol");
|
|
+ add("minecraft:rooted_dirt");
|
|
+ }}).forEach(key -> {
|
|
+ Block block = BuiltInRegistries.BLOCK.get(new ResourceLocation(key.toString()));
|
|
+ if (block != Blocks.AIR) shovelTurnsBlockToGrassPath.add(block);
|
|
+ });
|
|
+ }
|
|
+
|
|
public boolean silkTouchEnabled = false;
|
|
public String silkTouchSpawnerName = "<reset><white>Monster Spawner";
|
|
public List<String> silkTouchSpawnerLore = new ArrayList<>();
|