@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;
  }
Exemplo n.º 2
0
  /**
   * 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;
  }