@Override
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition mop) {
if (mop == null)
return itemstack;
Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
int meta = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
if (player.canPlayerEdit(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, itemstack)) {
ItemStack stack = getPickedBlock(itemstack);
if (stack != null) {
if (mop.sideHit == 0)
--mop.blockY;
if (mop.sideHit == 1)
++mop.blockY;
if (mop.sideHit == 2)
--mop.blockZ;
if (mop.sideHit == 3)
++mop.blockZ;
if (mop.sideHit == 4)
--mop.blockX;
if (mop.sideHit == 5)
++mop.blockX;
if (block.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
if (!world.isRemote) {
world.setBlock(mop.blockX, mop.blockY, mop.blockZ, ((ItemBlock) stack.getItem()).field_150939_a, stack.getItemDamage(), 1 | 2);
block.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, itemstack);
NBTTagCompound tileCmp = getStackTileEntity(itemstack);
if (tileCmp != null && !tileCmp.hasNoTags()) {
TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
tile1.xCoord = mop.blockX;
tile1.yCoord = mop.blockY;
tile1.zCoord = mop.blockZ;
world.setTileEntity(mop.blockX, mop.blockY, mop.blockZ, tile1);
}
} else player.swingItem();
clearPickedBlock(itemstack);
for (int i = 0; i < 8; i++) {
float x = (float) (mop.blockX + Math.random());
float y = (float) (mop.blockY + Math.random()) + 0.65F;
float z = (float) (mop.blockZ + Math.random());
ThaumicTinkerer.tcProxy.burst(world, x, y, z, 0.2F);
}
world.playSoundAtEntity(player, "thaumcraft:wand", 0.5F, 1F);
}
} else if (!blacklist.contains(block) && !ThaumcraftApi.portableHoleBlackList.contains(block) && block != null && block.getBlockHardness(world, mop.blockX, mop.blockY, mop.blockZ) != -1F && wand.consumeAllVis(itemstack, player, getCost(tile), true, false)) {
if (!world.isRemote) {
world.removeTileEntity(mop.blockX, mop.blockY, mop.blockZ);
world.setBlock(mop.blockX, mop.blockY, mop.blockZ, Blocks.air, 0, 1 | 2);
storePickedBlock(itemstack, block, (short) meta, tile);
}