I am trying to make a Hammer in 1.12.2. I know, the regular, typical Hammer, once again in another mod.
Overall I got the 3x3 Working, it breaks. Here is the code:
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
EnumFacing facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
AxisAlignedBB grid = (new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), (pos.getX() + 3),
(pos.getY() + 3), (pos.getZ() + 3)));
for (int x = (int) grid.minX; x < (int) grid.maxX; x++) {
for (int y = (int) grid.minY; y < (int) grid.maxY; y++) {
for (int z = (int) grid.minZ; z < (int) grid.maxZ; z++) {
BlockPos newpos = new BlockPos(x, y, z);
if (worldIn.getBlockState(newpos).getBlock() != Blocks.AIR) {
worldIn.destroyBlock(newpos, true);
}
}
}
}
return EnumActionResult.PASS;
} else if (!player.isSneaking()) {
worldIn.destroyBlock(pos, true);
return EnumActionResult.PASS;
}
return EnumActionResult.FAIL;
}
However I have been messing around with it and I did not get it to work in the sense that I wanted, which is starting from the middle and breaking top,down, left and right.
I did try the top and down method. pos.up() pos.down() etc but that did not work when I did the whole facing checks. So it would be different for when I looked east, or when I looked north. I did fix that, but when I looked up or down, it did not.
I guess it was because it checked player Horizontal Plane for Direction..
Anyway Results Below:
Its starting from bottom left to top right.
I have been trying to get it into the middle block and it does it around