Improve power handling with drill and chainsaw
This commit is contained in:
parent
c8886bbd9b
commit
6e1b608113
2 changed files with 13 additions and 8 deletions
|
@ -79,7 +79,6 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
|
|||
return Items.DIAMOND_AXE.canHarvestBlock(blockIn);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void breakBlock(BlockPos pos, ItemStack stack, World world, EntityLivingBase entityLiving, BlockPos oldPos) {
|
||||
if (oldPos == pos) {
|
||||
|
@ -95,6 +94,10 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
|
|||
if(!(entityLiving instanceof EntityPlayer)){
|
||||
return;
|
||||
}
|
||||
if(!PoweredItem.canUseEnergy(cost, stack)){
|
||||
return;
|
||||
}
|
||||
PoweredItem.useEnergy(cost, stack);
|
||||
blockState.getBlock().harvestBlock(world, (EntityPlayer) entityLiving, pos, blockState, world.getTileEntity(pos), stack);
|
||||
world.setBlockToAir(pos);
|
||||
world.removeTileEntity(pos);
|
||||
|
|
|
@ -49,7 +49,7 @@ import java.util.Set;
|
|||
public class ItemAdvancedDrill extends ItemDrill {
|
||||
|
||||
public ItemAdvancedDrill() {
|
||||
super(ToolMaterial.DIAMOND, "techreborn.advancedDrill", ConfigTechReborn.AdvancedDrillCharge, 4.0F, 10F);
|
||||
super(ToolMaterial.DIAMOND, "techreborn.advancedDrill", ConfigTechReborn.AdvancedDrillCharge, 2.0F, 10F);
|
||||
this.cost = 250;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,10 @@ public class ItemAdvancedDrill extends ItemDrill {
|
|||
if(blockState.getMaterial() == Material.AIR){
|
||||
return;
|
||||
}
|
||||
if(!PoweredItem.canUseEnergy(cost, drill)){
|
||||
return;
|
||||
}
|
||||
PoweredItem.useEnergy(cost, drill);
|
||||
blockState.getBlock().harvestBlock(world, playerIn, pos, blockState, world.getTileEntity(pos), drill);
|
||||
world.setBlockToAir(pos);
|
||||
world.removeTileEntity(pos);
|
||||
|
@ -118,12 +122,10 @@ public class ItemAdvancedDrill extends ItemDrill {
|
|||
// ItemDrill
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) {
|
||||
if (PoweredItem.canUseEnergy(cost, stack)) {
|
||||
EntityPlayer playerIn = (EntityPlayer) entityLiving;
|
||||
float originalHardness = blockIn.getPlayerRelativeBlockHardness(playerIn, worldIn, pos);
|
||||
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
|
||||
breakBlock(additionalPos, worldIn, playerIn, pos, originalHardness, stack);
|
||||
}
|
||||
EntityPlayer playerIn = (EntityPlayer) entityLiving;
|
||||
float originalHardness = blockIn.getPlayerRelativeBlockHardness(playerIn, worldIn, pos);
|
||||
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
|
||||
breakBlock(additionalPos, worldIn, playerIn, pos, originalHardness, stack);
|
||||
}
|
||||
// Use energy only once no matter how many blocks were broken, e.g. energy used per application of a drill
|
||||
return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving);
|
||||
|
|
Loading…
Reference in a new issue