Entity collision (scoreboards)

Discussion in 'Plugin Development' started by WolfMage1, Mar 14, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    WolfMage1

    I'm trying to disable player collision (which was introduced with the pvp update in 1.9) and so far I've been successful, but something it is doing that I don't want it to is it has stopped players colliding with mobs as well. I only want to disable player collision.

    Code:
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event)
        {
            Player player = event.getPlayer();
            if (player.hasPermission("nocollide.nocollide"))
            {
                Scoreboard scoreboard = player.getScoreboard();
                if(scoreboard == null)
                {
                    scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
                }
                Team team = plugin.hasTeam(scoreboard, "noCollide") ? scoreboard.getTeam("noCollide")
                        : scoreboard.registerNewTeam("noCollide");
                team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
                if (!team.hasEntry(player.getName()))
                {
                    team.addEntry(player.getName());
                }
                player.setScoreboard(scoreboard);
            }
        }
    I don't think it will help with the issue but here's the code if anyone is curious.

    And yes I am aware you can disable it in the spigot.yml but I want to only disable it per world.

    I've also tried LivingEntity#setCollidable

    @Zombie_Striker @timtower Any thoughts?
     
    Last edited: Mar 14, 2017
  2. Offline

    Zombie_Striker

    @WolfMage1
    Well, there is no way to filter out which entities can be collided with. However, the description for setCollidable says that it does not work both ways, so you may be able to get similar results by making sure all other entities are collidable.
     
  3. Offline

    WolfMage1

    So far I have tried enabling collision with CreatureSpawnEvent, enabling collision for entities near the player, and enabling collision for the player and entity themselves

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 15, 2017
Thread Status:
Not open for further replies.

Share This Page