Class ArcaneWorkbenchMenu
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
com.binaris.wizardry.content.menu.ArcaneWorkbenchMenu
public class ArcaneWorkbenchMenu
extends net.minecraft.world.inventory.AbstractContainerMenu
Where Part of the magic happens. This class handles the server-side logic of the Arcane Workbench GUI,
including the slots, shift-clicking, and the apply and clear buttons. Most of this work is delegated to the workbench
item and the changes between when is a wand is in the centre slot and when there isn't one are handled here.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intnet.minecraft.world.Containerstatic final intbooleanstatic final intstatic final intstatic final intFields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, containerId, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, slots -
Constructor Summary
ConstructorsConstructorDescriptionArcaneWorkbenchMenu(int i, net.minecraft.world.entity.player.Inventory playerInv) ArcaneWorkbenchMenu(int id, net.minecraft.world.entity.player.Inventory inventory, net.minecraft.world.Container container) -
Method Summary
Modifier and TypeMethodDescriptionint @Nullable []findSlotRangeForItem(net.minecraft.world.item.ItemStack stack) Finds the range of slots that the given item can go into.voidonApplyButtonPressed(net.minecraft.world.entity.player.Player player) Called when the apply button is pressed.voidonClearButtonPressed(net.minecraft.world.entity.player.Player player) Called when the clear button is pressed.voidonSlotChanged(int slotNumber, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player) Called when a slot is changed.@NotNull net.minecraft.world.item.ItemStackquickMoveStack(@NotNull net.minecraft.world.entity.player.Player player, int index) Handles shift-clicking.booleanstillValid(@NotNull net.minecraft.world.entity.player.Player player) Methods inherited from class net.minecraft.world.inventory.AbstractContainerMenu
addDataSlot, addDataSlots, addSlot, addSlotListener, broadcastChanges, broadcastFullState, canDragTo, canItemQuickReplace, canTakeItemForPickAll, checkContainerDataCount, checkContainerSize, clearContainer, clicked, clickMenuButton, findSlot, getCarried, getItems, getQuickcraftHeader, getQuickcraftMask, getQuickCraftPlaceCount, getQuickcraftType, getRedstoneSignalFromBlockEntity, getRedstoneSignalFromContainer, getSlot, getStateId, getType, incrementStateId, initializeContents, isValidQuickcraftType, isValidSlotIndex, moveItemStackTo, removed, removeSlotListener, resetQuickCraft, resumeRemoteUpdates, sendAllDataToRemote, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotNoCopy, setSynchronizer, slotsChanged, stillValid, suppressRemoteUpdates, transferState
-
Field Details
-
CRYSTAL_SLOT
public static final int CRYSTAL_SLOT- See Also:
-
CENTRE_SLOT
public static final int CENTRE_SLOT- See Also:
-
UPGRADE_SLOT
public static final int UPGRADE_SLOT- See Also:
-
SLOT_RADIUS
public static final int SLOT_RADIUS- See Also:
-
PLAYER_INVENTORY_SIZE
public static final int PLAYER_INVENTORY_SIZE- See Also:
-
container
public net.minecraft.world.Container container -
needsRefresh
public boolean needsRefresh
-
-
Constructor Details
-
ArcaneWorkbenchMenu
public ArcaneWorkbenchMenu(int i, net.minecraft.world.entity.player.Inventory playerInv) -
ArcaneWorkbenchMenu
public ArcaneWorkbenchMenu(int id, net.minecraft.world.entity.player.Inventory inventory, net.minecraft.world.Container container)
-
-
Method Details
-
quickMoveStack
@NotNull public @NotNull net.minecraft.world.item.ItemStack quickMoveStack(@NotNull @NotNull net.minecraft.world.entity.player.Player player, int index) Handles shift-clicking. Attempts to move items between the workbench slots and the player inventory. If the item can go in multiple workbench slots (e.g. spell books), it will try to put it in the first available one. If it can't go in any workbench slots, it will try to move it between the hotbar and main inventory.- Specified by:
quickMoveStackin classnet.minecraft.world.inventory.AbstractContainerMenu- Parameters:
player- The player using the workbench.index- The ID of the slot that was shift-clicked.- Returns:
- The rest of the stack that couldn't be moved, or ItemStack.EMPTY if the entire stack was moved.
-
stillValid
public boolean stillValid(@NotNull @NotNull net.minecraft.world.entity.player.Player player) - Specified by:
stillValidin classnet.minecraft.world.inventory.AbstractContainerMenu
-
onSlotChanged
public void onSlotChanged(int slotNumber, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player) Called when a slot is changed. If the centre slot is changed, this updates the visibility and position of the spell book slots. (Because there's no point in showing them if there's no wand in the centre slot). Depending of the wand upgrade, the number of spell slots may vary, so the spell book slots are arranged in a circle around the centre slot.- Parameters:
slotNumber- The slot number that changed.stack- The new stack in that slot.player- The player viewing the arcane workbench.
-
onApplyButtonPressed
public void onApplyButtonPressed(net.minecraft.world.entity.player.Player player) Called when the apply button is pressed. Delegates the logic to the workbench item in the centre slot, if there is one. Normally it will be a wand, in that case, it applies the spells from the spell book slots to the wand.- Parameters:
player- The player using the workbench.
-
onClearButtonPressed
public void onClearButtonPressed(net.minecraft.world.entity.player.Player player) Called when the clear button is pressed. Delegates the logic to the workbench item in the centre slot, if there is one. Normally it will be a wand, in that case, it clears all spells from the wand.- Parameters:
player- The player using the workbench.
-
findSlotRangeForItem
public int @Nullable [] findSlotRangeForItem(net.minecraft.world.item.ItemStack stack) Finds the range of slots that the given item can go into. This is used for shift-clicking. Returns null if there are no valid slots.- Parameters:
stack- The item stack to find slots for.- Returns:
- An array of two integers, the first is the index of the first valid slot, the second is the index of the last valid slot (inclusive). Or null if there are no valid slots.
-