This commit is contained in:
Bjarne Koll 2024-10-25 00:08:35 +02:00
parent 6ca02ef090
commit 42e181498c
21 changed files with 140 additions and 182 deletions

View file

@ -26,4 +26,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead + return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead
} }
@Override public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, Predicate<LivingEntity> predicate, DoubleSupplier... entityYChecks) {

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
} else if (factory instanceof ChestBlock.DoubleInventory) { } else if (factory instanceof ChestBlock.DoubleInventory) {
// SPIGOT-5355 - double chests too :( // SPIGOT-5355 - double chests too :(
((ChestBlock.DoubleInventory) factory).inventorylargechest.stopOpen(this); ((ChestBlock.DoubleInventory) factory).inventorylargechest.stopOpen(this);
@ -30,22 +30,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (itileinventory != null) { - if (itileinventory != null) {
- player.openMenu(itileinventory); - player.openMenu(itileinventory);
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
return InteractionResult.SUCCESS; return InteractionResult.CONSUME;
} else { } else {
return InteractionResult.PASS; return InteractionResult.PASS;
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
@@ -0,0 +0,0 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain @@ -0,0 +0,0 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
@Override @Override
public void openCustomInventoryScreen(Player player) { public void openCustomInventoryScreen(Player player) {
- player.openMenu(this); - player.openMenu(this);
- if (!player.level().isClientSide) { + // Paper - fix inventory open cancel - moved into below if
+ if (!player.level().isClientSide && player.openMenu(this).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation Level world = player.level();
- if (world instanceof ServerLevel worldserver) {
+ if (world instanceof ServerLevel worldserver && player.openMenu(this).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
this.gameEvent(GameEvent.CONTAINER_OPEN, player); this.gameEvent(GameEvent.CONTAINER_OPEN, player);
PiglinAi.angerNearbyPiglins(player, true); PiglinAi.angerNearbyPiglins(worldserver, player, true);
} }
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -61,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ } + }
+ // Paper end - Fix InventoryOpenEvent cancellation + // Paper end - Fix InventoryOpenEvent cancellation
return !player.level().isClientSide ? InteractionResult.CONSUME : InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
diff --git a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
@ -69,46 +72,43 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java --- a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java +++ b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
@@ -0,0 +0,0 @@ public class AnvilBlock extends FallingBlock { @@ -0,0 +0,0 @@ public class AnvilBlock extends FallingBlock {
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) { if (!world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos)); - player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_ANVIL); player.awardStat(Stats.INTERACT_WITH_ANVIL);
- return InteractionResult.CONSUME; + } // Paper - Fix InventoryOpenEvent cancellation
} }
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Nullable return InteractionResult.SUCCESS;
diff --git a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java --- a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
@@ -0,0 +0,0 @@ public class BarrelBlock extends BaseEntityBlock { @@ -0,0 +0,0 @@ public class BarrelBlock extends BaseEntityBlock {
return InteractionResult.SUCCESS;
} else { @Override
BlockEntity blockEntity = world.getBlockEntity(pos); protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (blockEntity instanceof BarrelBlockEntity) { - if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity) {
- player.openMenu((BarrelBlockEntity)blockEntity); - player.openMenu(barrelBlockEntity);
+ if (blockEntity instanceof BarrelBlockEntity && player.openMenu((BarrelBlockEntity)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity && player.openMenu(barrelBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_BARREL); player.awardStat(Stats.OPEN_BARREL);
PiglinAi.angerNearbyPiglins(player, true); PiglinAi.angerNearbyPiglins(serverLevel, player, true);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java --- a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
@@ -0,0 +0,0 @@ public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock { @@ -0,0 +0,0 @@ public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock {
if (world.isClientSide) {
return InteractionResult.SUCCESS; @Override
} else { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity) { - if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity) {
- player.openMenu(beaconBlockEntity); - player.openMenu(beaconBlockEntity);
+ if (world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity && player.openMenu(beaconBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity && player.openMenu(beaconBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_BEACON); player.awardStat(Stats.INTERACT_WITH_BEACON);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -129,102 +129,96 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java --- a/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java
@@ -0,0 +0,0 @@ public class BrewingStandBlock extends BaseEntityBlock { @@ -0,0 +0,0 @@ public class BrewingStandBlock extends BaseEntityBlock {
return InteractionResult.SUCCESS;
} else { @Override
BlockEntity blockEntity = world.getBlockEntity(pos); protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (blockEntity instanceof BrewingStandBlockEntity) { - if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity) {
- player.openMenu((BrewingStandBlockEntity)blockEntity); - player.openMenu(brewingStandBlockEntity);
+ if (blockEntity instanceof BrewingStandBlockEntity && player.openMenu((BrewingStandBlockEntity)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity && player.openMenu(brewingStandBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_BREWINGSTAND); player.awardStat(Stats.INTERACT_WITH_BREWINGSTAND);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java --- a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
@@ -0,0 +0,0 @@ public class CartographyTableBlock extends Block { @@ -0,0 +0,0 @@ public class CartographyTableBlock extends Block {
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) { if (!world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos)); - player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE); player.awardStat(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE);
- return InteractionResult.CONSUME; + } // Paper - Fix InventoryOpenEvent cancellation
} }
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Nullable return InteractionResult.SUCCESS;
diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java --- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
@@ -0,0 +0,0 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements @@ -0,0 +0,0 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements
} else { if (world instanceof ServerLevel worldserver) {
MenuProvider itileinventory = this.getMenuProvider(state, world, pos); MenuProvider itileinventory = this.getMenuProvider(state, world, pos);
- if (itileinventory != null) { - if (itileinventory != null) {
- player.openMenu(itileinventory); - player.openMenu(itileinventory);
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(this.getOpenChestStat()); player.awardStat(this.getOpenChestStat());
PiglinAi.angerNearbyPiglins(player, true); PiglinAi.angerNearbyPiglins(worldserver, player, true);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java --- a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
@@ -0,0 +0,0 @@ public class CraftingTableBlock extends Block { @@ -0,0 +0,0 @@ public class CraftingTableBlock extends Block {
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE);
- return InteractionResult.CONSUME;
}
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Override @Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (!world.isClientSide) {
- player.openMenu(state.getMenuProvider(world, pos));
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE);
+ } // Paper - Fix InventoryOpenEvent cancellation
}
return InteractionResult.SUCCESS;
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java --- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
@@ -0,0 +0,0 @@ public class DispenserBlock extends BaseEntityBlock { @@ -0,0 +0,0 @@ public class DispenserBlock extends BaseEntityBlock {
} else { if (tileentity instanceof DispenserBlockEntity) {
BlockEntity tileentity = world.getBlockEntity(pos); DispenserBlockEntity tileentitydispenser = (DispenserBlockEntity) tileentity;
- player.openMenu(tileentitydispenser);
+ if (player.openMenu(tileentitydispenser).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(tileentitydispenser instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER);
+ } // Paper - Fix InventoryOpenEvent cancellation
}
}
- if (tileentity instanceof DispenserBlockEntity) {
- player.openMenu((DispenserBlockEntity) tileentity);
+ if (tileentity instanceof DispenserBlockEntity && player.openMenu((DispenserBlockEntity) tileentity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
if (tileentity instanceof DropperBlockEntity) {
player.awardStat(Stats.INSPECT_DROPPER);
} else {
diff --git a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java --- a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java +++ b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
@@ -0,0 +0,0 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i @@ -0,0 +0,0 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
return InteractionResult.SUCCESS;
} else { } else {
EnderChestBlockEntity enderChestBlockEntity = (EnderChestBlockEntity)blockEntity; - if (world instanceof ServerLevel serverLevel) {
playerEnderChestContainer.setActiveChest(enderChestBlockEntity); + // Paper start - Fix InventoryOpenEvent cancellation - moved up;
- player.openMenu( + if (world instanceof ServerLevel serverLevel && player.openMenu(
+ // Paper start - Fix InventoryOpenEvent cancellation + new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
+ if (player.openMenu(
new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
- );
- player.awardStat(Stats.OPEN_ENDERCHEST);
- PiglinAi.angerNearbyPiglins(player, true);
+ ).isPresent()) { + ).isPresent()) {
+ player.awardStat(Stats.OPEN_ENDERCHEST); + // Paper end - Fix InventoryOpenEvent cancellation - moved up;
+ PiglinAi.angerNearbyPiglins(player, true); playerEnderChestContainer.setActiveChest(enderChestBlockEntity);
+ } - player.openMenu(
+ // Paper end - Fix InventoryOpenEvent cancellation - new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
return InteractionResult.CONSUME; - );
} + // Paper - Fix InventoryOpenEvent cancellation - moved up;
} else { player.awardStat(Stats.OPEN_ENDERCHEST);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}
diff --git a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java --- a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java
@ -244,32 +238,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java --- a/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java
@@ -0,0 +0,0 @@ public class GrindstoneBlock extends FaceAttachedHorizontalDirectionalBlock { @@ -0,0 +0,0 @@ public class GrindstoneBlock extends FaceAttachedHorizontalDirectionalBlock {
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_GRINDSTONE);
- return InteractionResult.CONSUME;
}
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Override @Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (!world.isClientSide) {
- player.openMenu(state.getMenuProvider(world, pos));
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_GRINDSTONE);
+ } // Paper - Fix InventoryOpenEvent cancellation
}
return InteractionResult.SUCCESS;
diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java --- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java +++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
@@ -0,0 +0,0 @@ public class HopperBlock extends BaseEntityBlock { @@ -0,0 +0,0 @@ public class HopperBlock extends BaseEntityBlock {
return InteractionResult.SUCCESS;
} else { @Override
BlockEntity blockEntity = world.getBlockEntity(pos); protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (blockEntity instanceof HopperBlockEntity) { - if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity) {
- player.openMenu((HopperBlockEntity)blockEntity); - player.openMenu(hopperBlockEntity);
+ if (blockEntity instanceof HopperBlockEntity && player.openMenu((HopperBlockEntity)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity && player.openMenu(hopperBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INSPECT_HOPPER); player.awardStat(Stats.INSPECT_HOPPER);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -290,50 +281,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/LoomBlock.java --- a/src/main/java/net/minecraft/world/level/block/LoomBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LoomBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LoomBlock.java
@@ -0,0 +0,0 @@ public class LoomBlock extends HorizontalDirectionalBlock { @@ -0,0 +0,0 @@ public class LoomBlock extends HorizontalDirectionalBlock {
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_LOOM);
- return InteractionResult.CONSUME;
}
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Override @Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (!world.isClientSide) {
- player.openMenu(state.getMenuProvider(world, pos));
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_LOOM);
+ } // Paper - Fix InventoryOpenEvent cancellation
}
return InteractionResult.SUCCESS;
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java --- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -0,0 +0,0 @@ public class ShulkerBoxBlock extends BaseEntityBlock { @@ -0,0 +0,0 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
} else if (player.isSpectator()) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
return InteractionResult.CONSUME; if (world instanceof ServerLevel serverLevel
} else if (world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity) { && world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity
- if (canOpen(state, world, pos, shulkerBoxBlockEntity)) { - && canOpen(state, world, pos, shulkerBoxBlockEntity)) {
- player.openMenu(shulkerBoxBlockEntity); - player.openMenu(shulkerBoxBlockEntity);
+ if (canOpen(state, world, pos, shulkerBoxBlockEntity) && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + && canOpen(state, world, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
player.awardStat(Stats.OPEN_SHULKER_BOX); + && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
PiglinAi.angerNearbyPiglins(player, true); player.awardStat(Stats.OPEN_SHULKER_BOX);
} PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}
diff --git a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java --- a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
@@ -0,0 +0,0 @@ public class SmithingTableBlock extends CraftingTableBlock { @@ -0,0 +0,0 @@ public class SmithingTableBlock extends CraftingTableBlock {
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) { if (!world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos)); - player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_SMITHING_TABLE); player.awardStat(Stats.INTERACT_WITH_SMITHING_TABLE);
- return InteractionResult.CONSUME; + } // Paper - Fix InventoryOpenEvent cancellation
} }
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
} return InteractionResult.SUCCESS;
}
diff --git a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java b/src/main/java/net/minecraft/world/level/block/SmokerBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java b/src/main/java/net/minecraft/world/level/block/SmokerBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java --- a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java
@ -353,16 +340,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java --- a/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java +++ b/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java
@@ -0,0 +0,0 @@ public class StonecutterBlock extends Block { @@ -0,0 +0,0 @@ public class StonecutterBlock extends Block {
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world.isClientSide) { if (!world.isClientSide) {
return InteractionResult.SUCCESS;
- } else {
- player.openMenu(state.getMenuProvider(world, pos)); - player.openMenu(state.getMenuProvider(world, pos));
+ } else if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_STONECUTTER); player.awardStat(Stats.INTERACT_WITH_STONECUTTER);
- return InteractionResult.CONSUME; + } // Paper - Fix InventoryOpenEvent cancellation
} }
+ return InteractionResult.CONSUME; // Paper - Fix InventoryOpenEvent cancellation
}
@Nullable return InteractionResult.SUCCESS;

View file

@ -29,8 +29,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -0,0 +0,0 @@ public abstract class Projectile extends Entity implements TraceableEntity { @@ -0,0 +0,0 @@ public abstract class Projectile extends Entity implements TraceableEntity {
public boolean deflect(ProjectileDeflection deflection, @Nullable Entity deflector, @Nullable Entity owner, boolean fromAttack) { public boolean deflect(ProjectileDeflection deflection, @Nullable Entity deflector, @Nullable Entity owner, boolean fromAttack) {
deflection.deflect(this, deflector, this.random);
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
deflection.deflect(this, deflector, this.random);
- this.setOwner(owner); - this.setOwner(owner);
+ // Paper start - Fix PickupStatus getting reset + // Paper start - Fix PickupStatus getting reset
+ if (this instanceof AbstractArrow arrow) { + if (this instanceof AbstractArrow arrow) {

View file

@ -68,10 +68,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
-public class CraftBoat extends CraftVehicle implements Boat { -public abstract class CraftBoat extends CraftVehicle implements Boat {
+public class CraftBoat extends CraftVehicle implements Boat, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API +public abstract class CraftBoat extends CraftVehicle implements Boat, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API
public CraftBoat(CraftServer server, net.minecraft.world.entity.vehicle.Boat entity) { public CraftBoat(CraftServer server, AbstractBoat entity) {
super(server, entity); super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -138,7 +138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(server, entity); super(server, entity);
paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
return getHandle().getExperienceReward((ServerLevel) this.getHandle().level(), null); return getHandle().getExperienceReward((net.minecraft.server.level.ServerLevel) this.getHandle().level(), null);
} }
// Paper end // Paper end
+ +

View file

@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
AABB axisalignedbb = entity.getBoundingBox(); AABB axisalignedbb = entity.getBoundingBox();
- if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { - if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
+ if (this.player.canInteractWithEntity(axisalignedbb, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(1.0D))) { // Paper - configurable lenience value for interact range + if (this.player.canInteractWithEntity(axisalignedbb, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0D))) { // Paper - configurable lenience value for interact range
packet.dispatch(new ServerboundInteractPacket.Handler() { packet.dispatch(new ServerboundInteractPacket.Handler() {
private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand); ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);

View file

@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - only call damage event when actuallyHurt will be called - move call logic down + // Paper end - only call damage event when actuallyHurt will be called - move call logic down
+ +
// CraftBukkit start // CraftBukkit start
if (!this.actuallyHurt(source, (float) event.getFinalDamage() - this.lastHurt, event)) { if (!this.actuallyHurt(world, source, (float) event.getFinalDamage() - this.lastHurt, event)) {
return false; return false;
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.lastHurt = amount; this.lastHurt = amount;
@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ amount = computeAmountFromEntityDamageEvent(event); + amount = computeAmountFromEntityDamageEvent(event);
+ // Paper end - only call damage event when actuallyHurt will be called - move call logic down + // Paper end - only call damage event when actuallyHurt will be called - move call logic down
// CraftBukkit start // CraftBukkit start
if (!this.actuallyHurt(source, (float) event.getFinalDamage(), event)) { if (!this.actuallyHurt(world, source, (float) event.getFinalDamage(), event)) {
return false; return false;
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
} }

View file

@ -1,26 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: DerEchtePilz <81232921+DerEchtePilz@users.noreply.github.com>
Date: Sun, 18 Aug 2024 13:05:31 +0200
Subject: [PATCH] Properly destroy placed blocks on the end platform
The craftbukkit provided implementation of LevelAccessor,
BlockStateListPopulator, does not support destroyBlock calls, simply
ignoring them.
This causes the destroyBlock calls during the generation of the end
platform to be lost. The patch moves the destroy calls and executes them
on the actual world access.
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
@@ -0,0 +0,0 @@ public class EndPlatformFeature extends Feature<NoneFeatureConfiguration> {
// CraftBukkit start
if (!blockList.getBlockState(blockposition_mutableblockposition1).is(block)) {
if (flag) {
- blockList.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null);
+ // blockList.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null); // Paper - moved down - cb implementation of LevelAccessor does not support destroyBlock
}
blockList.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3);