Updated Upstream (Paper)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@90a0835 Fix incremental player saving patch
PaperMC/Paper@f9f9079 Pull a few Folia patches
PaperMC/Paper@0f91091 Re-implement the compost events (#9192)
PaperMC/Paper@fa8fa1c Fix playing adventure sounds on World/Server (#8077)
This commit is contained in:
granny
2023-05-31 04:20:32 -07:00
parent 68117a4e35
commit d6cfa8f939
11 changed files with 45 additions and 57 deletions

View File

@@ -18,37 +18,31 @@ index 1d33c02088c150189d7f4b0aa27f6a1de96b11cf..1a46dbb364423c889fcdf58f640b7784
if (enuminteractionresult.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 fb4382337fe83f7d00c2212a7a71e0ba5bdd51cc..f085a669e2f2645e8c4f7a7e5a3c958f13809744 100644
index 6fab2b69a0af298bd00b309efcd6aa8399e23d1f..4f7b21caa123ea7896788fd25133d8de3ab1ccaf 100644
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
@@ -228,26 +228,28 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@@ -228,20 +228,28 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
ItemStack itemstack = player.getItemInHand(hand);
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
- if (i < 7 && !world.isClientSide) {
- // Paper start - EntityChangeBlockEvent
- double rand = world.getRandom().nextDouble();
- BlockState dummyBlockState = ComposterBlock.addItem(player, state, org.bukkit.craftbukkit.util.DummyGeneratorAccess.INSTANCE, pos, itemstack, rand);
- if (dummyBlockState == null) {
- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
- // Paper start - handle cancelled events
- if (iblockdata1 == null) {
- return InteractionResult.PASS;
- }
- if (state != dummyBlockState && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, dummyBlockState).isCancelled()) { // if block state will change and event cancelled
- return InteractionResult.sidedSuccess(world.isClientSide);
- }
- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand);
- // Paper end
-
+ // Purpur start
+ BlockState newState = process(i, state, world, itemstack, pos, player);
+ if (newState == null) {
+ return InteractionResult.PASS;
+ }
- world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
- player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
- if (!player.getAbilities().instabuild) {
- itemstack.shrink(1);
- }
+ // Purpur start
+ BlockState newState = process(i, state, world, itemstack, pos, player);
+ if (newState == null) {
+ return InteractionResult.PASS;
}
+ if (world.purpurConfig.composterBulkProcess && player.isShiftKeyDown() && newState != state) {
+ BlockState oldState;
+ int oldCount, newCount, oldLevel, newLevel;
@@ -63,28 +57,22 @@ index fb4382337fe83f7d00c2212a7a71e0ba5bdd51cc..f085a669e2f2645e8c4f7a7e5a3c958f
+ newCount = itemstack.getCount();
+ newLevel = newState.getValue(ComposterBlock.LEVEL);
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
+ }
}
+ // Purpur end
return InteractionResult.sidedSuccess(world.isClientSide);
} else if (i == 8) {
ComposterBlock.extractProduce(player, state, world, pos);
@@ -257,6 +259,32 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@@ -252,6 +260,26 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
}
}
+ // Purpur start
+ private static BlockState process(int level, BlockState state, Level world, ItemStack itemstack, BlockPos pos, Player player) {
+ if (level < 7 && !world.isClientSide) {
+ // Paper start - EntityChangeBlockEvent
+ double rand = world.getRandom().nextDouble();
+ BlockState dummyBlockState = ComposterBlock.addItem(player, state, org.bukkit.craftbukkit.util.DummyGeneratorAccess.INSTANCE, pos, itemstack, rand);
+ if (dummyBlockState == null) {
+ return dummyBlockState;
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
+ // Paper start - handle cancelled events
+ if (iblockdata1 == null) {
+ return iblockdata1;
+ }
+ if (state != dummyBlockState && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, dummyBlockState).isCancelled()) { // if block state will change and event cancelled
+ return state;
+ }
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand);
+ // Paper end
+
+ world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
@@ -92,7 +80,7 @@ index fb4382337fe83f7d00c2212a7a71e0ba5bdd51cc..f085a669e2f2645e8c4f7a7e5a3c958f
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return dummyBlockState;
+ return iblockdata1;
+ }
+ return state;
+ }