mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
by default, the "don't run with scissors" feature will not activate for shears that have an `item_model` component or `custom_model_data` component. adds a new world config option at `gameplay-mechanics.item.shears.damage-if-sprinting-item-model` that allows specifying a custom item model ResourceLocation (`purpurmc:scissors` by default) for use with this feature.
105 lines
5.4 KiB
Diff
105 lines
5.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sun, 7 May 2023 22:26:59 -0700
|
|
Subject: [PATCH] Sneak to bulk process composter
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
index a96f859a5d0c6ec692d4627a69f3c9ee49199dbc..adecb4915a0428b71e8c1e59b11f94dd1776697d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
@@ -583,7 +583,7 @@ public class ServerPlayerGameMode {
|
|
ItemStack itemstack1 = stack.copy();
|
|
InteractionResult enuminteractionresult;
|
|
|
|
- if (!flag1) {
|
|
+ if (!flag1 || (player.level().purpurConfig.composterBulkProcess && iblockdata.is(Blocks.COMPOSTER))) { // Purpur
|
|
InteractionResult enuminteractionresult1 = iblockdata.useItemOn(player.getItemInHand(hand), world, player, hand, hitResult);
|
|
|
|
if (enuminteractionresult1.consumesAction()) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
index 9264ba58188a7a682eeb8eb449b89ff8e60f91d6..809a820dd8eec3e48dd3263335c62fbea4cd4f2c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
@@ -243,18 +243,27 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
int i = (Integer) state.getValue(ComposterBlock.LEVEL);
|
|
|
|
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
|
|
- if (i < 7 && !world.isClientSide) {
|
|
- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, stack);
|
|
- // Paper start - handle cancelled events
|
|
- if (iblockdata1 == null) {
|
|
- return InteractionResult.PASS;
|
|
- }
|
|
- // Paper end
|
|
-
|
|
- world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
|
- player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
|
|
- stack.consume(1, player);
|
|
+ // Purpur start - sneak to bulk process composter
|
|
+ BlockState newState = process(i, player, state, world, pos, stack);
|
|
+ if (newState == null) {
|
|
+ return InteractionResult.PASS;
|
|
}
|
|
+ if (world.purpurConfig.composterBulkProcess && player.isShiftKeyDown() && newState != state) {
|
|
+ BlockState oldState;
|
|
+ int oldCount, newCount, oldLevel, newLevel;
|
|
+ do {
|
|
+ oldState = newState;
|
|
+ oldCount = stack.getCount();
|
|
+ oldLevel = oldState.getValue(ComposterBlock.LEVEL);
|
|
+ newState = process(oldLevel, player, oldState, world, pos, stack);
|
|
+ if (newState == null) {
|
|
+ return InteractionResult.PASS;
|
|
+ }
|
|
+ newCount = stack.getCount();
|
|
+ newLevel = newState.getValue(ComposterBlock.LEVEL);
|
|
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
|
|
+ }
|
|
+ // Purpur end
|
|
|
|
return InteractionResult.SUCCESS;
|
|
} else {
|
|
@@ -262,6 +271,25 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
}
|
|
}
|
|
|
|
+ // Purpur start - sneak to bulk process composter
|
|
+ private static @Nullable BlockState process(int level, Player player, BlockState state, Level world, BlockPos pos, ItemStack stack) {
|
|
+ if (level < 7 && !world.isClientSide) {
|
|
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, stack);
|
|
+ // Paper start - handle cancelled events
|
|
+ if (iblockdata1 == null) {
|
|
+ return null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
+ world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
|
+ player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
|
|
+ stack.consume(1, player);
|
|
+ return iblockdata1;
|
|
+ }
|
|
+ return state;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
|
int i = (Integer) state.getValue(ComposterBlock.LEVEL);
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index 99a1c69938be124ad6fd1ae9a96024cc9fafd62c..09fa9a18dc1bb6a3df80cb2237dc0d55affc0453 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -441,6 +441,11 @@ public class PurpurWorldConfig {
|
|
chestOpenWithBlockOnTop = getBoolean("blocks.chest.open-with-solid-block-on-top", chestOpenWithBlockOnTop);
|
|
}
|
|
|
|
+ public boolean composterBulkProcess = false;
|
|
+ private void composterSettings() {
|
|
+ composterBulkProcess = getBoolean("blocks.composter.sneak-to-bulk-process", composterBulkProcess);
|
|
+ }
|
|
+
|
|
public boolean dispenserApplyCursedArmor = true;
|
|
public boolean dispenserPlaceAnvils = false;
|
|
private void dispenserSettings() {
|