1.15.2 InteractEvent Pressure Plate X Location is off.

Discussion in 'Spigot Plugin Development' started by Ehrenmann, Feb 21, 2020.

  1. So this is my code, as you can see i am trying to compare the block under a player when he presses the pressure plate with an already defined checkpoint. The checkpoint location is right and the block is located at X:37. But when i print the output of e.getClickedBlock().getLocation(); X is 38 and i dont know why ( its the same when i press it from other angles.
    Code (Java):
        public void onInteract(PlayerInteractEvent e) {
            if (ecm.getBoolValueFromCFG("Settings.EnableSuperSecret") == true && ssm.getBooleanFromCFG("Settings.JnRServer") == true) {
                if(e.getAction() == Action.PHYSICAL) {
                    Location loc = e.getClickedBlock().getLocation();
                    loc.setY(loc.getY() - 1);
                    Bukkit.broadcastMessage("§cClicked Block Location: " + String.valueOf(loc));
                    Bukkit.broadcastMessage("§aCheckpoint Block Location: " + String.valueOf(ssm.getCheckpoint(ssm.getPlayersCurrentCheckpoint(e.getPlayer().getUniqueId().toString()) + 1)));
                    if (loc.getBlock().getType().equals(Material.EMERALD_BLOCK)) {
                        if(matchLocations(loc, ssm.getCheckpoint(ssm.getPlayersCurrentCheckpoint(e.getPlayer().getUniqueId().toString()) + 1)) == true) {
                            ssm.updatePlayersCurrentCheckpoint(e.getPlayer().getUniqueId().toString(), ssm.getPlayersCurrentCheckpoint(e.getPlayer().getUniqueId().toString()) + 1);
                            XSound.playSoundFromString(e.getPlayer(), XSound.ENTITY_PLAYER_LEVELUP.parseSound().toString());
                            String msg = smu.getMessageFromConfig("Messages.NewCheckpoint");
                            msg = msg.replace("[id]", String.valueOf(ssm.getPlayersCurrentCheckpoint(e.getPlayer().getUniqueId().toString())));
                            e.getPlayer().sendMessage(smu.getMessageFromConfig("Messages.Prefix") + msg);
    • Funny Funny x 1
  2. *bump* please can anyone help me?
  3. Could you show us the matchlocations() method?
    Perhaps something goes wrong when rounding or comparing the locations.
  4. Hey, thanks for replying but i already checked that. As you can see i print the result of "Location loc = e.getClickedBlock().getLocation();" instantly and it shows the wrong x coordinate.

    It should show the location of the block under the pressure plate but depending on the angle (i didnt figure that out yet) it will be x + 1 or - 1 but not the location it should be at