Solved Armor Stand NoClip

Discussion in 'Spigot Plugin Development' started by Tygo_Craft, Mar 29, 2020.

  1. Hey all,
    I'm currently working on a plugin that involves moving Armor Stands by setting their velocity. However, I need my Armor Stands to be able to move through blocks. I've tried editing the NMS using the following method:
    Code (Text):

    public void setNoClip(org.bukkit.entity.Entity target, boolean noclip) {
        net.minecraft.server.v1_12_R1.Entity ent = ((CraftEntity)target).getHandle();
        ent.noclip = noclip;
    }
     
    I really don't want to need to teleport the Armor Stands, so I hope that someone can help me out. : )
     
    • Useful Useful x 1
  2. what exactly is the problem? You can just use Entity#move(EnumMoveType, Vec3D) to move your entity
     
  3. The problem is that I can't get it to move through blocks, the stand just stops as soon as it collides into a block. I'm currently spawning the Armor Stand like I'd spawn a regular stand, after which I use the method above like so:
    Code (Text):
     EntityUtil.setNoClip(armorstand, true);
    After that I'm trying to move it using
    Code (Text):
     armorstand.setVelocity(vector.normalize().multiply(speed));
    It's my first time trying to edit the NMS though, so I probably made some stupid mistake. Don't kill me : )
     
  4. Works as it should for me. I have this code:
    Code (Java):
    entity = player.getWorld().spawn(player.getLocation(), Pig.class);
    ((CraftEntity) entity).getHandle().noclip = true;
    entity.setVelocity(new Vector(1, 0, 0));
     
    • Like Like x 2
  5. Yeah, got it. Thanks for your help sir : )