This commit is contained in:
Anuken
2020-02-17 09:27:51 -05:00
parent 1fe0a7d81e
commit b96d5c417f
3 changed files with 22 additions and 7 deletions

View File

@@ -1,10 +1,9 @@
package mindustry.world.modules;
import mindustry.type.Item;
import mindustry.type.ItemStack;
import mindustry.type.*;
import java.io.*;
import java.util.Arrays;
import java.util.*;
import static mindustry.Vars.content;
@@ -69,15 +68,24 @@ public class ItemModule extends BlockModule{
return total;
}
public Item first(){
for(int i = 0; i < items.length; i++){
if(items[i] > 0){
return content.item(i);
}
}
return null;
}
public Item take(){
for(int i = 0; i < items.length; i++){
int index = (i + takeRotation);
if(index >= items.length) index -= items.length; //conditional instead of mod
if(index >= items.length) index -= items.length;
if(items[index] > 0){
items[index] --;
total --;
takeRotation = index + 1;
return content.item(index % items.length);
return content.item(index);
}
}
return null;