Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/zone/moddev/mc/lib/gui/client/MachineScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,22 @@ private void hover(Element e, boolean enter) {

private void tooltip(GuiGraphics g, Element e, int mx, int my) {
if (!e.common().jeiRecipes().isEmpty() && recipeTooltip.test(this, e)) return;
// A filled slot's lines ride along in the item's own tooltip (getTooltipFromContainerItem).
if (e instanceof Element.Slot && hoveredSlot != null && hoveredSlot.hasItem()) return;
var lines = tooltipLines(e, mx, my);
if (!lines.isEmpty()) g.renderComponentTooltip(font, lines, mx, my);
}

@Override
protected List<Component> getTooltipFromContainerItem(ItemStack stack) {
var lines = super.getTooltipFromContainerItem(stack);
if (hovered instanceof Element.Slot slot && menu.slots.get(slot.index()) == hoveredSlot) {
lines = new ArrayList<>(lines);
lines.addAll(tooltipLines(slot, 0, 0));
}
return lines;
}

/** The tooltip lines of {@code e} with the mouse at {@code mx, my}; empty for none. */
public List<Component> tooltipLines(Element e, int mx, int my) {
var c = e.common();
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/zone/moddev/mc/lib/gui/runtime/MachineMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,20 @@ public ItemStack quickMoveStack(Player player, int index) {
if (!moveItemStackTo(stack, machineSlots, slots.size(), true)) return ItemStack.EMPTY;
} else {
if (host == null) return ItemStack.EMPTY;
var destinations = new ArrayList<Slot>();
for (int destination : host.screenDestinations(stack))
if (destination >= 0
&& destination < machineSlots
&& slots.get(destination).isActive()
&& slots.get(destination).mayPlace(stack))
moveItemStackTo(stack, destination, destination + 1, false);
destinations.add(slots.get(destination));
// Like vanilla's moveItemStackTo: top up matching stacks first, then fill empty slots.
for (var slot : destinations)
if (!stack.isEmpty() && ItemStack.isSameItemSameComponents(slot.getItem(), stack))
moveItemStackTo(stack, slot.index, slot.index + 1, false);
for (var slot : destinations)
if (!stack.isEmpty() && !slot.hasItem())
moveItemStackTo(stack, slot.index, slot.index + 1, false);
if (stack.getCount() == original.getCount()) return ItemStack.EMPTY;
}
if (stack.isEmpty()) source.setByPlayer(ItemStack.EMPTY);
Expand Down