Skip to content

Commit 1111f18

Browse files
committed
Update remote item matching option
1 parent 5ef8349 commit 1111f18

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

paper-server/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ paperweight {
2020
minecraftVersion = providers.gradleProperty("mcVersion")
2121
gitFilePatches = false
2222

23-
updatingMinecraft {
24-
oldPaperCommit = "f4f275519f7c1fbe9db173b7144a4fe81440e365"
25-
}
23+
//updatingMinecraft {
24+
// oldPaperCommit = "f4f275519f7c1fbe9db173b7144a4fe81440e365"
25+
//}
2626

2727
spigot {
2828
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--- a/net/minecraft/network/HashedStack.java
2+
+++ b/net/minecraft/network/HashedStack.java
3+
@@ -17,7 +_,7 @@
4+
}
5+
6+
@Override
7+
- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
8+
+ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic
9+
return stack.isEmpty();
10+
}
11+
};
12+
@@ -27,7 +_,7 @@
13+
hashedStack -> hashedStack instanceof HashedStack.ActualItem actualItem ? Optional.of(actualItem) : Optional.empty()
14+
);
15+
16+
- boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator);
17+
+ boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching); // Paper - add flag to simplify remote matching logic
18+
19+
static HashedStack create(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
20+
return (HashedStack)(stack.isEmpty()
21+
@@ -47,10 +_,10 @@
22+
);
23+
24+
@Override
25+
- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
26+
+ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic
27+
return this.count == stack.getCount()
28+
&& this.item.equals(stack.getItemHolder())
29+
- && this.components.matches(stack.getComponentsPatch(), hashGenerator);
30+
+ && (simplifyMatching || this.components.matches(stack.getComponentsPatch(), hashGenerator)); // Paper - add flag to simplify remote matching logic
31+
}
32+
}
33+
}

paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch

+9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
@Override
3232
public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack itemStack) {
3333
ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, itemStack));
34+
@@ -302,7 +_,7 @@
35+
36+
@Override
37+
public RemoteSlot createSlot() {
38+
- return new RemoteSlot.Synchronized(this.cache::getUnchecked);
39+
+ return new RemoteSlot.Synchronized(this.cache::getUnchecked, ServerPlayer.this.getBukkitEntity().simplifyContainerDesyncCheck()); // Paper - add flag to simplify remote matching logic
40+
}
41+
};
42+
private final ContainerListener containerListener = new ContainerListener() {
3443
@@ -316,6 +_,32 @@
3544
}
3645
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--- a/net/minecraft/world/inventory/RemoteSlot.java
2+
+++ b/net/minecraft/world/inventory/RemoteSlot.java
3+
@@ -29,12 +_,14 @@
4+
5+
public static class Synchronized implements RemoteSlot {
6+
private final HashedPatchMap.HashGenerator hasher;
7+
+ private final boolean simplifyMatching; // Paper - add flag to simplify remote matching logic
8+
@Nullable
9+
private ItemStack remoteStack = null;
10+
@Nullable
11+
private HashedStack remoteHash = null;
12+
13+
- public Synchronized(HashedPatchMap.HashGenerator hasher) {
14+
+ public Synchronized(HashedPatchMap.HashGenerator hasher, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic
15+
+ this.simplifyMatching = simplifyMatching; // Paper - add flag to simplify remote matching logic
16+
this.hasher = hasher;
17+
}
18+
19+
@@ -54,7 +_,7 @@
20+
public boolean matches(ItemStack stack) {
21+
if (this.remoteStack != null) {
22+
return ItemStack.matches(this.remoteStack, stack);
23+
- } else if (this.remoteHash != null && this.remoteHash.matches(stack, this.hasher)) {
24+
+ } else if (this.remoteHash != null && this.remoteHash.matches(stack, this.hasher, this.simplifyMatching)) { // Paper - add flag to simplify remote matching logic
25+
this.remoteStack = stack.copy();
26+
return true;
27+
} else {

0 commit comments

Comments
 (0)