Various bugfixes / Fixed persistent inventory, block crashes

This commit is contained in:
Anuken
2018-07-08 23:59:02 -04:00
parent a0e94577fc
commit 1e8206757d
14 changed files with 102 additions and 31 deletions
@@ -69,11 +69,12 @@ public class BlockInventoryFragment extends Fragment {
}
private void rebuild(boolean actions){
Player player = input.player;
IntSet container = new IntSet();
table.clear();
table.clearChildren();
table.background("inventory");
table.setTouchable(Touchable.enabled);
table.update(() -> {
@@ -121,7 +122,12 @@ public class BlockInventoryFragment extends Fragment {
HandCursorListener l = new HandCursorListener();
l.setEnabled(canPick);
ItemImage image = new ItemImage(item.region, () -> round(tile.entity.items.get(item)));
ItemImage image = new ItemImage(item.region, () -> {
if(tile == null || tile.entity == null){
return "";
}
return round(tile.entity.items.get(item));
});
image.addListener(l);
image.addListener(new InputListener(){
@@ -84,7 +84,6 @@ public class DebugFragment extends Fragment {
FloatingDialog dialog = new FloatingDialog("debug spawn");
for(UnitType type : UnitType.all()){
dialog.content().addImageButton("white", 40, () -> {
dialog.hide();
BaseUnit unit = type.create(player.getTeam());
unit.inventory.addAmmo(type.weapon.getAmmoType(type.weapon.getAcceptedItems().iterator().next()));
unit.setWave();