Mining bugfix
This commit is contained in:
@@ -19,10 +19,7 @@ import io.anuke.mindustry.graphics.Trail;
|
||||
import io.anuke.mindustry.io.TypeIO;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
@@ -192,6 +189,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
this.mining = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMine(Item item){
|
||||
return item.hardness <= mech.drillPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getArmor(){
|
||||
return mech.armor + mech.getExtraArmor(this);
|
||||
|
||||
@@ -58,6 +58,9 @@ public interface BuilderTrait extends Entity{
|
||||
/**Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all.*/
|
||||
float getBuildPower(Tile tile);
|
||||
|
||||
/**Returns whether or not this builder can mine a specific item type.*/
|
||||
boolean canMine(Item item);
|
||||
|
||||
/**Whether this type of builder can begin creating new blocks.*/
|
||||
default boolean canCreateBlocks(){
|
||||
return true;
|
||||
@@ -236,7 +239,8 @@ public interface BuilderTrait extends Entity{
|
||||
Tile tile = getMineTile();
|
||||
TileEntity core = unit.getClosestCore();
|
||||
|
||||
if(core == null || tile.block() != Blocks.air || unit.distanceTo(tile.worldx(), tile.worldy()) > mineDistance || tile.floor().drops == null || !unit.inventory.canAcceptItem(tile.floor().drops.item)){
|
||||
if(core == null || tile.block() != Blocks.air || unit.distanceTo(tile.worldx(), tile.worldy()) > mineDistance
|
||||
|| tile.floor().drops == null || !unit.inventory.canAcceptItem(tile.floor().drops.item) || !canMine(tile.floor().drops.item)){
|
||||
setMineTile(null);
|
||||
}else{
|
||||
Item item = tile.floor().drops.item;
|
||||
|
||||
@@ -279,6 +279,11 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
//no
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMine(Item item){
|
||||
return type.toMine.contains(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBuildPower(Tile tile){
|
||||
return type.buildPower;
|
||||
|
||||
Reference in New Issue
Block a user