geforkt von Mirrors/Paper
c5a10665b8
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
66 Zeilen
3.9 KiB
Diff
66 Zeilen
3.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jakub Zacek <dawon@dawon.eu>
|
|
Date: Sun, 24 Apr 2022 22:56:59 +0200
|
|
Subject: [PATCH] Add PlayerInventorySlotChangeEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index ad3896dd524acb573adffdfb38b13dd699539cef..3dbaa3c6b75a0f8bfdef42d210f2ac6f560cde3d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -352,6 +352,25 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
|
|
|
}
|
|
}
|
|
+ // Paper start - Add PlayerInventorySlotChangeEvent
|
|
+ @Override
|
|
+ public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
|
|
+ Slot slot = handler.getSlot(slotId);
|
|
+ if (!(slot instanceof ResultSlot)) {
|
|
+ if (slot.container == ServerPlayer.this.getInventory()) {
|
|
+ if (io.papermc.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
|
+ return;
|
|
+ }
|
|
+ io.papermc.paper.event.player.PlayerInventorySlotChangeEvent event = new io.papermc.paper.event.player.PlayerInventorySlotChangeEvent(ServerPlayer.this.getBukkitEntity(), slotId, CraftItemStack.asBukkitCopy(oldStack), CraftItemStack.asBukkitCopy(stack));
|
|
+ event.callEvent();
|
|
+ if (event.shouldTriggerAdvancements()) {
|
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Add PlayerInventorySlotChangeEvent
|
|
|
|
@Override
|
|
public void dataChanged(AbstractContainerMenu handler, int property, int value) {}
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
index b8d8aad81f54f7f43c01da075e63ec9173750bec..f7b9849819c185cd89533aca1f6d34398ffc1077 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
@@ -302,7 +302,7 @@ public abstract class AbstractContainerMenu {
|
|
while (iterator.hasNext()) {
|
|
ContainerListener icrafting = (ContainerListener) iterator.next();
|
|
|
|
- icrafting.slotChanged(this, slot, itemstack2);
|
|
+ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/ContainerListener.java b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
index 0e19cc55646625bf32a354d3df2dc2d6bcff96f4..eba024c9aadef8902aacccea1584ffbee6c04e44 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
@@ -5,5 +5,11 @@ import net.minecraft.world.item.ItemStack;
|
|
public interface ContainerListener {
|
|
void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack);
|
|
|
|
+ // Paper start - Add PlayerInventorySlotChangeEvent
|
|
+ default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
|
|
+ slotChanged(handler, slotId, stack);
|
|
+ }
|
|
+ // Paper end - Add PlayerInventorySlotChangeEvent
|
|
+
|
|
void dataChanged(AbstractContainerMenu handler, int property, int value);
|
|
}
|