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