Fixed item bridge crash
This commit is contained in:
@@ -28,12 +28,11 @@ public class DistributionBlocks extends BlockList implements ContentList{
|
|||||||
|
|
||||||
bridgeConveyor = new BufferedItemBridge("bridge-conveyor"){{
|
bridgeConveyor = new BufferedItemBridge("bridge-conveyor"){{
|
||||||
range = 3;
|
range = 3;
|
||||||
hasPower = false;
|
|
||||||
consumes.power(0.05f);
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
phaseConveyor = new ItemBridge("phase-conveyor"){{
|
phaseConveyor = new ItemBridge("phase-conveyor"){{
|
||||||
range = 7;
|
range = 7;
|
||||||
|
hasPower = false;
|
||||||
consumes.power(0.05f);
|
consumes.power(0.05f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public class LiquidBlocks extends BlockList implements ContentList{
|
|||||||
|
|
||||||
phaseConduit = new LiquidBridge("phase-conduit"){{
|
phaseConduit = new LiquidBridge("phase-conduit"){{
|
||||||
range = 7;
|
range = 7;
|
||||||
|
hasPower = false;
|
||||||
|
consumes.power(0.05f);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,8 +243,10 @@ public class ItemBridge extends Block{
|
|||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
ItemBridgeEntity entity = tile.entity();
|
ItemBridgeEntity entity = tile.entity();
|
||||||
Tile other = world.tile(entity.link);
|
Tile other = world.tile(entity.link);
|
||||||
|
boolean linked = false;
|
||||||
|
|
||||||
if(linkValid(tile, other)){
|
if(linkValid(tile, other)){
|
||||||
|
linked = true;
|
||||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||||
int rel2 = tile.relativeTo(source.x, source.y);
|
int rel2 = tile.relativeTo(source.x, source.y);
|
||||||
|
|
||||||
@@ -264,7 +266,7 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tile.entity.items.total() < itemCapacity;
|
return tile.entity.items.total() < itemCapacity && (linked || source.block() instanceof ItemBridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
package io.anuke.mindustry.world.blocks.distribution;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
import io.anuke.mindustry.type.Liquid;
|
|
||||||
import io.anuke.mindustry.world.BarType;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.mindustry.world.blocks.LiquidBlock;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
|
||||||
|
|
||||||
public class TunnelConduit extends LiquidBlock{
|
|
||||||
protected int maxdist = 3;
|
|
||||||
protected float speed = 53;
|
|
||||||
|
|
||||||
protected TunnelConduit(String name){
|
|
||||||
super(name);
|
|
||||||
rotate = true;
|
|
||||||
solid = true;
|
|
||||||
health = 70;
|
|
||||||
hasItems = true;
|
|
||||||
instantTransfer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBars(){
|
|
||||||
super.setBars();
|
|
||||||
bars.remove(BarType.liquid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion[] getIcon(){
|
|
||||||
return new TextureRegion[]{Draw.region(name)};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy(), tile.getRotation() * 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
Tile tunnel = getDestTunnel(tile);
|
|
||||||
if(tunnel == null) return;
|
|
||||||
Tile to = tunnel.getNearby(tunnel.getRotation());
|
|
||||||
if(to == null || !(to.block().hasLiquids)) return;
|
|
||||||
|
|
||||||
if(to.block().acceptLiquid(to, tunnel, liquid, amount))
|
|
||||||
to.block().handleLiquid(to, tunnel, liquid, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
int rot = source.relativeTo(tile.x, tile.y);
|
|
||||||
if(rot != (tile.getRotation() + 2) % 4) return false;
|
|
||||||
Tile tunnel = getDestTunnel(tile);
|
|
||||||
|
|
||||||
if(tunnel != null){
|
|
||||||
Tile to = tunnel.getNearby(tunnel.getRotation());
|
|
||||||
return to != null && (to.block().hasLiquids) &&
|
|
||||||
(to.block()).acceptLiquid(to, tunnel, liquid, amount);
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile getDestTunnel(Tile tile){
|
|
||||||
Tile dest = tile;
|
|
||||||
int rel = (tile.getRotation() + 2) % 4;
|
|
||||||
for(int i = 0; i < maxdist; i++){
|
|
||||||
if(dest == null) return null;
|
|
||||||
dest = dest.getNearby(rel);
|
|
||||||
if(dest != null && dest.block() instanceof TunnelConduit && dest.getRotation() == rel
|
|
||||||
&& dest.getNearby(rel) != null){
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user