mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
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 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){
|
||||
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
|
||||
float fract = tile.entity.liquids.get(liquid) / liquidCapacity;
|
||||
@ -142,6 +144,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
if(next == null) return 0;
|
||||
|
||||
next = next.link();
|
||||
next = next.block().getLiquidDestination(next, tile);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Tile getLiquidDestination(Tile tile, Tile from){
|
||||
return tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to put this item into a nearby container, if there are no available
|
||||
* containers, it gets added to the block's inventory.
|
||||
|
@ -1,12 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.LiquidBlock;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
public class LiquidJunction extends LiquidBlock{
|
||||
|
||||
@ -38,23 +36,10 @@ public class LiquidJunction extends LiquidBlock{
|
||||
}
|
||||
|
||||
@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);
|
||||
dir = (dir + 4) % 4;
|
||||
Tile to = tile.getNearby(dir).link();
|
||||
|
||||
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);
|
||||
Tile next = tile.getNearby(dir).link();
|
||||
return next.block().getLiquidDestination(next, tile);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user