Fixed startup crashing

This commit is contained in:
Anuken
2019-03-31 10:37:52 -04:00
parent a6c9bd3182
commit 160ae4e244
5 changed files with 21 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.ui;
import io.anuke.arc.Core;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.OrderedMap;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.scene.ui.layout.Table;
@@ -45,7 +46,7 @@ public class ContentDisplay{
BlockStats stats = block.stats;
for(StatCategory cat : stats.toMap().keys()){
OrderedMap<BlockStat, StatValue> map = stats.toMap().get(cat);
OrderedMap<BlockStat, Array<StatValue>> map = stats.toMap().get(cat);
if(map.size == 0) continue;
@@ -56,7 +57,11 @@ public class ContentDisplay{
table.table(inset -> {
inset.left();
inset.add("[LIGHT_GRAY]" + stat.localized() + ":[] ");
map.get(stat).display(inset);
Array<StatValue> arr = map.get(stat);
for(StatValue value : arr){
value.display(inset);
}
//map.get(stat).display(inset);
}).fillX().padLeft(10);
table.row();
}

View File

@@ -23,7 +23,7 @@ public class LiquidDisplay extends Table{
t.add(Strings.toFixed(amount, 2));
add(t);
}
}}).size(8*3);
}}).size(8*4);
add(liquid.localizedName()).padLeft(3);
}
}

View File

@@ -45,7 +45,7 @@ public class GenericCrafter extends Block{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.itemsSecond);
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
if(outputItem != null){
stats.add(BlockStat.output, outputItem);
@@ -65,7 +65,6 @@ public class GenericCrafter extends Block{
}
}
@Override
public TextureRegion[] generateIcons(){
return drawIcons == null ? super.generateIcons() : drawIcons.get();
@@ -131,8 +130,6 @@ public class GenericCrafter extends Block{
return itemCapacity;
}
public static class GenericCrafterEntity extends TileEntity{
public float progress;
public float totalProgress;

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.world.meta;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectMap.Entry;
import io.anuke.arc.collection.OrderedMap;
import io.anuke.mindustry.type.Item;
@@ -10,7 +11,7 @@ import io.anuke.mindustry.world.meta.values.*;
/**Hold and organizes a list of block stats.*/
public class BlockStats{
private final OrderedMap<StatCategory, OrderedMap<BlockStat, StatValue>> map = new OrderedMap<>();
private final OrderedMap<StatCategory, OrderedMap<BlockStat, Array<StatValue>>> map = new OrderedMap<>();
private boolean dirty;
/**Adds a single float value with this stat, formatted to 2 decimal places.*/
@@ -50,15 +51,15 @@ public class BlockStats{
/**Adds a stat value.*/
public void add(BlockStat stat, StatValue value){
if(map.containsKey(stat.category) && map.get(stat.category).containsKey(stat)){
throw new RuntimeException("Duplicate stat entry: \"" + stat + "\" in block.");
}
//if(map.containsKey(stat.category) && map.get(stat.category).containsKey(stat)){
// throw new RuntimeException("Duplicate stat entry: \"" + stat + "\" in block.");
//}
if(!map.containsKey(stat.category)){
map.put(stat.category, new OrderedMap<>());
}
map.get(stat.category).put(stat, value);
map.get(stat.category).getOr(stat, Array::new).add(value);
dirty = true;
}
@@ -74,11 +75,11 @@ public class BlockStats{
dirty = true;
}
public OrderedMap<StatCategory, OrderedMap<BlockStat, StatValue>> toMap(){
public OrderedMap<StatCategory, OrderedMap<BlockStat, Array<StatValue>>> toMap(){
//sort stats by index if they've been modified
if(dirty){
map.orderedKeys().sort();
for(Entry<StatCategory, OrderedMap<BlockStat, StatValue>> entry : map.entries()){
for(Entry<StatCategory, OrderedMap<BlockStat, Array<StatValue>>> entry : map.entries()){
entry.value.orderedKeys().sort();
}