This commit is contained in:
Anuken
2020-04-25 00:04:14 -04:00
parent 09e08a474b
commit 2e2c8ceab4
8 changed files with 18 additions and 12 deletions

View File

@ -914,7 +914,7 @@ public class Blocks implements ContentList{
requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.silicon, 1, Items.graphite, 1)); requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.silicon, 1, Items.graphite, 1));
health = 75; health = 75;
speed = 0.04f; speed = 0.04f;
recharge = 4f; recharge = 2f;
}}; }};
armoredConveyor = new ArmoredConveyor("armored-conveyor"){{ armoredConveyor = new ArmoredConveyor("armored-conveyor"){{

View File

@ -178,11 +178,11 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
public byte absoluteRelativeTo(int cx, int cy){ public byte absoluteRelativeTo(int cx, int cy){
int x = tile.x, y = tile.y; int x = tile.x, y = tile.y;
if(Math.abs(x - cx) > Math.abs(y - cy)){ if(Math.abs(x - cx) > Math.abs(y - cy)){
if(x <= cx - 1 && y == cy) return 0; if(x <= cx - 1) return 0;
if(x >= cx + 1 && y == cy) return 2; if(x >= cx + 1) return 2;
}else{ }else{
if(x == cx && y <= cy - 1) return 1; if(y <= cy - 1) return 1;
if(x == cx && y >= cy + 1) return 3; if(y >= cy + 1) return 3;
} }
return -1; return -1;

View File

@ -44,6 +44,7 @@ public class Block extends UnlockableContent{
public boolean consumesPower = true; public boolean consumesPower = true;
public boolean outputsPower = false; public boolean outputsPower = false;
public boolean outputsPayload = false; public boolean outputsPayload = false;
public boolean acceptsItems = false;
public int itemCapacity = 10; public int itemCapacity = 10;
public float liquidCapacity = 10f; public float liquidCapacity = 10f;

View File

@ -80,6 +80,10 @@ public interface Autotiler{
} }
} }
default boolean facing(int x, int y, int rotation, int x2, int y2){
return Point2.equals(x + Geometry.d4(rotation).x,y + Geometry.d4(rotation).y, x2, y2);
}
default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction, boolean checkWorld){ default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction, boolean checkWorld){
int realDir = Mathf.mod(rotation - direction, 4); int realDir = Mathf.mod(rotation - direction, 4);
if(directional != null && directional[realDir] != null){ if(directional != null && directional[realDir] != null){

View File

@ -87,7 +87,7 @@ public class OverflowGate extends Block{
} }
public Tilec getTileTarget(Item item, Tile src, boolean flip){ public Tilec getTileTarget(Item item, Tile src, boolean flip){
int from = relativeTo(src.x, src.y); int from = absoluteRelativeTo(src.x, src.y);
if(from == -1) return null; if(from == -1) return null;
Tilec to = nearby((from + 2) % 4); Tilec to = nearby((from + 2) % 4);
if(to == null) return null; if(to == null) return null;

View File

@ -100,7 +100,7 @@ public class Sorter extends Block{
} }
Tilec getTileTarget(Item item, Tilec source, boolean flip){ Tilec getTileTarget(Item item, Tilec source, boolean flip){
int dir = source.relativeTo(tile.x, tile.y); int dir = source.absoluteRelativeTo(tile.x, tile.y);
if(dir == -1) return null; if(dir == -1) return null;
Tilec to; Tilec to;

View File

@ -73,8 +73,10 @@ public class StackConveyor extends Block implements Autotiler{
if(state == stateLoad){ //standard conveyor mode if(state == stateLoad){ //standard conveyor mode
return otherblock.outputsItems() && lookingAt(tile, rotation, otherx, othery, otherrot, otherblock); return otherblock.outputsItems() && lookingAt(tile, rotation, otherx, othery, otherrot, otherblock);
}else if(state == stateUnload){ //router mode }else if(state == stateUnload){ //router mode
return (otherblock.hasItems || otherblock.outputsItems()) && return (otherblock.hasItems || otherblock.outputsItems() || otherblock.acceptsItems) &&
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || otherblock instanceof StackConveyor); (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
(otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) &&
!(world.ent(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.ent(otherx, othery)).state == stateUnload);
} }
} }
return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock) && otherblock instanceof StackConveyor; return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock) && otherblock instanceof StackConveyor;
@ -151,8 +153,6 @@ public class StackConveyor extends Block implements Autotiler{
public void onProximityUpdate(){ public void onProximityUpdate(){
super.onProximityUpdate(); super.onProximityUpdate();
Fx.healBlockFull.at(tile, 1);
state = stateMove; state = stateMove;
int[] bits = buildBlending(tile, tile.rotation(), null, true); int[] bits = buildBlending(tile, tile.rotation(), null, true);
@ -160,6 +160,7 @@ public class StackConveyor extends Block implements Autotiler{
if(bits[0] == 0 && !blends(tile, tile.rotation(), 0) && blends(tile, tile.rotation(), 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it if(bits[0] == 0 && !blends(tile, tile.rotation(), 0) && blends(tile, tile.rotation(), 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
blendprox = 0; blendprox = 0;
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
if(blends(tile, rotation(), i)){ if(blends(tile, rotation(), i)){
blendprox |= (1 << i); blendprox |= (1 << i);

View File

@ -8,7 +8,7 @@ public class ItemVoid extends Block{
public ItemVoid(String name){ public ItemVoid(String name){
super(name); super(name);
update = solid = true; update = solid = acceptsItems = true;
} }
public class ItemVoidEntity extends TileEntity{ public class ItemVoidEntity extends TileEntity{