NMS Collide Villager Glitch

Discussion in 'Plugin Development' started by macboinc, Aug 26, 2014.

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

    macboinc

    Hey guys!
    Well before you read this thread I want you guys to watch this video so I don't have to explain it in words:

    Ok, as you saw in the video, when you collide into a villager, it glitches out.
    Here is my NMS code:
    Code:
        @Override
        protected void aC() {
        super.aC();
        this.getAttributeInstance(GenericAttributes.d).setValue(0.0D);
        this.getAttributeInstance(GenericAttributes.a).setValue(1.0D);
        this.getAttributeInstance(GenericAttributes.c).setValue(0.0D); 
        }
     
        @Override
        public void move(double d0, double d1, double d2) { }
    IS there any fix/alternative way to make it not pushable without it glitching out?

    Thanks,
    -Mac :)
     
  2. Offline

    fireblast709

    macboinc perhaps try out clientside entities (i.e. by sending a spawn packet)
     
  3. Offline

    macboinc

    I don't know how to use packets AT ALL.. Could you send me a link on how I can learn it?
     
  4. Offline

    fireblast709

    macboinc
    • Resources section (I bet there is something regarding packets there, including libs)
    • http://wiki.vg/Protocol - information regarding the protocol
     
  5. Offline

    macboinc

    Can you send a small example of using packets?
     
  6. Offline

    SmooshCakez

    A small example, though this obviously isn't the packet you want to use:
    Code:java
    1. PacketPlayInChat packet = new PacketPlayInChat();
    2. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);

    You probably want to use PacketPlayOutNamedEntitySpawn, but it isn't as simple as just instantiating it.
     
  7. Offline

    macboinc

    Makes more sense... Thanks! (No, I'm Not being sarcastic)
     
  8. Offline

    macboinc

    That will make it stop moving, not making it not pushable.

    fireblast709 SmooshCakez
    Are there any NMS ways of doing this without using packets?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  9. macboinc so you want it to be non-pushable?
     
  10. No, he wants it to be pushable but without glitching all the way to it's start point.
     
  11. Offline

    macboinc

  12. macboinc maybe try set it's velocity and multiply it by 0 then add slowness 255 to it. I use it for my custom kit pvp. Works fine for me. Non-pushable

    My code:

    Code:java
    1. public void ourEntities() {
    2. World w = Bukkit.getWorld("world");
    3. Location loc1 = new Location(w, -156.5, 157, -28.4);
    4.  
    5. Villager v = (Villager) loc1.getWorld().spawnEntity(loc1,
    6. EntityType.VILLAGER);
    7. v.setCustomName(ChatColor.AQUA + "Kits");
    8. v.setCustomNameVisible(true);
    9. v.setVelocity(v.getVelocity().multiply(0));
    10. v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2555555, 255));
     
  13. Offline

    SmooshCakez

    AFAIK, no. Packets to spawn entities aren't very hard to use, though. Let's say I have an EntityHorse named foo.

    Code:java
    1. PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(foo);
    2. EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    3. nmsPlayer.playerConnection.sendPacket(packet);
     
  14. Offline

    macboinc

    lol foo
     
  15. Oh, sorry, I didn't undestand the video then xD
     
  16. Offline

    TheGamblingMan

    SmooshCakez So if i spawn an entity like that players can't collide with them?
     
  17. Offline

    SantaClawz69

    Hey macboinc, I've made a plugin very similar to yours but I used an API called RemoteEntities. It's a much, much, MUCH easier way to code NMS than raw. If you use RemoteEntites I can help you.
     
    ChipDev likes this.
  18. Offline

    macboinc

    You think I would use that before doing this, RemoteEntities is outdated, I will use
    http://dev.bukkit.org/bukkit-plugins/entityapi/ when it comes out.
     
  19. Offline

    Dablakbandit

    [quote uid=90892535 name="macboinc" post=2774463]You think I would use that before doing this, RemoteEntities is outdated, I will use
    http://dev.bukkit.org/bukkit-plugins/entityapi/ when it comes out.[/quote]

    I have a plugin for Villagers being unable to be push (among other things) at <Edit by Moderator: Redacted not allowed paid resource url>

    Note: not approved by bukkit staff
     
    Last edited by a moderator: Dec 6, 2016
  20. Offline

    SantaClawz69

    macboinc it's not outdated at all. It's still compatible with all the versions out today. I just made a Plugin recently with it
     
  21. Offline

    macboinc

    Well, I tried, and it is outdated :/

    Which method or event should I put this in?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  22. Offline

    SmooshCakez

    Whenever you want the entity to spawn (probably PlayerJoinEvent).
     
  23. Offline

    macboinc

    Not working

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  24. Offline

    fireblast709

    Describe your method, tell us what happened and what you expect it to do.
     
  25. Offline

    macboinc

    fireblast709 SmooshCakez
    Not working code (Still glitches whilst pushing):
    Code:java
    1. @EventHandler
    2. public void onCreateureSpawn(CreatureSpawnEvent e) {
    3. if (e.getEntity() instanceof CustomVillager) {
    4. CustomVillager v = (CustomVillager) e.getEntity();
    5. Player p = (Player) e.getEntity();
    6. // Yes I saw your signature
    7. v.setProfession(5);
    8. PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(v);
    9. EntityPlayer nmsPlayer = ((CraftPlayer) p).getHandle();
    10. nmsPlayer.playerConnection.sendPacket(packet);
    11. Bukkit.getServer().broadcastMessage("Spawned a villager");
    12. }
    13. }
     
  26. Offline

    fireblast709

    macboinc You still seem to spawn a serverside one. Instead of spawning a serverside one, try just the packet there.
     
  27. Offline

    macboinc

    Kind of confused, how can I do that?
     
  28. Offline

    fireblast709

    macboinc Where do you spawn your custom entity? Replace the world.addEntity call with sending a packet.
     
  29. Offline

    macboinc

    I summon my entity via spawn egg, or /summon Villager
     
Thread Status:
Not open for further replies.

Share This Page