@@ -44,83 +44,30 @@ public class GuiMEItemInputBus extends GuiMEItemBus implements IJEIGhostIngredie
4444 private static final ResourceLocation TEXTURES_INPUT_BUS = new ResourceLocation (ModularMachinery .MODID , "textures/gui/meiteminputbus.png" );
4545
4646 protected final Map <IGhostIngredientHandler .Target <?>, Object > mapTargetSlot = new Object2ObjectOpenHashMap <>();
47- private int invActionAmount = 0 ;
4847
4948 public GuiMEItemInputBus (final MEItemInputBus te , final EntityPlayer player ) {
5049 super (new ContainerMEItemInputBus (te , player ));
5150 this .ySize = 204 ;
5251 }
5352
54- private static int getAddAmount () {
55- int addAmount ;
56- // SHIFT + CTRL + ALT 1000000
57- // ALT + CTRL 100000
58- // ALT + SHIFT 10000
59- // SHIFT + CTRL 1000
60- // CTRL 100
61- // SHIFT 10
62- if (isShiftDown () && isControlDown () && isAltDown ()) {
63- addAmount = 1_000_000 ;
64- } else if (isAltDown () && isControlDown ()) {
65- addAmount = 100_000 ;
66- } else if (isAltDown () && isShiftDown ()) {
67- addAmount = 10_000 ;
68- } else if (isShiftDown () && isControlDown ()) {
69- addAmount = 1_000 ;
70- } else if (isControlDown ()) {
71- addAmount = 100 ;
72- } else if (isShiftDown ()) {
73- addAmount = 10 ;
74- } else {
75- addAmount = 1 ;
76- }
77- return addAmount ;
78- }
79-
8053 private static List <String > getAddActionInfo () {
8154 List <String > tooltip = new ArrayList <>();
8255 tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action" ));
8356 // Quite a sight, isn't it?
84- String addAmount = MiscUtils .formatDecimal (getAddAmount ());
85- if (isShiftDown () && isControlDown () && isAltDown ()) {
86- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
87- "SHIFT + CTRL + ALT" , addAmount ));
88- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
89- "SHIFT + CTRL + ALT" , addAmount ));
90- } else if (isAltDown () && isControlDown ()) {
91- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
92- "CTRL + ALT" , addAmount ));
93- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
94- "CTRL + ALT" , addAmount ));
95- } else if (isAltDown () && isShiftDown ()) {
96- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
97- "SHIFT + ALT" , addAmount ));
98- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
99- "SHIFT + ALT" , addAmount ));
100- } else if (isShiftDown () && isControlDown ()) {
101- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
102- "SHIFT + CTRL" , addAmount ));
103- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
104- "SHIFT + CTRL" , addAmount ));
105- } else if (isControlDown ()) {
106- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
107- "CTRL" , addAmount ));
108- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
109- "CTRL" , addAmount ));
110- } else if (isShiftDown ()) {
111- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase" ,
112- "SHIFT" , addAmount ));
113- tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease" ,
114- "SHIFT" , addAmount ));
57+ // It was truly a beautiful sight...
58+
59+ if (isShiftDown () && isControlDown ()) {
60+ String keyCombination = "SHIFT + CTRL" ;
61+ tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.multiply" ,
62+ keyCombination ));
63+ tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.divide" ,
64+ keyCombination ));
11565 } else {
11666 tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.increase.normal" ));
11767 tooltip .add (TextFormatting .GRAY + I18n .format ("gui.meiteminputbus.inv_action.decrease.normal" ));
11868 }
119- return tooltip ;
120- }
12169
122- private static boolean isAltDown () {
123- return Keyboard .isKeyDown (Keyboard .KEY_LMENU ) || Keyboard .isKeyDown (Keyboard .KEY_RMENU );
70+ return tooltip ;
12471 }
12572
12673 private static boolean isControlDown () {
@@ -159,29 +106,53 @@ protected void onMouseWheelEvent(final int x, final int y, final int wheel) {
159106 return ;
160107 }
161108
162- int amount = wheel < 0 ? -getAddAmount () : getAddAmount ();
163109 int stackCount = stack .getCount ();
110+ int countToSend = getUpdatedCount (isScrollingUp (wheel ), stackCount );
164111
165- if (amount > 0 ) {
166- if (stackCount + amount > slot .getSlotStackLimit ()) {
112+ if (countToSend > 0 ) {
113+ if (countToSend > slot .getSlotStackLimit ()) {
167114 return ;
168115 }
169- } else if (stackCount - amount <= 0 ) {
170- return ;
171116 }
172117
173- this .invActionAmount += amount ;
174- ClientProxy .clientScheduler .addRunnable (() -> sendInvActionToServer (slot .slotNumber ), 0 );
118+ ClientProxy .clientScheduler .addRunnable (() -> sendInvActionToServer (slot .slotNumber , countToSend ), 0 );
119+ }
120+
121+ private boolean isScrollingUp (int wheel ) {
122+ return wheel >= 0 ;
123+ }
124+
125+ private int getUpdatedCount (boolean isScrollingUp , int currentAmount ) {
126+ if (isShiftDown () && isControlDown ()) {
127+ if (isScrollingUp ) {
128+ // Overflow protection
129+ if (currentAmount <= Integer .MAX_VALUE / 2 ) {
130+ return 2 * currentAmount ;
131+ }
132+ return Integer .MAX_VALUE ;
133+ } else {
134+ return Math .max (1 , currentAmount / 2 );
135+ }
136+ } else {
137+ if (isScrollingUp ) {
138+ // Overflow protection
139+ if (currentAmount < Integer .MAX_VALUE ) {
140+ return 1 + currentAmount ;
141+ }
142+ return Integer .MAX_VALUE ;
143+ } else {
144+ return Math .max (1 , currentAmount - 1 );
145+ }
146+ }
175147 }
176148
177- public void sendInvActionToServer (int slotNumber ) {
178- if (invActionAmount == 0 ) {
149+ public void sendInvActionToServer (int slotNumber , int amountToSend ) {
150+ if (amountToSend == 0 ) {
179151 return ;
180152 }
181153 ModularMachinery .NET_CHANNEL .sendToServer (new PktMEInputBusInvAction (
182- invActionAmount , slotNumber
154+ amountToSend , slotNumber
183155 ));
184- invActionAmount = 0 ;
185156 }
186157
187158 @ Override
0 commit comments