mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +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,39 +211,54 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
||||||
zRange = radius;
|
zRange = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int xPos = x-xRange; xPos <= x+xRange; xPos++){
|
//Break Middle Block first
|
||||||
for(int yPos = y-yRange; yPos <= y+yRange; yPos++){
|
int use = this.getEnergyUsePerBlock(stack);
|
||||||
for(int zPos = z-zRange; zPos <= z+zRange; zPos++){
|
if(this.getEnergyStored(stack) >= use){
|
||||||
int use = this.getEnergyUsePerBlock(stack);
|
this.tryHarvestBlock(world, x, y, z, false, stack, player, use);
|
||||||
if(this.getEnergyStored(stack) >= use){
|
}
|
||||||
Block block = world.getBlock(xPos, yPos, zPos);
|
else return;
|
||||||
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))){
|
|
||||||
this.extractEnergy(stack, use, false);
|
|
||||||
|
|
||||||
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
|
//Break Blocks around
|
||||||
if(block.removedByPlayer(world, player, xPos, yPos, zPos, true)){
|
if(radius > 0){
|
||||||
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
|
for(int xPos = x-xRange; xPos <= x+xRange; xPos++){
|
||||||
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
for(int yPos = y-yRange; yPos <= y+yRange; yPos++){
|
||||||
|
for(int zPos = z-zRange; zPos <= z+zRange; zPos++){
|
||||||
if(!EnchantmentHelper.getSilkTouchModifier(player)){
|
if(!(x == xPos && y == yPos && z == zPos)){
|
||||||
block.dropXpOnBlockBreak(world, xPos, yPos, zPos, block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)));
|
if(this.getEnergyStored(stack) >= use){
|
||||||
}
|
this.tryHarvestBlock(world, xPos, yPos, zPos, true, stack, player, use);
|
||||||
|
|
||||||
if(!(xPos == x && yPos == y && zPos == z)){
|
|
||||||
world.playAuxSFX(2001, xPos, yPos, zPos, Block.getIdFromBlock(block)+(meta << 12));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 >= 0.0F && (!isExtra || (this.canHarvestBlock(block, stack) && !block.hasTileEntity(meta)))){
|
||||||
|
this.extractEnergy(stack, use, false);
|
||||||
|
|
||||||
|
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
|
||||||
|
if(block.removedByPlayer(world, player, xPos, yPos, zPos, true)){
|
||||||
|
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
|
||||||
|
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||||
|
|
||||||
|
if(!EnchantmentHelper.getSilkTouchModifier(player)){
|
||||||
|
block.dropXpOnBlockBreak(world, xPos, yPos, zPos, block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isExtra){
|
||||||
|
world.playAuxSFX(2001, xPos, yPos, zPos, Block.getIdFromBlock(block)+(meta << 12));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(){
|
public String getName(){
|
||||||
return "itemDrill";
|
return "itemDrill";
|
||||||
|
|
Loading…
Reference in a new issue