Help using Remote Entities

Discussion in 'Plugin Development' started by SuperOriginal, Feb 21, 2014.

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

    SuperOriginal

    So I made RemoteEntity spawn with a 1/15 chance of hitting a regular mob. How can I make it so it only makes a sound when it is a special entity? I've tried to use hashmaps, here's my code:

    Code:java
    1. @EventHandler
    2. public void onDamage(EntityDamageByEntityEvent e){
    3. if(e.getDamager() instanceof Player && e.getEntity() instanceof Pig){
    4. int r = gen.nextInt(15);
    5.  
    6. Pig pig = (Pig) e.getEntity();
    7. LivingEntity li = (LivingEntity) e.getDamager();
    8. if(special.get(pig) == null){
    9. special.put(pig, false);
    10. }
    11. if(special.get(pig) !=null){
    12. if(special.get(pig).equals(true)){
    13. pig.getWorld().playSound(pig.getLocation(), Sound.GHAST_SCREAM, 3F, 7F);
    14. return;
    15. }
    16.  
    17. }
    18. if(r < 15){
    19.  
    20.  
    21.  
    22. EntityManager manager = RemoteEntities.createManager(this);
    23. RemoteEntity entity = manager.createEntity(RemoteEntityType.Pig, pig.getLocation(), false);
    24. //entity.getMind().addTargetingDesire(new DesireFindAttackingTarget(50F, true, false), 5);
    25. //entity.getMind().addMovementDesire(new DesireMoveAndMeleeAttack(Player.class, true), 4);
    26. entity.getMind().addMovementDesire(new DesireKillTarget(li), 4);
    27. special.put((Entity) entity, true);
    28.  
    29. pig.setHealth(5.0);
    30. pig.remove();

    Sorry if I worded it a bit confusing but essentially I want it to only make ghast noises when it is a special mob but right now it doesn't do anything. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page