From 2e2c8ceab4df1c02e69e5d24c904719db312b324 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 25 Apr 2020 00:04:14 -0400 Subject: [PATCH] Bugfixes --- core/src/mindustry/content/Blocks.java | 2 +- core/src/mindustry/entities/def/TileComp.java | 8 ++++---- core/src/mindustry/world/Block.java | 1 + core/src/mindustry/world/blocks/Autotiler.java | 4 ++++ .../world/blocks/distribution/OverflowGate.java | 2 +- core/src/mindustry/world/blocks/distribution/Sorter.java | 2 +- .../world/blocks/distribution/StackConveyor.java | 9 +++++---- core/src/mindustry/world/blocks/sandbox/ItemVoid.java | 2 +- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 6f5e7639aa..5ca25cddf9 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -914,7 +914,7 @@ public class Blocks implements ContentList{ requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.silicon, 1, Items.graphite, 1)); health = 75; speed = 0.04f; - recharge = 4f; + recharge = 2f; }}; armoredConveyor = new ArmoredConveyor("armored-conveyor"){{ diff --git a/core/src/mindustry/entities/def/TileComp.java b/core/src/mindustry/entities/def/TileComp.java index 96f011570f..de702da2d4 100644 --- a/core/src/mindustry/entities/def/TileComp.java +++ b/core/src/mindustry/entities/def/TileComp.java @@ -178,11 +178,11 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree public byte absoluteRelativeTo(int cx, int cy){ int x = tile.x, y = tile.y; if(Math.abs(x - cx) > Math.abs(y - cy)){ - if(x <= cx - 1 && y == cy) return 0; - if(x >= cx + 1 && y == cy) return 2; + if(x <= cx - 1) return 0; + if(x >= cx + 1) return 2; }else{ - if(x == cx && y <= cy - 1) return 1; - if(x == cx && y >= cy + 1) return 3; + if(y <= cy - 1) return 1; + if(y >= cy + 1) return 3; } return -1; diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index be7565170d..d3a0a410f1 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -44,6 +44,7 @@ public class Block extends UnlockableContent{ public boolean consumesPower = true; public boolean outputsPower = false; public boolean outputsPayload = false; + public boolean acceptsItems = false; public int itemCapacity = 10; public float liquidCapacity = 10f; diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index 1b06503960..ae22eff0ba 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -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){ int realDir = Mathf.mod(rotation - direction, 4); if(directional != null && directional[realDir] != null){ diff --git a/core/src/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/mindustry/world/blocks/distribution/OverflowGate.java index c095730237..66ed86994e 100644 --- a/core/src/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/mindustry/world/blocks/distribution/OverflowGate.java @@ -87,7 +87,7 @@ public class OverflowGate extends Block{ } 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; Tilec to = nearby((from + 2) % 4); if(to == null) return null; diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index 35718d0bbf..9f784b22bf 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -100,7 +100,7 @@ public class Sorter extends Block{ } 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; Tilec to; diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index c3bb8988b2..8fef4e6861 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -73,8 +73,10 @@ public class StackConveyor extends Block implements Autotiler{ if(state == stateLoad){ //standard conveyor mode return otherblock.outputsItems() && lookingAt(tile, rotation, otherx, othery, otherrot, otherblock); }else if(state == stateUnload){ //router mode - return (otherblock.hasItems || otherblock.outputsItems()) && - (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || otherblock instanceof StackConveyor); + return (otherblock.hasItems || otherblock.outputsItems() || otherblock.acceptsItems) && + (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; @@ -151,8 +153,6 @@ public class StackConveyor extends Block implements Autotiler{ public void onProximityUpdate(){ super.onProximityUpdate(); - Fx.healBlockFull.at(tile, 1); - state = stateMove; 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 blendprox = 0; + for(int i = 0; i < 4; i++){ if(blends(tile, rotation(), i)){ blendprox |= (1 << i); diff --git a/core/src/mindustry/world/blocks/sandbox/ItemVoid.java b/core/src/mindustry/world/blocks/sandbox/ItemVoid.java index 646aad25e0..8d36d339b1 100644 --- a/core/src/mindustry/world/blocks/sandbox/ItemVoid.java +++ b/core/src/mindustry/world/blocks/sandbox/ItemVoid.java @@ -8,7 +8,7 @@ public class ItemVoid extends Block{ public ItemVoid(String name){ super(name); - update = solid = true; + update = solid = acceptsItems = true; } public class ItemVoidEntity extends TileEntity{