Controlling mob movement

Discussion in 'Plugin Development' started by niko, Aug 24, 2011.

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

    niko

    Hi all!

    I'm trying to gain control over a specific mob (by entityId). Ideally I'd like to give it a Location and have it move there.

    I'm reading in bergerkiller's post that I'd need to extend net.minecraft.server.[entity] and I think I could do it with the EntityLiving class to avoid recreating each creature type. I've never worked with this package before, though.

    Anyone have an example/know of a plugin that can move specific mobs? Any help is appreciated.
     
  2. Offline

    bergerkiller

    @niko of course I come and take a look. :)

    And no, this is not the case unfortunately. For example:
    As you see, you are basically rewriting everything.

    If you really need all entities, do it like this:
    - Make a fake Entity class that is a placeholder for all functions you wish to use/replace
    - Extend all entity types and call the same method of the fake entity class for your custom type.

    For example:
    Code:
    public class CustomCow extends EntityCow {
        //some init stuff here
    
        public void move(double motX, double motY, double motZ) {
            FakeEntity.move(motX, motY, motZ, this);
        }
     
    }
    FakeEntity:
    Code:
    public class FakeEntity {
        public static void move(double motX, double motY, double motZ, Entity e) {
            //do move operations on e
            //replace 'this.' by 'e.'
    
        }
     
    }
    But, since you only need movement functions, you would be better off setting and getting the entity velocity. It is quite a hassle to work like this, since you need to spawn and despawn your custom entity as you work with it.
     
  3. Offline

    niko

    @bergerkiller thanks for the reply, sorry it's taking me so long to get back. life attacks :)

    I /think/ I understand what you're saying. even if I don't, you helped me to realize I need to create a way to actually select the specific mob I want to operate on, so that's good! I'll try to update here on my progress with this as it happens.

    thanks again for your advice!
     
Thread Status:
Not open for further replies.

Share This Page