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
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public default Identifier getTabSettingsName() {
* @param container The active container.
* @param channel The active channel.
* @param hoveringStorageSlot The storage slot id that is being hovered. -1 if none.
* @param mouseButton The mouse button.
* @param mouseButton The mouse button, as an InputConstants.MOUSE_BUTTON_* value.
* @param hasClickedOutside If the player has clicked outside the gui.
* @param hasClickedInStorage If the player has clicked inside the storage space.
* This can be true even if the storage slot is -1.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cyclops.integratedterminals.client.gui.container;

import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
Expand Down Expand Up @@ -333,7 +334,7 @@ public boolean mouseClicked(MouseButtonEvent mouse, boolean isDoubleClick) {

@Override
public boolean mouseDragged(MouseButtonEvent mouse, double mouseXPrev, double mouseYPrev) {
return this.getFocused() != null && this.isDragging() && mouse.button() == 0 && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
return this.getFocused() != null && this.isDragging() && mouse.button() == InputConstants.MOUSE_BUTTON_LEFT && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
}

public void setFirstRow(int firstRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public boolean mouseClicked(MouseButtonEvent mouse, boolean isDoubleClick) {
this.clicked = true;

// Select a tab
if (mouse.button() == 0
if (mouse.button() == InputConstants.MOUSE_BUTTON_LEFT
&& mouse.y() < topPos + TAB_UNSELECTED_HEIGHT
&& mouse.x() > leftPos + TAB_OFFSET_X
&& mouse.x() <= leftPos + TAB_OFFSET_X + (TAB_WIDTH * getMenu().getTabsClientCount() - 1)) {
Expand Down Expand Up @@ -630,17 +630,17 @@ public boolean mouseClicked(MouseButtonEvent mouse, boolean isDoubleClick) {

// Start dragging over container slots when a storage slot is selected
if (tab.getActiveSlotId() >= 0
&& (mouse.button() == 0 || mouse.button() == 1 || this.getMinecraft().options.keyPickItem.getKey().getValue() == mouse.button() - 100)) {
&& (mouse.button() == InputConstants.MOUSE_BUTTON_LEFT || mouse.button() == InputConstants.MOUSE_BUTTON_RIGHT || isPickItemButton(mouse))) {
if (playerSlot != null && !this.terminalDragSplitting) {
this.terminalDragSplitting = true;
this.terminalDragSplittingButton = mouse.button();
this.terminalDragSplittingSlots.clear();

if (mouse.button() == 0) {
if (mouse.button() == InputConstants.MOUSE_BUTTON_LEFT) {
this.terminalDragMode = 0;
} else if (mouse.button() == 1) {
} else if (mouse.button() == InputConstants.MOUSE_BUTTON_RIGHT) {
this.terminalDragMode = 1;
} else if (this.getMinecraft().options.keyPickItem.getKey().getValue() == mouse.button() - 100) {
} else if (isPickItemButton(mouse)) {
this.terminalDragMode = 2;
}
return true;
Expand All @@ -654,7 +654,7 @@ public boolean mouseClicked(MouseButtonEvent mouse, boolean isDoubleClick) {
// Vanilla would send its own click for it, which the server answers without knowing about
// the terminal's click yet, so it would undo what we predicted until that one arrives too.
if (IModHelpers.get().getMinecraftClientHelpers().isShifted() && playerSlot != null && !playerSlot.getItem().isEmpty()
&& getMenu().getCarried().isEmpty() && (mouse.button() == 0 || mouse.button() == 1)) {
&& getMenu().getCarried().isEmpty() && (mouse.button() == InputConstants.MOUSE_BUTTON_LEFT || mouse.button() == InputConstants.MOUSE_BUTTON_RIGHT)) {
this.clicked = false; // To avoid handling this click again on mouse release
if (tab.handleClick(getMenu(), getMenu().getSelectedChannel(), -1, mouse.button(),
false, false, playerSlot.index, true)) {
Expand Down Expand Up @@ -715,6 +715,10 @@ && getMenu().getCarried().isEmpty() && (mouse.button() == 0 || mouse.button() ==
return super.mouseClicked(mouse, isDoubleClick);
}

protected boolean isPickItemButton(MouseButtonEvent mouse) {
return this.getMinecraft().options.keyPickItem.isActiveAndMatches(InputConstants.Type.MOUSE.getOrCreate(mouse.button()));
}

@Nullable
public Slot getSlotUnderMouse() {
Slot slot = this.hoveredSlot;
Expand Down Expand Up @@ -742,7 +746,7 @@ public boolean mouseDragged(MouseButtonEvent mouse, double mouseXPrev, double mo
}).orElse(false)) {
return true;
}
return this.getFocused() != null && this.isDragging() && mouse.button() == 0 && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
return this.getFocused() != null && this.isDragging() && mouse.button() == InputConstants.MOUSE_BUTTON_LEFT && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
}

private void updateTerminalDragSplitting(ITerminalStorageTabClient<?> tab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected void extractLabels(GuiGraphicsExtractor guiGraphics, int mouseX, int m

@Override
public boolean mouseDragged(MouseButtonEvent mouse, double mouseXPrev, double mouseYPrev) {
return this.getFocused() != null && this.isDragging() && mouse.button() == 0 && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
return this.getFocused() != null && this.isDragging() && mouse.button() == InputConstants.MOUSE_BUTTON_LEFT && this.getFocused().mouseDragged(mouse, mouseXPrev, mouseYPrev) ? true : super.mouseDragged(mouse, mouseXPrev, mouseYPrev);
}

public void setFirstRow(int firstRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.mojang.blaze3d.platform.InputConstants;
import it.unimi.dsi.fastutil.ints.*;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -830,7 +831,7 @@ public boolean handleClick(AbstractContainerMenu container, int channel, int hov

Player player = Minecraft.getInstance().player;
boolean initiateCraftingOption = false;
if (mouseButton == 0 || mouseButton == 1 || mouseButton == 2) {
if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT || mouseButton == InputConstants.MOUSE_BUTTON_RIGHT || mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE) {
TerminalClickType clickType = null;
long moveQuantity = this.activeSlotQuantity;
long movePlayerQuantity = 0;
Expand All @@ -842,29 +843,29 @@ public boolean handleClick(AbstractContainerMenu container, int channel, int hov
} else {
if (shift) {
// Quick move single or max quantity from storage to player
clickType = mouseButton == 2 ? TerminalClickType.STORAGE_QUICK_MOVE_INCREMENTAL : TerminalClickType.STORAGE_QUICK_MOVE;
clickType = mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE ? TerminalClickType.STORAGE_QUICK_MOVE_INCREMENTAL : TerminalClickType.STORAGE_QUICK_MOVE;
} else {
// Pick up
this.activeSlotId = hoveringStorageSlot;
this.activeSlotQuantity = Math.min((int) ingredientComponent.getMatcher()
.getQuantity(hoveringStorageInstance.orElse(matcher.getEmptyInstance())),
viewHandler.getInitialInstanceMovementQuantity());
if (mouseButton == 1) {
if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) {
this.activeSlotQuantity = (int) Math.ceil((double) this.activeSlotQuantity / 2);
} else if (mouseButton == 2) {
} else if (mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE) {
this.activeSlotQuantity = 1;
}
}
}
} else if (hoveredContainerSlot >= 0 && !container.getSlot(hoveredContainerSlot).getItem().isEmpty() && isQuickMove) {
// Quick move max quantity from player to storage
clickType = mouseButton == 2 ? TerminalClickType.PLAYER_QUICK_MOVE_INCREMENTAL : TerminalClickType.PLAYER_QUICK_MOVE;
clickType = mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE ? TerminalClickType.PLAYER_QUICK_MOVE_INCREMENTAL : TerminalClickType.PLAYER_QUICK_MOVE;
} else if (hasClickedInStorage && !container.getCarried().isEmpty()) {
// Move into storage
clickType = TerminalClickType.PLAYER_PLACE_STORAGE;
if (mouseButton == 0) {
if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) {
movePlayerQuantity = viewHandler.getActivePlayerStackQuantity(player.getInventory(), container);
} else if (mouseButton == 1) {
} else if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) {
movePlayerQuantity = viewHandler.getIncrementalInstanceMovementQuantity();
} else {
movePlayerQuantity = (int) Math.ceil((double) viewHandler.getActivePlayerStackQuantity(player.getInventory(), container) / 2);
Expand All @@ -880,10 +881,10 @@ public boolean handleClick(AbstractContainerMenu container, int channel, int hov
} else if (hoveredContainerSlot >= 0) {
// Insert into player inventory
clickType = TerminalClickType.STORAGE_PLACE_PLAYER;
if (mouseButton == 0) {
if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) {
reset = true;
moveQuantity = this.activeSlotQuantity;
} else if (mouseButton == 1) {
} else if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) {
transferFullSelection = false;
moveQuantity = viewHandler.getIncrementalInstanceMovementQuantity();
} else {
Expand All @@ -892,12 +893,12 @@ public boolean handleClick(AbstractContainerMenu container, int channel, int hov
}
this.activeSlotQuantity -= moveQuantity;
} else if (hasClickedInStorage) {
if ((mouseButton == 0 || mouseButton == 2) && this.activeSlotId == hoveringStorageSlot) {
if ((mouseButton == InputConstants.MOUSE_BUTTON_LEFT || mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE) && this.activeSlotId == hoveringStorageSlot) {
// Increase the active quantity
this.activeSlotQuantity = (int) Math.min(ingredientComponent.getMatcher().getQuantity(hoveringStorageInstance.get()),
this.activeSlotQuantity + (shift ? viewHandler.getInitialInstanceMovementQuantity()
: viewHandler.getIncrementalInstanceMovementQuantity()));
} else if (mouseButton == 1) {
} else if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) {
// Decrease active quantity
this.activeSlotQuantity = Math.max(0, this.activeSlotQuantity - (shift ? viewHandler.getInitialInstanceMovementQuantity()
: viewHandler.getIncrementalInstanceMovementQuantity()));
Expand Down Expand Up @@ -1268,7 +1269,7 @@ public int dragIntoSlot(AbstractContainerMenu container, int channel, Slot slot,
int activeSlotQuantityOld = this.activeSlotQuantity;

this.activeSlotQuantity = quantity;
this.handleClick(container, channel, getActiveSlotId(), 0, false, false, slot.index, false);
this.handleClick(container, channel, getActiveSlotId(), InputConstants.MOUSE_BUTTON_LEFT, false, false, slot.index, false);

this.activeSlotId = oldActiveSlotId;
this.activeSlotQuantity = activeSlotQuantityOld;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedterminals.core.terminalstorage.button;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -34,7 +35,7 @@ public ButtonImage createButton(int x, int y) {
public void onClick(TerminalStorageTabIngredientComponentClient<T, ?> clientTab,
TerminalStorageTabIngredientComponentCommon<T, ?> commomTab, ButtonImage guiButton,
int channel, MouseButtonEvent mouse, boolean isDoubleClick) {
this.button.active = mouse.button() == 0 ? this.button.active.next() : TerminalButtonFilterCrafting.FilterType.getDefault();
this.button.active = mouse.button() == InputConstants.MOUSE_BUTTON_LEFT ? this.button.active.next() : TerminalButtonFilterCrafting.FilterType.getDefault();

CompoundTag data = new CompoundTag();
this.button.active.write(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedterminals.core.terminalstorage.button;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -35,7 +36,7 @@ public ButtonImage createButton(int x, int y) {
public void onClick(TerminalStorageTabIngredientComponentClient<T, ?> clientTab,
TerminalStorageTabIngredientComponentItemStackCraftingCommon commomTab, ButtonImage guiButton,
int channel, MouseButtonEvent mouse, boolean isDoubleClick) {
this.button.active = mouse.button() == 0 ? TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.values()[(this.button.active.ordinal() + 1) % TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.values().length] : TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.DISABLED;
this.button.active = mouse.button() == InputConstants.MOUSE_BUTTON_LEFT ? TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.values()[(this.button.active.ordinal() + 1) % TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.values().length] : TerminalButtonItemStackCraftingGridAutoRefill.AutoRefillType.DISABLED;

CompoundTag data = new CompoundTag();
data.putInt("active", this.button.active.ordinal());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedterminals.core.terminalstorage.button;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -35,7 +36,7 @@ public ButtonImage createButton(int x, int y) {

@Override
public void onClick(TerminalStorageTabIngredientComponentClient<T, ?> clientTab, @Nullable TerminalStorageTabIngredientComponentCommon<T, ?> commonTab, ButtonImage guiButton, int channel, MouseButtonEvent mouse, boolean isDoubleClick) {
this.button.scale = mouse.button() == 0 ? TerminalButtonScaleGui.GuiScale.values()[(this.button.scale.ordinal() + 1) % TerminalButtonScaleGui.GuiScale.values().length] : TerminalButtonScaleGui.GuiScale.SCALE_XY;
this.button.scale = mouse.button() == InputConstants.MOUSE_BUTTON_LEFT ? TerminalButtonScaleGui.GuiScale.values()[(this.button.scale.ordinal() + 1) % TerminalButtonScaleGui.GuiScale.values().length] : TerminalButtonScaleGui.GuiScale.SCALE_XY;

CompoundTag data = new CompoundTag();
data.putInt("scale", this.button.scale.ordinal());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedterminals.core.terminalstorage.button;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -28,7 +29,7 @@ public ButtonSort createButton(int x, int y) {
@Override
public void onClick(TerminalStorageTabIngredientComponentClient<T, ?> clientTab, ITerminalStorageTabCommon commonTab,
ButtonSort guiButton, int channel, MouseButtonEvent mouse, boolean isDoubleClick) {
if (mouse.button() == 0) {
if (mouse.button() == InputConstants.MOUSE_BUTTON_LEFT) {
if (this.button.active) {
if (this.button.descending) {
this.button.descending = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.core.HolderLookup;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.Identifier;
Expand Down Expand Up @@ -308,7 +309,7 @@ public ItemStack quickMoveStack(Player player, int slotID) {
if(player.level().isClientSide()) {
Optional<ITerminalStorageTabClient<?>> tabOptional = this.selectedClientTabProvider.getSelectedClientTab();
if(tabOptional.isPresent() && !tabOptional.get().isQuickMovePrevented(slotID)) {
tabOptional.get().handleClick(this, this.getSelectedChannel(), -1, 0,
tabOptional.get().handleClick(this, this.getSelectedChannel(), -1, InputConstants.MOUSE_BUTTON_LEFT,
false, false, slotID, true);
}
}
Expand Down
Loading