From e3cd20d171fcd1156f436dd2727f1f4c0673ff3e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 28 Jan 2017 17:50:34 +0100 Subject: [PATCH] Make the drill not use energy in creative Closes #595 --- .../ellpeck/actuallyadditions/mod/items/ItemDrill.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 194354776..9e0ebba86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -174,8 +174,10 @@ public class ItemDrill extends ItemEnergy{ @Override public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){ int use = this.getEnergyUsePerBlock(stack); - if(this.getEnergyStored(stack) >= use){ - this.extractEnergyInternal(stack, use, false); + if(!(entity2 instanceof EntityPlayer) || !((EntityPlayer)entity2).capabilities.isCreativeMode){ + if(this.getEnergyStored(stack) >= use){ + this.extractEnergyInternal(stack, use, false); + } } return true; } @@ -454,7 +456,9 @@ public class ItemDrill extends ItemEnergy{ 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); if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){ - this.extractEnergyInternal(stack, use, false); + if(!player.capabilities.isCreativeMode){ + this.extractEnergyInternal(stack, use, false); + } //Break the Block return WorldUtil.playerHarvestBlock(stack, world, player, pos); }