Fix compilation issues (#1509)

This commit is contained in:
Krakenied
2024-04-28 22:23:25 +02:00
committed by GitHub
parent 9d2dae3c9c
commit dc9993f4d1
36 changed files with 207 additions and 258 deletions

View File

@@ -18,72 +18,74 @@ index 5cedce1f432f6b809b25269242a16477682c824f..61ff2f6c09251da8c34fd653020cd4d3
if (iteminteractionresult.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 d3d12f9114173f4971f95d7ef895a4374705bd3f..750c9043c2b70b18fb34df1e856e3cbb6c651770 100644
index d3d12f9114173f4971f95d7ef895a4374705bd3f..f34159f8d6c51af2341bf49db0d6d6f0417919cf 100644
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
@@ -238,16 +238,26 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@@ -237,18 +237,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) {
- if (i < 7 && !world.isClientSide) {
- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, stack);
- // Paper start - handle cancelled events
- if (iblockdata1 == null) {
+ // Purpur start
+ BlockState newState = process(stack, state, world, pos, player, i);
+ if (newState == null) {
return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
}
- return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
- }
- // Paper end
-
- world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
- player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
- stack.consume(1, player);
+ if (world.purpurConfig.composterBulkProcess && player.isShiftKeyDown()) {
+ BlockState oldState;
+ int oldCount, newCount, oldLevel, newLevel;
+ do {
+ oldState = newState;
+ newState = process(stack, state, world, pos, player, i);
+ oldCount = stack.getCount();
+ if (newState == null) {
+ return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
+ }
+ oldLevel = oldState.getValue(ComposterBlock.LEVEL);
+ newCount = stack.getCount();
+ newLevel = newState.getValue(ComposterBlock.LEVEL);
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
+ }
+ // Purpur start - sneak to bulk process composter
+ BlockState newState = process(i, player, state, world, pos, stack);
+ if (newState == null) {
+ return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
}
+ 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 ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
+ }
+ newCount = stack.getCount();
+ newLevel = newState.getValue(ComposterBlock.LEVEL);
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
+ }
+ // Purpur end
return ItemInteractionResult.sidedSuccess(world.isClientSide);
@@ -255,6 +265,27 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
return super.useItemOn(stack, state, world, pos, player, hand, hit);
} else {
@@ -256,6 +265,25 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
}
}
+ private static BlockState process(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, int i) {
+ // Purpur end
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, stack);
+ // Paper start - handle cancelled events
+ if (iblockdata1 == null) {
+ return null; // Purpur
+ }
+ // Paper end
+
+ world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
+ player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
+ stack.consume(1, player);
+ // Purpur start
+ // }
+ //
+ // return ItemInteractionResult.sidedSuccess(world.isClientSide);
+ // } else {
+ // return super.useItemOn(stack, state, world, pos, player, hand, hit);
+ // }
+ // }
+ // Purpur end
+ // 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 cc365ef1a435c05639e1261bc349df3517e4a44b..5739e18827d77dc594894f7cf8d7ceb9f7b83df1 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java