Replacing Entity (creature)

Discussion in 'Plugin Development' started by tobiyas, Apr 27, 2012.

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

    tobiyas

    Hello to everyone.

    I'm looking for a possibility to replace a LivingEntity (Creatute, not Player).
    The Problem that I ran into is that some plugins save their Entities in containers (regardless which ones). The only usefull replacements that I know is the CreatureSpawnEvent or doing using a Scheduler task searching for new Creatures.

    The Problem is, if another plugin calls the Method world.spawnCreatute(...), it will return for first methode null and second methode will just remove it.

    Is there any Posibility to Override a creature without destroying it's link to other plugins?

    My actual code ist:

    Code:
    @EventHandler(priority = EventPriority.LOWEST)
    public void replaceDragon(CreatureSpawnEvent event){
        if(event.isCancelled()) return;
     
        if(!event.getEntityType().equals(EntityType.ENDER_DRAGON)) return;
        if(!plugin.interactConfig().getconfig_replaceAllDragons()) return;
     
        int id = event.getEntity().getEntityId();
         
        //checks if the Dragon is spawned by this plugin
        if(plugin.getContainer().containsID(id)) return;
     
        //checks if the entity is not of (EntityEnderDragon)
        if(plugin.interactBridgeController().isSpecialDragon(event.getEntity())) return;
     
        spawnLimitedEnderDragon(event.getLocation());
        event.setCancelled(true);
    }
    
    If you need more code to see:
    github link

    Nevermind.
    Got it done using reflections :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page