Make the drill not use energy in creative

Closes #595
This commit is contained in:
Ellpeck 2017-01-28 17:50:34 +01:00
parent 55e98e5f14
commit e3cd20d171

View file

@ -174,9 +174,11 @@ public class ItemDrill extends ItemEnergy{
@Override @Override
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){ public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){
int use = this.getEnergyUsePerBlock(stack); int use = this.getEnergyUsePerBlock(stack);
if(!(entity2 instanceof EntityPlayer) || !((EntityPlayer)entity2).capabilities.isCreativeMode){
if(this.getEnergyStored(stack) >= use){ if(this.getEnergyStored(stack) >= use){
this.extractEnergyInternal(stack, use, false); this.extractEnergyInternal(stack, use, false);
} }
}
return true; return true;
} }
@ -454,7 +456,9 @@ public class ItemDrill extends ItemEnergy{
float hardness = block.getBlockHardness(state, world, pos); float hardness = block.getBlockHardness(state, world, pos);
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getStrVsBlock(stack, world.getBlockState(pos)) > 1.0F); boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getStrVsBlock(stack, world.getBlockState(pos)) > 1.0F);
if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){ if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){
if(!player.capabilities.isCreativeMode){
this.extractEnergyInternal(stack, use, false); this.extractEnergyInternal(stack, use, false);
}
//Break the Block //Break the Block
return WorldUtil.playerHarvestBlock(stack, world, player, pos); return WorldUtil.playerHarvestBlock(stack, world, player, pos);
} }