1.8.8 Inconsistent compilation problem with Maven

Discussion in 'Spigot Plugin Development' started by amazinng, Feb 17, 2020.

  1. Hi,

    I'm trying to make a plugin that launches you in a parabolic motion when touching a slime block. I found a helper method to do this and was able to import it with no problem. However, when trying to utilise the method, Maven decides to throw the error "An unknown compilation problem occurred".

    Current code:
    Code (Text):
    @EventHandler
    public void onUseLaunchPadEvent(PlayerMoveEvent event)
    {
        Player player = event.getPlayer();

        if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.SLIME_BLOCK)
        {
            Vector from = player.getLocation().toVector();
            Vector to = new Location(player.getWorld(), 34, 4, 0, -90, 4).toVector();

            player.setVelocity(calculateVelocity(from, to, 6));
        }
    }

    public Vector calculateVelocity(Vector from, Vector to, int heightGain)
    {
        // Gravity of a potion
        double gravity = 0.115;
        // Block locations
        int endGain = to.getBlockY() - from.getBlockY();
        double horizDist = Math.sqrt(distanceSquared(from, to));
        // Height gain
        int gain = heightGain;
        double maxGain = gain > (endGain + gain) ? gain : (endGain + gain);
        // Solve quadratic equation for velocity
        double a = -horizDist * horizDist / (4 * maxGain);
        double b = horizDist;
        double c = -endGain;
        double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a);
        // Vertical velocity
        double vy = Math.sqrt(maxGain * gravity);
        // Horizontal velocity
        double vh = vy / slope;
        // Calculate horizontal direction
        int dx = to.getBlockX() - from.getBlockX();
        int dz = to.getBlockZ() - from.getBlockZ();
        double mag = Math.sqrt(dx * dx + dz * dz);
        double dirx = dx / mag;
        double dirz = dz / mag;
        // Horizontal velocity components
        double vx = vh * dirx;
        double vz = vh * dirz;
        return new Vector(vx, vy, vz);
    }

    private double distanceSquared(Vector from, Vector to)
    {
        double dx = to.getBlockX() - from.getBlockX();
        double dz = to.getBlockZ() - from.getBlockZ();
        return dx * dx + dz * dz;
    }
    Error occurs when I try and specify 'to' as the second parameter, but the error does not occur if I try and specify 'from'. For example:

    This errors:
    Code (Text):
    player.setVelocity(calculateVelocity(from, to, 6));
    This does not error:
    Code (Text):
    player.setVelocity(calculateVelocity(from, from, 6));
    I have no idea what could be causing this. Any help is appreciated, thanks.
     
  2. Maybe try to compile such code with something else. If that fails, you know it's a java error.
     
  3. What does your pom.xml look like?
     
    • Like Like x 1
  4. IDE doesn't throw any errors and the code looks fine to me.

    https://pastebin.com/raw/VUTHHmQS
     
  5. is Vector directly imported? can we see the rest of the class? have you tried rebuilding the project in your IDE? this does not mean start from scratch

    matching server versions? matching java versions?
     
  6. Thanks for the reply. Here's my code:
    https://pastebin.com/raw/0RBuaqkq

    I haven't run into any troubles when using the other vector 'from' as the second argument which is super weird and why I'm so confused about why this isn't compiling. Not very helpful that Maven doesn't provide any information either

    EDIT: ignore statics, they weren't there when I was testing
     
    #6 amazinng, Feb 18, 2020
    Last edited: Feb 18, 2020
  7. bump, would appreciate if anyone could help
     
  8. you answered two of the questions