@@ -113,82 +113,60 @@ public int inputSlots() {
113113 return processor .getSlotsConfig ().getInputItems ();
114114 }
115115
116+ public int allProcessorSlots () {
117+ int i = processor .getSlotsConfig ().getInputItems () + processor .getSlotsConfig ().getOutputItems ();
118+ if (processor .supportEnergyUpgrade ) {
119+ i ++;
120+ }
121+ if (processor .supportSpeedUpgrade ) {
122+ i ++;
123+ }
124+ if (processor .supportsCatalyst ) {
125+ i ++;
126+ }
127+ return i ;
128+ }
129+
116130 @ Override
117131 public @ NotNull ItemStack quickMoveStack (@ NotNull Player pPlayer , int index ) {
118- ItemStack itemstack = ItemStack .EMPTY ;
119132 Slot slot = this .slots .get (index );
120- int maxSlotId = 36 +inputSlots ()+processor .getSlotsConfig ().getOutputItems ()+processor .getUpgradesSlots ()-1 ;
121- if (slot != null && slot .hasItem ()) {
122- ItemStack stack = slot .getItem ();
123- itemstack = stack .copy ();
124- if (index < inputSlots ()) {
125- if (!this .moveItemStackTo (stack , inputSlots ()+processor .getSlotsConfig ().getOutputItems (), 37 , true )) {
133+ int maxSlotId = 35 +allProcessorSlots ();
134+ if (slot == null || !slot .hasItem ()) {
135+ return ItemStack .EMPTY ;
136+ }
137+ ItemStack stack = slot .getItem ();
138+ ItemStack itemstack = stack .copy ();
139+ if (slot instanceof NCSlotItemHandler ) {
140+ if (!this .moveItemStackTo (stack , allProcessorSlots (), maxSlotId , false )) {
141+ return ItemStack .EMPTY ;
142+ }
143+ } else {
144+ if (!this .moveItemStackTo (stack , 0 , inputSlots (), false )) {
145+ if (!this .moveItemStackTo (stack , inputSlots ()+outputSlots (), allProcessorSlots (), false )) {
126146 return ItemStack .EMPTY ;
127147 }
128- } else {
129- if (index < inputSlots ()+processor .getSlotsConfig ().getOutputItems ()
130- && index > inputSlots ()-1 ) {
131- boolean result = this .moveItemStackTo (stack , inputSlots ()+processor .getSlotsConfig ().getOutputItems (), maxSlotId , false );
132- if (!result ) {
133- return ItemStack .EMPTY ;
134- }
135- } else if (index < 28 ) {
136- boolean result = handleUpgradesQuickMove (stack );
137- if (blockEntity .isInputAllowed (stack )) {
138- result = this .moveItemStackTo (stack , 0 , inputSlots (), false );
139- }
140- if (!result ) {
141- result = this .moveItemStackTo (stack , 28 , maxSlotId , false );
142- }
143- if (!result ) {
144- return ItemStack .EMPTY ;
145- }
146- } else if (index < maxSlotId ) {
147- boolean result = false ;
148- if (blockEntity .isInputAllowed (stack )) {
149- result = this .moveItemStackTo (stack , 0 , inputSlots (), false );
150- }
151- if (!result ) {
152- result = this .moveItemStackTo (stack , inputSlots ()+processor .getSlotsConfig ().getOutputItems (), 28 , false );
153- }
154-
155- if (!result ) {
156- return ItemStack .EMPTY ;
157- }
158- }
159- }
160-
161- if (stack .isEmpty ()) {
162- slot .set (ItemStack .EMPTY );
163- } else {
164- slot .setChanged ();
165148 }
149+ }
166150
167- if (stack .getCount () == itemstack .getCount ()) {
168- return ItemStack .EMPTY ;
169- }
151+ if (stack .isEmpty ()) {
152+ slot .set (ItemStack .EMPTY );
153+ } else {
154+ slot .setChanged ();
155+ }
170156
171- slot .onTake (pPlayer , stack );
157+ if (stack .getCount () == itemstack .getCount ()) {
158+ return ItemStack .EMPTY ;
172159 }
173160
161+ slot .onTake (pPlayer , stack );
162+
174163 return itemstack ;
175164 }
176165
177- private boolean handleUpgradesQuickMove (ItemStack stack ) {
178- if (stack .getItem ().equals (NC_ITEMS .get ("upgrade_speed" ).get ()) && processor .supportSpeedUpgrade ) {
179- return this .moveItemStackTo (stack , inputSlots ()+processor .getSlotsConfig ().getOutputItems (), 37 , true );
180- }
181- if (stack .getItem ().equals (NC_ITEMS .get ("upgrade_energy" ).get ()) && processor .supportEnergyUpgrade ) {
182- int id = 37 ;
183- if (processor .supportSpeedUpgrade ) {
184- id ++;
185- }
186- return this .moveItemStackTo (stack , inputSlots ()+processor .getSlotsConfig ().getOutputItems (), id , true );
187- }
188- return false ;
166+ private int outputSlots () {
167+ return processor .getSlotsConfig ().getOutputItems ();
189168 }
190169
191-
192170 private void addSlotRange (IItemHandler handler , int x , int y , int amount , int dx ) {
193171 for (int i = 0 ; i < amount ; i ++) {
194172 addSlot (new SlotItemHandler (handler , slotIndex , x , y ));
0 commit comments