Solved Preventing wither boss from moving(NMS)

Discussion in 'Plugin Help/Development/Requests' started by HeyAwesomePeople, Jun 28, 2015.

Thread Status:
Not open for further replies.
  1. Hello all!

    I am creating a plugin in which a Wither must be stationary, but still attack nearby players and move its heads. Right now I just have the basic NMS class to spawn the Wither, but I don't know where to go from here to actually prevent it from moving.

    http://hastebin.com/ciyaloliza.axapta


    Now I have looked at the decompiled code, and I found the m() method for EntityWither. This method seems to control movement, but the only way to stop it from moving(as far as I know), is to remove "super.m()". But this also stops the wither from attacking players and it prevents heads from moving. How would I edit exactly was "super.m()" does so I can stop it from moving?

    Also, I am using 1.8.3.

    Thanks,
    HeyAwesomePeople
     
  2. Offline

    ArmyArmy

  3. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
     
  4. e() is the method for 1.7.10. In 1.8.3, I have found its m().

    If I just override m() and leave it blank, the wither doesn't move. At all. It's heads don't move. It doesn't shoot players.
     
  5. Offline

    ArmyArmy

    Well, first of, your constructor should look only like this:
    Code:
    public DTCWither(World world) {
    super(world); // No need to setup goalSelector, it's already done in super class
    }
    
    And for the movement you can try
    Code:
    @Override
    public void m(){
    super.m();
    this.motX = this.motY = this.motZ = 0;
    }
    
    Not sure about it, but it's worth a try.
     
  6. @ArmyArmy Now it doesn't move unless it gets hit. It stays still and shoots players, but as soon as it gets hit it starts to move again.
     
  7. Offline

    ArmyArmy

    By guess is this is caused by PathfinderGoalHurtByTarget in targetSelector, which means you would need to clear it.
    Code:
    public DTCWither(World world) {
    super(world)
        try{
           Field targetFieldB = PathfinderGoalSelector.class.getDeclaredField("b"); // The lists are [URL='https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/PathfinderGoalSelector.java']here[/URL].
           Field targetFieldC = PathfinderGoalSelector.class.getDeclaredField("b"); // We acces them via reflection and clear them.
           List targetListB = (List) targetFieldB.get(targetSelector);
           List targetListC = (List) targetFieldC.get(targetSelector);
           targetListB.clear();
           targetListC.clear();
          this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 0, false, false, bq)); //This is from the EntityWither class
         }catch(NoSuchFieldException e){
           e.printStackTrace();
         } catch (IllegalArgumentException e) {
           e.printStackTrace();
         } catch (IllegalAccessException e) {
           e.printStackTrace();
         }
    }
    
     
  8. @ArmyArmy I get an illegal access exception with that, but I did get a soluation. Someone on the Spigot forums told me to do this:

    Code:
    @Override
        public void move(double d0, double d1, double d2){
            return;
        }
    It worked... But I did learn new stuff trying to figure this out. Thanks for everything guys!
     
Thread Status:
Not open for further replies.

Share This Page