Updated Advanced Drill behaviour. Closes #1463
This commit is contained in:
parent
d272111d16
commit
a69fa60436
1 changed files with 14 additions and 6 deletions
|
@ -28,6 +28,7 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -67,24 +68,31 @@ public class ItemAdvancedDrill extends ItemDrill {
|
||||||
for (int i = -1; i < 2; i++) {
|
for (int i = -1; i < 2; i++) {
|
||||||
for (int j = -1; j < 2; j++) {
|
for (int j = -1; j < 2; j++) {
|
||||||
BlockPos newPos = pos.add(i, j, 0);
|
BlockPos newPos = pos.add(i, j, 0);
|
||||||
|
if (worldIn.getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||||
targetBlocks.add(newPos);
|
targetBlocks.add(newPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (enumfacing == EnumFacing.EAST || enumfacing == EnumFacing.WEST) {
|
} else if (enumfacing == EnumFacing.EAST || enumfacing == EnumFacing.WEST) {
|
||||||
for (int i = -1; i < 2; i++) {
|
for (int i = -1; i < 2; i++) {
|
||||||
for (int j = -1; j < 2; j++) {
|
for (int j = -1; j < 2; j++) {
|
||||||
BlockPos newPos = pos.add(0, j, i);
|
BlockPos newPos = pos.add(0, j, i);
|
||||||
|
if (worldIn.getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||||
targetBlocks.add(newPos);
|
targetBlocks.add(newPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) {
|
} else if (enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) {
|
||||||
for (int i = -1; i < 2; i++) {
|
for (int i = -1; i < 2; i++) {
|
||||||
for (int j = -1; j < 2; j++) {
|
for (int j = -1; j < 2; j++) {
|
||||||
BlockPos newPos = pos.add(j, 0, i);
|
BlockPos newPos = pos.add(j, 0, i);
|
||||||
|
if (worldIn.getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||||
targetBlocks.add(newPos);
|
targetBlocks.add(newPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return targetBlocks;
|
return targetBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +105,7 @@ public class ItemAdvancedDrill extends ItemDrill {
|
||||||
if (blockHardness == -1.0F) {
|
if (blockHardness == -1.0F) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((blockHardness / originalHardness) > 20.0F) {
|
if ((originalHardness / blockHardness) > 10.0F) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NonNullList<ItemStack> stuff = NonNullList.create();
|
NonNullList<ItemStack> stuff = NonNullList.create();
|
||||||
|
@ -122,16 +130,16 @@ public class ItemAdvancedDrill extends ItemDrill {
|
||||||
float originalHardness = blockIn.getPlayerRelativeBlockHardness(playerIn, worldIn, pos);
|
float originalHardness = blockIn.getPlayerRelativeBlockHardness(playerIn, worldIn, pos);
|
||||||
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
|
for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, entityLiving)) {
|
||||||
breakBlock(additionalPos, worldIn, playerIn, pos, originalHardness);
|
breakBlock(additionalPos, worldIn, playerIn, pos, originalHardness);
|
||||||
PoweredItem.useEnergy(cost, 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);
|
return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemPickaxe
|
// ItemPickaxe
|
||||||
@Override
|
@Override
|
||||||
public boolean canHarvestBlock(IBlockState blockIn) {
|
public boolean canHarvestBlock(IBlockState blockIn) {
|
||||||
return Items.DIAMOND_PICKAXE.canHarvestBlock(blockIn) || Items.DIAMOND_SHOVEL.canHarvestBlock(blockIn);
|
return (Items.DIAMOND_PICKAXE.canHarvestBlock(blockIn) || Items.DIAMOND_SHOVEL.canHarvestBlock(blockIn)) && !Items.DIAMOND_AXE.canHarvestBlock(blockIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item
|
// Item
|
||||||
|
|
Loading…
Reference in a new issue