mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-16 18:31:53 +01:00
Fix InventoryOpenEvent cancellation
This commit is contained in:
parent
be5187c2da
commit
2742ad6a9a
23 changed files with 325 additions and 64 deletions
paper-server/patches/sources/net/minecraft
server/level
world
entity/vehicle
level/block
AnvilBlock.java.patchBarrelBlock.java.patchBeaconBlock.java.patchBlastFurnaceBlock.java.patchBrewingStandBlock.java.patchCartographyTableBlock.java.patchChestBlock.java.patchCraftingTableBlock.java.patchDispenserBlock.java.patchEnderChestBlock.java.patchFurnaceBlock.java.patchGrindstoneBlock.java.patchHopperBlock.java.patchLecternBlock.java.patchLoomBlock.java.patchShulkerBoxBlock.java.patchSmithingTableBlock.java.patchSmokerBlock.java.patchStonecutterBlock.java.patch
|
@ -530,12 +530,10 @@
|
|||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel));
|
||||
@@ -863,8 +1081,22 @@
|
||||
|
||||
if (this.tickCount % 20 == 0) {
|
||||
@@ -865,6 +1083,20 @@
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
||||
+ if (this.oldLevel == -1) {
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
|
@ -544,8 +542,8 @@
|
|||
+ if (this.oldLevel != this.experienceLevel) {
|
||||
+ CraftEventFactory.callPlayerLevelChangeEvent(this.getBukkitEntity(), this.oldLevel, this.experienceLevel);
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ if (this.getBukkitEntity().hasClientWorldBorder()) {
|
||||
+ ((CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().tick();
|
||||
+ }
|
||||
|
@ -1169,7 +1167,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1396,13 +1896,40 @@
|
||||
@@ -1396,13 +1896,44 @@
|
||||
if (factory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -1202,6 +1200,10 @@
|
|||
+ } else if (factory instanceof ChestBlock.DoubleInventory) {
|
||||
+ // SPIGOT-5355 - double chests too :(
|
||||
+ ((ChestBlock.DoubleInventory) factory).inventorylargechest.stopOpen(this);
|
||||
+ // Paper start - Fix InventoryOpenEvent cancellation
|
||||
+ } else if (!this.enderChestInventory.isActiveChest(null)) {
|
||||
+ this.enderChestInventory.stopOpen(this);
|
||||
+ // Paper end - Fix InventoryOpenEvent cancellation
|
||||
+ }
|
||||
+ return OptionalInt.empty();
|
||||
+ }
|
||||
|
@ -1210,7 +1212,7 @@
|
|||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
|
||||
@@ -1410,9 +1937,11 @@
|
||||
@@ -1410,9 +1941,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -1224,7 +1226,7 @@
|
|||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1425,15 +1954,26 @@
|
||||
@@ -1425,15 +1958,26 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(AbstractHorse horse, Container inventory) {
|
||||
|
@ -1254,7 +1256,7 @@
|
|||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1456,9 +1996,28 @@
|
||||
@@ -1456,9 +2000,28 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
|
@ -1283,7 +1285,7 @@
|
|||
|
||||
@Override
|
||||
public void doCloseContainer() {
|
||||
@@ -1485,19 +2044,19 @@
|
||||
@@ -1485,19 +2048,19 @@
|
||||
i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(Stats.SWIM_ONE_CM, i);
|
||||
|
@ -1306,7 +1308,7 @@
|
|||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (deltaY > 0.0D) {
|
||||
@@ -1508,13 +2067,13 @@
|
||||
@@ -1508,13 +2071,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(Stats.SPRINT_ONE_CM, i);
|
||||
|
@ -1323,7 +1325,7 @@
|
|||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1557,7 +2116,7 @@
|
||||
@@ -1557,7 +2120,7 @@
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int amount) {
|
||||
this.stats.increment(this, stat, amount);
|
||||
|
@ -1332,7 +1334,7 @@
|
|||
scoreaccess.add(amount);
|
||||
});
|
||||
}
|
||||
@@ -1565,7 +2124,7 @@
|
||||
@@ -1565,7 +2128,7 @@
|
||||
@Override
|
||||
public void resetStat(Stat<?> stat) {
|
||||
this.stats.setValue(this, stat, 0);
|
||||
|
@ -1341,7 +1343,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1597,9 +2156,9 @@
|
||||
@@ -1597,9 +2160,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(Stats.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
|
@ -1353,7 +1355,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1613,6 +2172,13 @@
|
||||
@@ -1613,6 +2176,13 @@
|
||||
public void disconnect() {
|
||||
this.disconnected = true;
|
||||
this.ejectPassengers();
|
||||
|
@ -1367,7 +1369,7 @@
|
|||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, false);
|
||||
}
|
||||
@@ -1625,6 +2191,7 @@
|
||||
@@ -1625,6 +2195,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
|
@ -1375,7 +1377,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1661,7 +2228,7 @@
|
||||
@@ -1661,7 +2232,7 @@
|
||||
this.onUpdateAbilities();
|
||||
if (alive) {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
|
@ -1384,7 +1386,7 @@
|
|||
this.setHealth(oldPlayer.getHealth());
|
||||
this.foodData = oldPlayer.foodData;
|
||||
Iterator iterator = oldPlayer.getActiveEffects().iterator();
|
||||
@@ -1669,7 +2236,7 @@
|
||||
@@ -1669,7 +2240,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
|
@ -1393,7 +1395,7 @@
|
|||
}
|
||||
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
@@ -1680,7 +2247,7 @@
|
||||
@@ -1680,7 +2251,7 @@
|
||||
this.portalProcess = oldPlayer.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
|
@ -1402,7 +1404,7 @@
|
|||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
this.experienceLevel = oldPlayer.experienceLevel;
|
||||
@@ -1696,7 +2263,7 @@
|
||||
@@ -1696,7 +2267,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
|
@ -1411,7 +1413,7 @@
|
|||
this.seenCredits = oldPlayer.seenCredits;
|
||||
this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = oldPlayer.chunkTrackingView;
|
||||
@@ -1752,19 +2319,19 @@
|
||||
@@ -1752,19 +2323,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1435,7 +1437,7 @@
|
|||
}
|
||||
|
||||
return flag1;
|
||||
@@ -1799,10 +2366,18 @@
|
||||
@@ -1799,10 +2370,18 @@
|
||||
}
|
||||
|
||||
public boolean setGameMode(GameType gameMode) {
|
||||
|
@ -1456,7 +1458,7 @@
|
|||
} else {
|
||||
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
|
||||
if (gameMode == GameType.SPECTATOR) {
|
||||
@@ -1818,7 +2393,7 @@
|
||||
@@ -1818,7 +2397,7 @@
|
||||
|
||||
this.onUpdateAbilities();
|
||||
this.updateEffectVisibility();
|
||||
|
@ -1465,7 +1467,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1861,8 +2436,13 @@
|
||||
@@ -1861,8 +2440,13 @@
|
||||
}
|
||||
|
||||
public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) {
|
||||
|
@ -1480,7 +1482,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1878,7 +2458,36 @@
|
||||
@@ -1878,7 +2462,36 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientOptions) {
|
||||
|
@ -1517,7 +1519,7 @@
|
|||
this.requestedViewDistance = clientOptions.viewDistance();
|
||||
this.chatVisibility = clientOptions.chatVisibility();
|
||||
this.canChatColor = clientOptions.chatColors();
|
||||
@@ -1957,12 +2566,27 @@
|
||||
@@ -1957,12 +2570,27 @@
|
||||
|
||||
this.camera = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.camera) {
|
||||
|
@ -1546,7 +1548,7 @@
|
|||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1999,11 +2623,11 @@
|
||||
@@ -1999,11 +2627,11 @@
|
||||
|
||||
@Nullable
|
||||
public Component getTabListDisplayName() {
|
||||
|
@ -1560,7 +1562,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -2045,12 +2669,44 @@
|
||||
@@ -2045,12 +2673,44 @@
|
||||
this.setRespawnPosition(player.getRespawnDimension(), player.getRespawnPosition(), player.getRespawnAngle(), player.isRespawnForced(), false);
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1609,7 @@
|
|||
}
|
||||
|
||||
this.respawnPosition = pos;
|
||||
@@ -2064,6 +2720,7 @@
|
||||
@@ -2064,6 +2724,7 @@
|
||||
this.respawnForced = false;
|
||||
}
|
||||
|
||||
|
@ -1615,7 +1617,7 @@
|
|||
}
|
||||
|
||||
public SectionPos getLastSectionPos() {
|
||||
@@ -2088,18 +2745,44 @@
|
||||
@@ -2088,18 +2749,44 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1664,7 +1666,7 @@
|
|||
}
|
||||
|
||||
this.awardStat(Stats.DROP);
|
||||
@@ -2115,6 +2798,11 @@
|
||||
@@ -2115,6 +2802,11 @@
|
||||
return null;
|
||||
} else {
|
||||
double d0 = this.getEyeY() - 0.30000001192092896D;
|
||||
|
@ -1676,7 +1678,7 @@
|
|||
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), stack);
|
||||
|
||||
entityitem.setPickUpDelay(40);
|
||||
@@ -2166,6 +2854,16 @@
|
||||
@@ -2166,6 +2858,16 @@
|
||||
}
|
||||
|
||||
public void loadGameTypes(@Nullable CompoundTag nbt) {
|
||||
|
@ -1693,7 +1695,7 @@
|
|||
this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType"));
|
||||
}
|
||||
|
||||
@@ -2275,9 +2973,15 @@
|
||||
@@ -2275,9 +2977,15 @@
|
||||
|
||||
@Override
|
||||
public void stopRiding() {
|
||||
|
@ -1710,7 +1712,7 @@
|
|||
if (entity instanceof LivingEntity entityliving) {
|
||||
Iterator iterator = entityliving.getActiveEffects().iterator();
|
||||
|
||||
@@ -2375,10 +3079,12 @@
|
||||
@@ -2375,16 +3083,161 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
|
@ -1726,10 +1728,11 @@
|
|||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3 respawnPos, BlockPos currentPos) {
|
||||
@@ -2387,4 +3093,147 @@
|
||||
Vec3 vec3d1 = Vec3.atBottomCenterOf(currentPos).subtract(respawnPos).normalize();
|
||||
|
||||
return (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - Add per-player time and weather.
|
||||
+ public long timeOffset = 0;
|
||||
|
@ -1742,8 +1745,8 @@
|
|||
+ } else {
|
||||
+ // Adds timeOffset to the beginning of this day.
|
||||
+ return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public WeatherType weather = null;
|
||||
+
|
||||
|
|
|
@ -374,7 +374,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -321,15 +514,61 @@
|
||||
@@ -321,17 +514,62 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,6 +397,8 @@
|
|||
+ cancelledBlock = !(itileinventory instanceof MenuProvider);
|
||||
+ }
|
||||
|
||||
- if (itileinventory != null) {
|
||||
- player.openMenu(itileinventory);
|
||||
+ if (player.getCooldowns().isOnCooldown(stack)) {
|
||||
+ cancelledItem = true; // Paper - correctly handle items on cooldown
|
||||
+ }
|
||||
|
@ -433,10 +435,11 @@
|
|||
+ } else if (this.gameModeForPlayer == GameType.SPECTATOR) {
|
||||
+ MenuProvider itileinventory = iblockdata.getMenuProvider(world, blockposition);
|
||||
+
|
||||
if (itileinventory != null) {
|
||||
player.openMenu(itileinventory);
|
||||
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
return InteractionResult.CONSUME;
|
||||
@@ -359,7 +598,7 @@
|
||||
} else {
|
||||
return InteractionResult.PASS;
|
||||
@@ -359,7 +597,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,19 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -109,10 +125,10 @@
|
||||
|
||||
@Override
|
||||
public void openCustomInventoryScreen(Player player) {
|
||||
- player.openMenu(this);
|
||||
+ // Paper - fix inventory open cancel - moved into below if
|
||||
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);
|
||||
PiglinAi.angerNearbyPiglins(worldserver, player, true);
|
||||
}
|
||||
@@ -165,7 +181,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,18 @@
|
|||
}
|
||||
|
||||
default void chestVehicleDestroyed(DamageSource source, ServerLevel world, Entity vehicle) {
|
||||
@@ -97,13 +101,18 @@
|
||||
@@ -91,19 +95,28 @@
|
||||
}
|
||||
|
||||
default InteractionResult interactWithContainerVehicle(Player player) {
|
||||
- player.openMenu(this);
|
||||
+ // Paper start - Fix InventoryOpenEvent cancellation
|
||||
+ if (player.openMenu(this).isEmpty()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end - Fix InventoryOpenEvent cancellation
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
default void unpackChestVehicleLootTable(@Nullable Player player) {
|
||||
MinecraftServer minecraftServer = this.level().getServer();
|
||||
|
@ -53,7 +64,7 @@
|
|||
LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position());
|
||||
if (player != null) {
|
||||
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||
@@ -173,4 +182,14 @@
|
||||
@@ -173,4 +186,14 @@
|
||||
default boolean isChestVehicleStillValid(Player player) {
|
||||
return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/AnvilBlock.java
|
||||
+++ b/net/minecraft/world/level/block/AnvilBlock.java
|
||||
@@ -62,8 +62,9 @@
|
||||
@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_ANVIL);
|
||||
+ } // Paper - Fix InventoryOpenEvent cancellation
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/BarrelBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BarrelBlock.java
|
||||
@@ -41,8 +41,7 @@
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
- if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity) {
|
||||
- player.openMenu(barrelBlockEntity);
|
||||
+ if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity && player.openMenu(barrelBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.OPEN_BARREL);
|
||||
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/BeaconBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BeaconBlock.java
|
||||
@@ -46,8 +46,7 @@
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity) {
|
||||
- player.openMenu(beaconBlockEntity);
|
||||
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity && player.openMenu(beaconBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_BEACON);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/BlastFurnaceBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BlastFurnaceBlock.java
|
||||
@@ -45,8 +45,7 @@
|
||||
@Override
|
||||
protected void openContainer(Level world, BlockPos pos, Player player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
- if (blockEntity instanceof BlastFurnaceBlockEntity) {
|
||||
- player.openMenu((MenuProvider)blockEntity);
|
||||
+ if (blockEntity instanceof BlastFurnaceBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_BLAST_FURNACE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/BrewingStandBlock.java
|
||||
+++ b/net/minecraft/world/level/block/BrewingStandBlock.java
|
||||
@@ -68,8 +68,7 @@
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity) {
|
||||
- player.openMenu(brewingStandBlockEntity);
|
||||
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity && player.openMenu(brewingStandBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_BREWINGSTAND);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/CartographyTableBlock.java
|
||||
+++ b/net/minecraft/world/level/block/CartographyTableBlock.java
|
||||
@@ -32,8 +32,9 @@
|
||||
@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_CARTOGRAPHY_TABLE);
|
||||
+ } // Paper - Fix InventoryOpenEvent cancellation
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
|
@ -26,10 +26,13 @@
|
|||
}
|
||||
|
||||
public Optional<MenuProvider> acceptSingle(ChestBlockEntity single) {
|
||||
@@ -121,6 +104,38 @@
|
||||
}
|
||||
};
|
||||
|
||||
@@ -118,8 +101,40 @@
|
||||
@Override
|
||||
public Optional<MenuProvider> acceptNone() {
|
||||
return Optional.empty();
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public static class DoubleInventory implements MenuProvider {
|
||||
+
|
||||
|
@ -53,19 +56,28 @@
|
|||
+ } else {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Component getDisplayName() {
|
||||
+ return (Component) (this.tileentitychest.hasCustomName() ? this.tileentitychest.getDisplayName() : (this.tileentitychest1.hasCustomName() ? this.tileentitychest1.getDisplayName() : Component.translatable("container.chestDouble")));
|
||||
+ }
|
||||
+ };
|
||||
};
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends ChestBlock> codec() {
|
||||
return ChestBlock.CODEC;
|
||||
@@ -257,7 +272,7 @@
|
||||
@@ -232,8 +247,7 @@
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
MenuProvider itileinventory = this.getMenuProvider(state, world, pos);
|
||||
|
||||
- if (itileinventory != null) {
|
||||
- player.openMenu(itileinventory);
|
||||
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(this.getOpenChestStat());
|
||||
PiglinAi.angerNearbyPiglins(worldserver, player, true);
|
||||
}
|
||||
@@ -257,7 +271,7 @@
|
||||
|
||||
@Override
|
||||
public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> combine(BlockState state, Level world, BlockPos pos, boolean ignoreBlocked) {
|
||||
|
@ -74,7 +86,7 @@
|
|||
|
||||
if (ignoreBlocked) {
|
||||
bipredicate = (generatoraccess, blockposition1) -> {
|
||||
@@ -273,9 +288,16 @@
|
||||
@@ -273,9 +287,16 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public MenuProvider getMenuProvider(BlockState state, Level world, BlockPos pos) {
|
||||
|
@ -92,7 +104,7 @@
|
|||
public static DoubleBlockCombiner.Combiner<ChestBlockEntity, Float2FloatFunction> opennessCombiner(final LidBlockEntity progress) {
|
||||
return new DoubleBlockCombiner.Combiner<ChestBlockEntity, Float2FloatFunction>() {
|
||||
public Float2FloatFunction acceptDouble(ChestBlockEntity first, ChestBlockEntity second) {
|
||||
@@ -321,6 +343,11 @@
|
||||
@@ -321,6 +342,11 @@
|
||||
}
|
||||
|
||||
private static boolean isCatSittingOnChest(LevelAccessor world, BlockPos pos) {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/CraftingTableBlock.java
|
||||
+++ b/net/minecraft/world/level/block/CraftingTableBlock.java
|
||||
@@ -31,8 +31,9 @@
|
||||
@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;
|
|
@ -8,7 +8,18 @@
|
|||
|
||||
@Override
|
||||
public MapCodec<? extends DispenserBlock> codec() {
|
||||
@@ -88,7 +89,7 @@
|
||||
@@ -79,8 +80,9 @@
|
||||
if (tileentity instanceof DispenserBlockEntity) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@
|
||||
}
|
||||
|
||||
public void dispenseFrom(ServerLevel world, BlockState state, BlockPos pos) {
|
||||
|
@ -17,7 +28,7 @@
|
|||
|
||||
if (tileentitydispenser == null) {
|
||||
DispenserBlock.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", pos);
|
||||
@@ -97,13 +98,17 @@
|
||||
@@ -97,13 +99,17 @@
|
||||
int i = tileentitydispenser.getRandomSlot(world.random);
|
||||
|
||||
if (i < 0) {
|
||||
|
@ -35,7 +46,7 @@
|
|||
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
|
||||
}
|
||||
|
||||
@@ -111,6 +116,12 @@
|
||||
@@ -111,6 +117,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/world/level/block/EnderChestBlock.java
|
||||
+++ b/net/minecraft/world/level/block/EnderChestBlock.java
|
||||
@@ -78,7 +78,7 @@
|
||||
@@ -78,14 +78,16 @@
|
||||
PlayerEnderChestContainer playerEnderChestContainer = player.getEnderChestInventory();
|
||||
if (playerEnderChestContainer != null && world.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChestBlockEntity) {
|
||||
BlockPos blockPos = pos.above();
|
||||
|
@ -8,4 +8,18 @@
|
|||
+ if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
if (world instanceof ServerLevel serverLevel) {
|
||||
- if (world instanceof ServerLevel serverLevel) {
|
||||
- playerEnderChestContainer.setActiveChest(enderChestBlockEntity);
|
||||
- player.openMenu(
|
||||
- new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
|
||||
- );
|
||||
+ // Paper start - Fix InventoryOpenEvent cancellation - moved up;
|
||||
+ playerEnderChestContainer.setActiveChest(enderChestBlockEntity); // Needs to happen before ChestMenu.threeRows as it is required for opening animations
|
||||
+ if (world instanceof ServerLevel serverLevel && player.openMenu(
|
||||
+ new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
|
||||
+ ).isPresent()) {
|
||||
+ // Paper end - Fix InventoryOpenEvent cancellation - moved up;
|
||||
+ // Paper - Fix InventoryOpenEvent cancellation - moved up;
|
||||
player.awardStat(Stats.OPEN_ENDERCHEST);
|
||||
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/FurnaceBlock.java
|
||||
+++ b/net/minecraft/world/level/block/FurnaceBlock.java
|
||||
@@ -45,8 +45,7 @@
|
||||
@Override
|
||||
protected void openContainer(Level world, BlockPos pos, Player player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
- if (blockEntity instanceof FurnaceBlockEntity) {
|
||||
- player.openMenu((MenuProvider)blockEntity);
|
||||
+ if (blockEntity instanceof FurnaceBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_FURNACE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/GrindstoneBlock.java
|
||||
+++ b/net/minecraft/world/level/block/GrindstoneBlock.java
|
||||
@@ -152,8 +152,9 @@
|
||||
@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;
|
|
@ -1,6 +1,16 @@
|
|||
--- a/net/minecraft/world/level/block/HopperBlock.java
|
||||
+++ b/net/minecraft/world/level/block/HopperBlock.java
|
||||
@@ -178,6 +178,7 @@
|
||||
@@ -125,8 +125,7 @@
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity) {
|
||||
- player.openMenu(hopperBlockEntity);
|
||||
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity && player.openMenu(hopperBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INSPECT_HOPPER);
|
||||
}
|
||||
|
||||
@@ -178,6 +177,7 @@
|
||||
|
||||
@Override
|
||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
|
|
|
@ -31,3 +31,13 @@
|
|||
float f = 0.25F * (float) enumdirection.getStepX();
|
||||
float f1 = 0.25F * (float) enumdirection.getStepZ();
|
||||
ItemEntity entityitem = new ItemEntity(world, (double) pos.getX() + 0.5D + (double) f, (double) (pos.getY() + 1), (double) pos.getZ() + 0.5D + (double) f1, itemstack);
|
||||
@@ -282,8 +293,7 @@
|
||||
private void openScreen(Level world, BlockPos pos, Player player) {
|
||||
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||
|
||||
- if (tileentity instanceof LecternBlockEntity) {
|
||||
- player.openMenu((LecternBlockEntity) tileentity);
|
||||
+ if (tileentity instanceof LecternBlockEntity && player.openMenu((LecternBlockEntity) tileentity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_LECTERN);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/LoomBlock.java
|
||||
+++ b/net/minecraft/world/level/block/LoomBlock.java
|
||||
@@ -33,8 +33,9 @@
|
||||
@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;
|
|
@ -1,5 +1,16 @@
|
|||
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
@@ -98,8 +98,8 @@
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
if (world instanceof ServerLevel serverLevel
|
||||
&& world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity
|
||||
- && canOpen(state, world, pos, shulkerBoxBlockEntity)) {
|
||||
- player.openMenu(shulkerBoxBlockEntity);
|
||||
+ && canOpen(state, world, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
|
||||
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.OPEN_SHULKER_BOX);
|
||||
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
|
||||
}
|
||||
@@ -137,7 +137,7 @@
|
||||
itemEntity.setDefaultPickUpDelay();
|
||||
world.addFreshEntity(itemEntity);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/SmithingTableBlock.java
|
||||
+++ b/net/minecraft/world/level/block/SmithingTableBlock.java
|
||||
@@ -38,8 +38,9 @@
|
||||
@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_SMITHING_TABLE);
|
||||
+ } // Paper - Fix InventoryOpenEvent cancellation
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/world/level/block/SmokerBlock.java
|
||||
+++ b/net/minecraft/world/level/block/SmokerBlock.java
|
||||
@@ -44,8 +44,7 @@
|
||||
@Override
|
||||
protected void openContainer(Level world, BlockPos pos, Player player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
- if (blockEntity instanceof SmokerBlockEntity) {
|
||||
- player.openMenu((MenuProvider)blockEntity);
|
||||
+ if (blockEntity instanceof SmokerBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
|
||||
player.awardStat(Stats.INTERACT_WITH_SMOKER);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/StonecutterBlock.java
|
||||
+++ b/net/minecraft/world/level/block/StonecutterBlock.java
|
||||
@@ -48,8 +48,9 @@
|
||||
@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_STONECUTTER);
|
||||
+ } // Paper - Fix InventoryOpenEvent cancellation
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
Loading…
Add table
Reference in a new issue