You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create the block entity for the primary anchor of a multipart workbench.
149
+
*
150
+
* @param pos the position where the block entity would be created
151
+
* @param state the block state at the position
152
+
* @return the new block entity when this block is the primary anchor (lower half with TYPE `LEFT` or `SINGLE`), or `null` if this block is a secondary part
* Open the workbench menu for the block's master part when a player interacts without an item.
175
+
*
176
+
* @param state the block state at the clicked position
177
+
* @param level the level in which the interaction occurs
178
+
* @param pos the position of the block that was interacted with
179
+
* @param player the player performing the interaction
180
+
* @param hitResult details about the hit (hit position and face)
181
+
* @return {@code InteractionResult.CONSUME} if a menu was opened on the server, {@code InteractionResult.SUCCESS} on the client, {@code InteractionResult.PASS} otherwise
* Handles a player's interaction with the workbench when no item is used.
105
+
*
106
+
* <p>On the client this acknowledges the interaction. On the server this method
107
+
* is a hook for workbench-specific handling; if the workbench processes the
108
+
* interaction it will consume it, otherwise the interaction is passed to other handlers.</p>
109
+
*
110
+
* @param state the block state of the workbench
111
+
* @param level the world in which the interaction occurs
112
+
* @param pos the position of the interacted block
113
+
* @param player the player performing the interaction
114
+
* @param hit the hit result describing the interaction point
115
+
* @return {@code InteractionResult.SUCCESS} on client, {@code InteractionResult.CONSUME} if handled by the workbench, or {@code InteractionResult.PASS} otherwise
* Compute the master (base) block position for this block based on its state.
135
+
*
136
+
* @param state the block state of the current block
137
+
* @param pos the position of the current block
138
+
* @return the position of the master (base) block: if the block is the upper half, the block below is used; if the block's type is `RIGHT`, the position is offset one block counterclockwise from its facing direction; otherwise the original position
* Collects nearby inventory-containing block entities within the configured scan radius and vertical range.
50
+
*
51
+
* Scans a square area centered on this entity from -scanRadius..+scanRadius on X/Z and -2..+2 on Y, gathers any
52
+
* block entities implementing `Container`, and returns them sorted by increasing distance to this entity.
53
+
*
54
+
* @return a list of nearby `Container` instances sorted by proximity; an empty list if none are found or if the world (`level`) is null
55
+
*/
33
56
publicList<Container> getNearbyInventories() {
34
57
List<Container> inventories = newArrayList<>();
35
58
if (level == null) {
@@ -55,20 +78,39 @@ public List<Container> getNearbyInventories() {
55
78
returninventories;
56
79
}
57
80
58
-
// --- RECYCLER LOGIC ---
81
+
/**
82
+
* Attempt to recycle an ItemStack into component items and distribute those components to nearby inventories or drop them at the workbench location.
83
+
*
84
+
* <p>The base implementation is a no-op; subclasses should override to perform actual recycling. Implementations are expected to insert resulting items into nearby Container block entities when possible and otherwise spawn the items at this entity's world position.</p>
85
+
*
86
+
* @param stack the ItemStack to recycle
87
+
*/
59
88
publicvoidattemptRecycle(ItemStackstack) {
60
89
// Logic to break down stack.getItem() and return components
61
90
// to nearby chests or drop them at worldPosition.
62
91
}
63
92
93
+
/**
94
+
* Create the container menu presented to the player when they open this workbench.
95
+
*
96
+
* @param syncId the window synchronization id provided by the client
97
+
* @param playerInventory the player's inventory
98
+
* @param player the player opening the menu
99
+
* @return the created AbstractContainerMenu, or `null` if no menu should be opened
0 commit comments