@Override public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { BlockPos blockpos = world.getStrongholdPos("Stronghold", new BlockPos(player)); if (blockpos != null) { EntityEnderEye entityendereye = new EntityEnderEye(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5); entityendereye.moveTowards(blockpos); world.spawnEntityInWorld(entityendereye); world.playAuxSFXAtEntity((EntityPlayer) null, 1002, new BlockPos(player), 0); } } return true; }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, false); if (var4 != null && var4.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldIn.getBlockState(var4.func_178782_a()).getBlock() == Blocks.end_portal_frame) { return itemStackIn; } else { if (!worldIn.isRemote) { BlockPos var5 = worldIn.func_180499_a("Stronghold", new BlockPos(playerIn)); if (var5 != null) { EntityEnderEye var6 = new EntityEnderEye(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ); var6.func_180465_a(var5); worldIn.spawnEntityInWorld(var6); worldIn.playSoundAtEntity( playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); worldIn.playAuxSFXAtEntity((EntityPlayer) null, 1002, new BlockPos(playerIn), 0); if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); } } return itemStackIn; } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick( ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false); if (movingobjectposition != null && movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = par2World.getBlockId( movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); if (i == Block.endPortalFrame.blockID) { return par1ItemStack; } } if (!par2World.isRemote) { ChunkPosition chunkposition = par2World.findClosestStructure( "Stronghold", (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ); if (chunkposition != null) { EntityEnderEye entityendereye = new EntityEnderEye( par2World, par3EntityPlayer.posX, par3EntityPlayer.posY + 1.62D - (double) par3EntityPlayer.yOffset, par3EntityPlayer.posZ); entityendereye.moveTowards( (double) chunkposition.x, chunkposition.y, (double) chunkposition.z); par2World.spawnEntityInWorld(entityendereye); par2World.playSoundAtEntity( par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); par2World.playAuxSFXAtEntity( (EntityPlayer) null, 1002, (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ, 0); if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } } } return par1ItemStack; }