Register Entitys Bukkit?

Discussion in 'Plugin Development' started by OstlerDev, Aug 4, 2012.

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

    OstlerDev

    Hey so I am helping update a plugin that was created in 1.0, and I ran into a bit of a snag. Because I taught myself java, I dont know how to use everything in it and I cannot figure out how to hook into CB's classes, the prevoius plugin author used this:
    Code:
    public void registerDeadMinesEntities() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
        Class[] parameterTypes = { Class.class, String.class, Integer.TYPE };
        Method method = EntityTypes.class.getDeclaredMethod("a", parameterTypes);
        method.setAccessible(true);
     
        method.invoke(new EntityTypes(), new Object[] { DeadMinesZombie.class, "Zombie", Integer.valueOf(54) });
        method.invoke(new EntityTypes(), new Object[] { DeadMinesGiant.class, "Giant", Integer.valueOf(53) });
        method.invoke(new EntityTypes(), new Object[] { DeadMinesPigZombie.class, "PigZombie", Integer.valueOf(57) });
      }
    Could anyone point me in the right direction here? It would be greatly appreciated!

    Thanks
    -OstlerDev

    Does anybody know how to do this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  2. Offline

    Sagacious_Zed Bukkit Docs

    Any off Bukkit API use will be to your own ability.
     
  3. Offline

    mushroomhostage

    Try looking in the mc-dev repository for net.minecraft.server.EntityTypes, and find the "a" method it is calling to get an idea of what it is doing. Looking at 1.2.5 https://github.com/mushroomhostage/mc-dev/blob/master/net/minecraft/server/EntityTypes.java
    Code:
    
        private static void a(Class oclass, String s, int i) {
            b.put(s, oclass);
            c.put(oclass, s);
            d.put(Integer.valueOf(i), oclass);
            e.put(oclass, Integer.valueOf(i));
            f.put(s, Integer.valueOf(i));
        }
    
    so it's adding a new entity type to EntityTypes internal mappings. Looks like this code should still work in 1.2.5, but not sure about 1.3.1, may have to find a new way to do this. Usually the obfuscated names change between major releases. But if you have trouble deducing the right method from the obfuscated code, try using the latest Minecraft Coder Pack, it can helpfully deobfuscate Minecraft for you (although you'll have to obfuscate it back for CraftBukkit).
     
  4. Offline

    OstlerDev

    Ok, thanks so much guys, I know it was an odd request, but hopefully I can get the plugin back up and running.
     
Thread Status:
Not open for further replies.

Share This Page