Fixed bugs with FPS and map sending

This commit is contained in:
Anuken
2018-01-28 10:33:44 -05:00
parent 5cba3050b9
commit adfa66a73b
11 changed files with 87 additions and 39 deletions

View File

@@ -9,8 +9,18 @@ import static io.anuke.mindustry.Vars.debug;
public class Inventory {
private final int[] items = new int[Item.getAllItems().size];
private boolean updated;
public boolean isUpdated(){
return updated;
}
public void setUpdated(boolean updated){
this.updated = updated;
}
public void clearItems(){
updated = true;
Arrays.fill(items, 0);
addItem(Item.stone, 40);
@@ -29,6 +39,7 @@ public class Inventory {
}
public void addItem(Item item, int amount){
updated = true;
items[item.id] += amount;
}
@@ -47,24 +58,29 @@ public class Inventory {
}
public boolean hasItem(ItemStack req){
updated = true;
return items[req.item.id] >= req.amount;
}
public boolean hasItem(Item item, int amount){
updated = true;
return items[item.id] >= amount;
}
public void removeItem(ItemStack req){
updated = true;
items[req.item.id] -= req.amount;
if(items[req.item.id] < 0) items[req.item.id] = 0; //prevents negative item glitches in multiplayer
}
public void removeItems(ItemStack... reqs){
updated = true;
for(ItemStack req : reqs)
removeItem(req);
}
public int[] getItems(){
updated = true;
return items;
}
}