Posted July 4, 20169 yr So I'm trying to make a 3x3 pickaxe. Everything is fine, but whenever I look up or down, it doesn't exactly perform the function I'm asking for. It mines sideways when ever I look up or down. Here's my onBlockDestroyed code: @Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) { int x = pos.getX(): int y = pos.getY(); Int z = pos.getZ(); if(playerIn.getHorizontalFacing() == EnumFacing.UP || playerIn.getHorizontalFacing() == EnumFacing.DOWN) { if(worldIn.getBlockState(new BlockPos(x + 1, y, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y, z), true); if(worldIn.getBlockState(new BlockPos(x + 1, y, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y, z + 1), true); if(worldIn.getBlockState(new BlockPos(x + 1, y, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y, z - 1), true); if(worldIn.getBlockState(new BlockPos(x, y, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y, z + 1), true); if(worldIn.getBlockState(new BlockPos(x, y, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y, z - 1), true); if(worldIn.getBlockState(new BlockPos(x - 1, y, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y, z), true); if(worldIn.getBlockState(new BlockPos(x - 1, y, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y, z + 1), true); if(worldIn.getBlockState(new BlockPos(x - 1, y, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y, z - 1), true); } else if(playerIn.getHorizontalFacing() == EnumFacing.EAST || playerIn.getHorizontalFacing() == EnumFacing.WEST) { if(worldIn.getBlockState(new BlockPos(x, y + 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y + 1, z), true); if(worldIn.getBlockState(new BlockPos(x, y + 1, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y + 1, z - 1), true); if(worldIn.getBlockState(new BlockPos(x, y + 1, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y + 1, z + 1), true); if(worldIn.getBlockState(new BlockPos(x, y, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y, z - 1), true); if(worldIn.getBlockState(new BlockPos(x, y, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y, z + 1), true); if(worldIn.getBlockState(new BlockPos(x, y - 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y - 1, z), true); if(worldIn.getBlockState(new BlockPos(x, y - 1, z - 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y - 1, z - 1), true); if(worldIn.getBlockState(new BlockPos(x, y - 1, z + 1)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y - 1, z + 1), true); } else if(playerIn.getHorizontalFacing() == EnumFacing. NORTH || playerIn.getHorizontalFacing() == EnumFacing.SOUTH) { if(worldIn.getBlockState(new BlockPos(x, y + 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y + 1, z), true); if(worldIn.getBlockState(new BlockPos(x + 1, y + 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y + 1, z), true); if(worldIn.getBlockState(new BlockPos(x - 1, y + 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y + 1, z), true); if(worldIn.getBlockState(new BlockPos(x + 1, y, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y, z - 1), true); if(worldIn.getBlockState(new BlockPos(x - 1, y, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y, z), true); if(worldIn.getBlockState(new BlockPos(x, y - 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x, y - 1, z), true); if(worldIn.getBlockState(new BlockPos(x + 1, y - 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x + 1, y - 1, z), true); if(worldIn.getBlockState(new BlockPos(x - 1, y - 1, z)) == Blocks.stone.getDefaultState()) worldIn.destroyBlock(new BlockPos(x - 1, y - 1, z), true); } return true; }
July 4, 20169 yr I wouldn't use where the player is looking at, as you can be looking up and still hit a block from the sides. Get where he hit the block mined, that side is better to use.
July 4, 20169 yr Author I wouldn't use where the player is looking at, as you can be looking up and still hit a block from the sides. Get where he hit the block mined, that side is better to use. Ah yes. How would i go about doing that? Would i get the block the player is looking at?
July 4, 20169 yr I see you want it for a 3x3 pick. This is what I did for my hammer in a mod I'm working on. Inside the "onBlockDestroyed" get the MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, (EntityPlayer) playerIn, flag); And then you can switch "movingobjectposition.sideHit"
July 4, 20169 yr Author I see you want it for a 3x3 pick. This is what I did for my hammer in a mod I'm working on. Inside the "onBlockDestroyed" get the MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, (EntityPlayer) playerIn, flag); And then you can switch "movingobjectposition.sideHit" Thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.