Fixed some junction issues / Improved server crash reporting

This commit is contained in:
Anuken
2018-09-02 22:40:23 -04:00
parent 5e29115c2e
commit 3b63f60462
6 changed files with 34 additions and 17 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 B

After

Width:  |  Height:  |  Size: 183 B

@@ -73,7 +73,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
private Tile mining; private Tile mining;
private CarriableTrait carrying; private CarriableTrait carrying;
private Trail trail = new Trail(12); private Trail trail = new Trail(12);
private Vector2 movement = new Vector2(); private Vector2 movement = new Translator();
private boolean moved; private boolean moved;
public Player(){ public Player(){
@@ -101,9 +101,7 @@ public abstract class BaseBlock{
return true; return true;
} }
/** /**Returns how much power is accepted.*/
* Returns how much power is accepted.
*/
public float addPower(Tile tile, float amount){ public float addPower(Tile tile, float amount){
float canAccept = Math.min(powerCapacity - tile.entity.power.amount, amount); float canAccept = Math.min(powerCapacity - tile.entity.power.amount, amount);
@@ -2,11 +2,12 @@ package io.anuke.mindustry.world.blocks.distribution;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.LiquidBlock; import io.anuke.mindustry.world.blocks.LiquidBlock;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
//TODO fix
public class LiquidJunction extends LiquidBlock{ public class LiquidJunction extends LiquidBlock{
public LiquidJunction(String name){ public LiquidJunction(String name){
@@ -14,6 +15,18 @@ public class LiquidJunction extends LiquidBlock{
hasLiquids = true; hasLiquids = true;
} }
@Override
public void setBars(){
super.setBars();
bars.remove(BarType.liquid);
}
@Override
public void setStats(){
super.setStats();
stats.remove(BlockStat.liquidCapacity);
}
@Override @Override
public void draw(Tile tile){ public void draw(Tile tile){
Draw.rect(name(), tile.worldx(), tile.worldy()); Draw.rect(name(), tile.worldx(), tile.worldy());
@@ -30,8 +43,9 @@ public class LiquidJunction extends LiquidBlock{
dir = (dir + 4) % 4; dir = (dir + 4) % 4;
Tile to = tile.getNearby(dir); Tile to = tile.getNearby(dir);
if(to.block().hasLiquids && to.block().acceptLiquid(to, tile, liquid, amount)) if(to.block().hasLiquids && to.block().acceptLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount))){
to.block().handleLiquid(to, tile, liquid, amount); to.block().handleLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount));
}
} }
@Override @Override
@@ -39,7 +53,6 @@ public class LiquidJunction extends LiquidBlock{
int dir = source.relativeTo(dest.x, dest.y); int dir = source.relativeTo(dest.x, dest.y);
dir = (dir + 4) % 4; dir = (dir + 4) % 4;
Tile to = dest.getNearby(dir); Tile to = dest.getNearby(dir);
return to != null && to.block().hasLiquids && return to != null && to.block().hasLiquids && to.block().acceptLiquid(to, dest, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount));
to.block().acceptLiquid(to, dest, liquid, amount);
} }
} }
@@ -11,20 +11,25 @@ public class LiquidModule extends BlockModule{
private float total; private float total;
private Liquid current = Liquid.getByID(0); private Liquid current = Liquid.getByID(0);
/** /**Returns total amount of liquids.*/
* Returns total amount of liquids.
*/
public float total(){ public float total(){
return total; return total;
} }
/** /**Last recieved or loaded liquid. Only valid for liquid modules with 1 type of liquid.*/
* Last recieved or loaded liquid. Only valid for liquid modules with 1 type of liquid.
*/
public Liquid current(){ public Liquid current(){
return current; return current;
} }
public void reset(Liquid liquid, float amount){
for(int i = 0; i < liquids.length; i++){
liquids[i] = 0f;
}
liquids[liquid.id] = amount;
total = amount;
current = liquid;
}
public float currentAmount(){ public float currentAmount(){
return liquids[current.id]; return liquids[current.id];
} }
@@ -39,8 +39,9 @@ public class CrashHandler{
//add all relevant info, ignoring exceptions //add all relevant info, ignoring exceptions
ex(() -> value.addChild("build", new JsonValue(Version.build))); ex(() -> value.addChild("build", new JsonValue(Version.build)));
ex(() -> value.addChild("mode", new JsonValue(Vars.state.mode.toString()))); ex(() -> value.addChild("mode", new JsonValue(Vars.state.mode.name())));
ex(() -> value.addChild("difficulty", new JsonValue(Vars.state.difficulty.toString()))); ex(() -> value.addChild("state", new JsonValue(Vars.state.getState().name())));
ex(() -> value.addChild("difficulty", new JsonValue(Vars.state.difficulty.name())));
ex(() -> value.addChild("players", new JsonValue(Vars.playerGroup.size()))); ex(() -> value.addChild("players", new JsonValue(Vars.playerGroup.size())));
ex(() -> value.addChild("os", new JsonValue(System.getProperty("os.name")))); ex(() -> value.addChild("os", new JsonValue(System.getProperty("os.name"))));
ex(() -> value.addChild("trace", new JsonValue(parseException(e)))); ex(() -> value.addChild("trace", new JsonValue(parseException(e))));