mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Drill now doesn't break TileEntities with 3x3 or 5x5 Upgrade, also breaks middle block first, then blocks around that to prevent bugs when the Drill is almost out of fuel
This commit is contained in:
parent
5077fed341
commit
1b36e7c19a
1 changed files with 38 additions and 23 deletions
|
@ -211,15 +211,36 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
zRange = radius;
|
||||
}
|
||||
|
||||
//Break Middle Block first
|
||||
int use = this.getEnergyUsePerBlock(stack);
|
||||
if(this.getEnergyStored(stack) >= use){
|
||||
this.tryHarvestBlock(world, x, y, z, false, stack, player, use);
|
||||
}
|
||||
else return;
|
||||
|
||||
//Break Blocks around
|
||||
if(radius > 0){
|
||||
for(int xPos = x-xRange; xPos <= x+xRange; xPos++){
|
||||
for(int yPos = y-yRange; yPos <= y+yRange; yPos++){
|
||||
for(int zPos = z-zRange; zPos <= z+zRange; zPos++){
|
||||
int use = this.getEnergyUsePerBlock(stack);
|
||||
if(!(x == xPos && y == yPos && z == zPos)){
|
||||
if(this.getEnergyStored(stack) >= use){
|
||||
this.tryHarvestBlock(world, xPos, yPos, zPos, true, stack, player, use);
|
||||
}
|
||||
else return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tryHarvestBlock(World world, int xPos, int yPos, int zPos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
float hardness = block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
if(hardness > -1.0F && ((x == xPos && y == yPos && z == zPos) || this.canHarvestBlock(block, stack))){
|
||||
if(hardness >= 0.0F && (!isExtra || (this.canHarvestBlock(block, stack) && !block.hasTileEntity(meta)))){
|
||||
this.extractEnergy(stack, use, false);
|
||||
|
||||
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
|
||||
|
@ -231,18 +252,12 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
block.dropXpOnBlockBreak(world, xPos, yPos, zPos, block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)));
|
||||
}
|
||||
|
||||
if(!(xPos == x && yPos == y && zPos == z)){
|
||||
if(isExtra){
|
||||
world.playAuxSFX(2001, xPos, yPos, zPos, Block.getIdFromBlock(block)+(meta << 12));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
|
|
Loading…
Reference in a new issue