Fixed #745
This commit is contained in:
@@ -115,6 +115,8 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
Tile other = proximity.get((i + dump) % proximity.size);
|
Tile other = proximity.get((i + dump) % proximity.size);
|
||||||
Tile in = Edges.getFacingEdge(tile, other);
|
Tile in = Edges.getFacingEdge(tile, other);
|
||||||
|
|
||||||
|
other = other.block().getLiquidDestination(other, tile);
|
||||||
|
|
||||||
if(other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){
|
if(other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){
|
||||||
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
|
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
|
||||||
float fract = tile.entity.liquids.get(liquid) / liquidCapacity;
|
float fract = tile.entity.liquids.get(liquid) / liquidCapacity;
|
||||||
@@ -142,6 +144,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
if(next == null) return 0;
|
if(next == null) return 0;
|
||||||
|
|
||||||
next = next.link();
|
next = next.link();
|
||||||
|
next = next.block().getLiquidDestination(next, tile);
|
||||||
|
|
||||||
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){
|
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){
|
||||||
|
|
||||||
@@ -179,6 +182,10 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tile getLiquidDestination(Tile tile, Tile from){
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to put this item into a nearby container, if there are no available
|
* Tries to put this item into a nearby container, if there are no available
|
||||||
* containers, it gets added to the block's inventory.
|
* containers, it gets added to the block's inventory.
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package io.anuke.mindustry.world.blocks.distribution;
|
package io.anuke.mindustry.world.blocks.distribution;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
import io.anuke.mindustry.world.blocks.LiquidBlock;
|
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
|
||||||
|
|
||||||
public class LiquidJunction extends LiquidBlock{
|
public class LiquidJunction extends LiquidBlock{
|
||||||
|
|
||||||
@@ -38,23 +36,10 @@ public class LiquidJunction extends LiquidBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public Tile getLiquidDestination(Tile tile, Tile source){
|
||||||
int dir = source.relativeTo(tile.x, tile.y);
|
int dir = source.relativeTo(tile.x, tile.y);
|
||||||
dir = (dir + 4) % 4;
|
dir = (dir + 4) % 4;
|
||||||
Tile to = tile.getNearby(dir).link();
|
Tile next = tile.getNearby(dir).link();
|
||||||
|
return next.block().getLiquidDestination(next, tile);
|
||||||
if(to.block().hasLiquids && to.block().acceptLiquid(to, tile, liquid, amount)){
|
|
||||||
to.block().handleLiquid(to, tile, liquid, amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptLiquid(Tile dest, Tile source, Liquid liquid, float amount){
|
|
||||||
int dir = source.relativeTo(dest.x, dest.y);
|
|
||||||
dir = (dir + 4) % 4;
|
|
||||||
Tile to = dest.getNearby(dir);
|
|
||||||
if(to == null) return false;
|
|
||||||
to = to.link();
|
|
||||||
return to != null && to.entity != null && to.block().hasLiquids && to.block().acceptLiquid(to, dest, liquid, amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user