RemoteSlot .java

net.minecraft.world.inventory.RemoteSlot (interface): members: Synchronized, receive, PLACEHOLDER, force, matches. imports: HashedPatchMap, HashedStack.

net.minecraft.world.inventoryinterface69 linescommon1.6 KB

API Surface (7)

void receive(final HashedStack incoming)
void force(final ItemStack outgoing)
boolean matches(final ItemStack local)
void force(final ItemStack outgoing)
void receive(final HashedStack incoming)
boolean matches(final ItemStack local)
void copyFrom(final RemoteSlot.Synchronized other)

Fields & Constants (1)

PLACEHOLDER

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RemoteSlot.java69 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.inventory;
2
3
import net.minecraft.network.HashedPatchMap;
4
import net.minecraft.network.HashedStack;
5
import net.minecraft.world.item.ItemStack;
6
import org.jspecify.annotations.Nullable;
7
8
public interface RemoteSlot {
9
	RemoteSlot PLACEHOLDER = new RemoteSlot() {
10
		@Override
11
		public void receive(final HashedStack incoming) {
12
		}
13
14
		@Override
15
		public void force(final ItemStack outgoing) {
16
		}
17
18
		@Override
19
		public boolean matches(final ItemStack local) {
20
			return true;
21
		}
22
	};
23
24
	void force(ItemStack outgoing);
25
26
	void receive(HashedStack incoming);
27
28
	boolean matches(ItemStack local);
29
30
	class Synchronized implements RemoteSlot {
31
		private final HashedPatchMap.HashGenerator hasher;
32
		private @Nullable ItemStack remoteStack = null;
33
		private @Nullable HashedStack remoteHash = null;
34
35
		public Synchronized(final HashedPatchMap.HashGenerator hasher) {
36
			this.hasher = hasher;
37
		}
38
39
		@Override
40
		public void force(final ItemStack outgoing) {
41
			this.remoteStack = outgoing.copy();
42
			this.remoteHash = null;
43
		}
44
45
		@Override
46
		public void receive(final HashedStack incoming) {
47
			this.remoteStack = null;
48
			this.remoteHash = incoming;
49
		}
50
51
		@Override
52
		public boolean matches(final ItemStack local) {
53
			if (this.remoteStack != null) {
54
				return ItemStack.matches(this.remoteStack, local);
55
			} else if (this.remoteHash != null && this.remoteHash.matches(local, this.hasher)) {
56
				this.remoteStack = local.copy();
57
				return true;
58
			} else {
59
				return false;
60
			}
61
		}
62
63
		public void copyFrom(final RemoteSlot.Synchronized other) {
64
			this.remoteStack = other.remoteStack;
65
			this.remoteHash = other.remoteHash;
66
		}
67
	}
68
}
69

Decompiled Minecraft 26.3 source of RemoteSlot (net/minecraft/world/inventory/RemoteSlot.java) with Mojang official mappings, stored verbatim on the site.