Getting MobType and related actions

Discussion in 'Plugin Development' started by Infernus, Mar 3, 2011.

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

    Infernus

    As I've seen in my code I had to add a 'Suppress Warning':

    @SuppressWarnings("deprecation")

    So I am actually looking for a way to not use this SuppressWarning, code:

    PHP:
        @SuppressWarnings("deprecation")
        public 
    void onCreatureSpawn(CreatureSpawnEvent event)
        {
            if(
    event.getMobType().getName().equalsIgnoreCase("creeper"))
                
    event.setCancelled(true);
        }
    Yeah, guess what, it's my creeperpreventer! ;)


    And my second question is, how do I change for example the health of a spawning creature? Would be nice to know as I have a plan for an upcoming mod :)

    Thanks for your support!
     
  2. Offline

    MadMonkeyCo

    Funny, I discover another post by you.
    You can change the health of any LivingEntity using the setHealth and getHealth functions (or is it called methods in Java?).
    Try changing the @SuppressWarning to @Override
     
  3. Offline

    niko

    yes, "methods" in Java.

    the @Override annotation tells Java that you want this method to take priority over the Listener class which you are extending. similarly, the @SuppressWarning tells your compiler, "please don't show me warnings about this section."
     
  4. Offline

    Cogito

    The problem is that mobType is deprecated - you should use creatureType instead
     
  5. Offline

    Infernus

    Thanks! I will soon take a look into this.
     
Thread Status:
Not open for further replies.

Share This Page