Implemented various suggestions

- Pathfinding weighs walls more
- C disables all HUD
- Unloader doesn't store items
- Some bugfixes
This commit is contained in:
Anuken
2020-05-07 21:37:41 -04:00
parent 2ca7f553bb
commit 2b9d618bd2
16 changed files with 78 additions and 54 deletions
@@ -266,7 +266,7 @@ public class Drill extends Block{
}
if(dominantItems > 0 && progress >= drillTime + hardnessDrillMultiplier * dominantItem.hardness && items.total() < itemCapacity){
offloadNear(dominantItem);
offload(dominantItem);
useContent(dominantItem);
index++;
@@ -114,7 +114,7 @@ public class GenericCrafter extends Block{
if(outputItem != null){
useContent(outputItem.item);
for(int i = 0; i < outputItem.amount; i++){
offloadNear(outputItem.item);
offload(outputItem.item);
}
}
@@ -112,7 +112,7 @@ public class Separator extends Block{
consume();
if(item != null && items.get(item) < itemCapacity){
offloadNear(item);
offload(item);
}
}
@@ -25,6 +25,7 @@ public class Unloader extends Block{
hasItems = true;
configurable = true;
saveConfig = true;
itemCapacity = 0;
config(Item.class, (tile, item) -> {
tile.items().clear();
@@ -47,40 +48,31 @@ public class Unloader extends Block{
public class UnloaderEntity extends TileEntity{
public Item sortItem = null;
private Item removeItem(Tilec tile, Item item){
if(item == null){
return tile.items().take();
}else{
if(tile.items().has(item)){
tile.items().remove(item, 1);
return item;
}
return null;
}
}
private boolean hasItem(Tilec tile, Item item){
if(item == null){
return tile.items().total() > 0;
}else{
return tile.items().has(item);
}
}
public Tilec dumpingTo;
@Override
public void updateTile(){
if(timer(timerUnload, speed / timeScale()) && items.total() == 0){
if(timer(timerUnload, speed / timeScale())){
for(Tilec other : proximity){
if(other.interactable(team) && other.block().unloadable && other.block().hasItems && items.total() == 0 &&
((sortItem == null && items.total() > 0) || hasItem(other, sortItem))){
offloadNear(removeItem(other, sortItem));
if(other.interactable(team) && other.block().unloadable && other.block().hasItems
&& ((sortItem == null && other.items().total() > 0) || (sortItem != null && other.items().has(sortItem)))){
//make sure the item can't be dumped back into this block
dumpingTo = other;
//get item to be taken
Item item = sortItem == null ? other.items().beginTake() : sortItem;
//remove item if it's dumped correctly
if(put(item)){
if(sortItem == null){
other.items().endTake(item);
}else{
other.items().remove(item, 1);
}
}
}
}
}
dump();
}
@Override
@@ -110,7 +102,7 @@ public class Unloader extends Block{
@Override
public boolean canDump(Tilec to, Item item){
return !(to.block() instanceof StorageBlock);
return !(to.block() instanceof StorageBlock) && to != dumpingTo;
}
@Override