Solved Area Effects Cloud

Discussion in 'Plugin Development' started by SteveStage, Apr 17, 2021.

  1. Offline

    SteveStage

    When I'm try to create effect cloud when arrow hits ground or entity - nothing changes...

    Creating cloud:
    PHP:
    public void perkCurseShot()
        {
            
    Location l;
            
    Block b this.event.getHitBlock();
            if(
    == null)
            {
                
    this.event.getHitEntity().getLocation();
            }
            else
            {
                
    double y this.event.getHitBlock().getY();
                
    = new Location(this.victim.getWorld(), this.event.getHitBlock().getX(), ythis.event.getHitBlock().getZ());
                switch(
    this.event.getHitBlockFace())
                {
                    case 
    UP:
                        
    l.setY(y+1.0);
                        break;
                    case 
    DOWN:
                        
    l.setY(y-1.0);
                        break;
                    default:
                        break;
                }
            }
            
    AreaEffectCloud c = (AreaEffectCloud)this.victim.getWorld().spawnEntity(lEntityType.AREA_EFFECT_CLOUD);
            
    c.clearCustomEffects();
            
    c.setColor(Color.GRAY);
            
    c.setRadius(5.0F);
            
    c.setDuration(200);
            
    c.addCustomEffect(new PotionEffect(PotionEffectType.WEAKNESS20*42), true);
        }
    ProjectileHitEvent:
    PHP:
    @EventHandler
        
    public void onProjectileHit(ProjectileHitEvent phev)
        {
            if((
    phev.getHitEntity() instanceof LivingEntity) == false) return;
            
    LivingEntity v = (LivingEntity)phev.getHitEntity();
            
    Entity e phev.getEntity();
            if(
    e.getType() == EntityType.ARROW && this.skpl.getArrow() == e)
            {
                switch(
    this.skill_id)
                {
                    case 
    SKILL_ARCHER:
                        
    this.skpl.setEvent(phev);
                        
    this.skpl.setVictim(v);
                        switch(
    this.skpl.getCurrentSelectPerk())
                        {
                            case 
    ARCHER_PERK_FA:
                                
    this.skpl.perkUse(ARCHER_PERK_FAplug);
                                break;
                            case 
    ARCHER_PERK_V:
                                
    this.skpl.perkUse(ARCHER_PERK_Vplug);
                                break;
                            case 
    ARCHER_PERK_CS:
                                
    this.skpl.perkUse(ARCHER_PERK_CSplug);
                                break;
                        }
                        break;
                }
            }
        }
     
  2. Offline

    davidclue

    I don't see you calling your method to create the cloud anywhere.
     
  3. Offline

    SteveStage

    PHP:
    this.skpl.perkUse(ARCHER_PERK_CSplug);
    PHP:
    public void perkUse(int needperkPlugin plug)
        {
            switch(
    this.skillid)
            {
                case 
    SKILL_SWORDSMAN:
                    switch(
    needperk)
                    {
                        case -
    1:
                            break;
                        case 
    0:
                            ((
    Swordsman)this.skillclass).perkSwordCombo();
                            break;
                        case 
    1:
                            ((
    Swordsman)this.skillclass).perkKickSlash();
                            break;
                        case 
    2:
                            ((
    Swordsman)this.skillclass).perkBlockBreaker(this.chance);
                            break;
                        case 
    3:
                            ((
    Swordsman)this.skillclass).perkDangerWound();
                            break;
                        case 
    4:
                            ((
    Swordsman)this.skillclass).perkRageOfBlade();
                            break;
                    }
                    break;
                case 
    SKILL_ARCHER:
                    switch(
    needperk)
                    {
                        case 
    0:
                            ((
    Archer)this.skillclass).perkFireArrow();
                            break;
                        case 
    1:
                            ((
    Archer)this.skillclass).perkVenom();
                            break;
                        case 
    2:
                            ((
    Archer)this.skillclass).perkRapidFire();
                            break;
                        case 
    3:
                            ((
    Archer)this.skillclass).perkCurseShot();
                            break;
                        case 
    4:
                            ((
    Archer)this.skillclass).perkRangeMaster();
                            break;
                    }
                    break;
            }
        }
     
  4. Offline

    davidclue

    Use some logs to determine if the code even runs and then tell me what point the code reaches, put a log up at this line:
    Code:
    Bukkit.getLogger().info("reached here with location: "+l.getBlockX()+" "+l.getBlockY()+" "+l.getBlockZ());
    AreaEffectCloud c = (AreaEffectCloud)this.victim.getWorld().spawnEntity(l, EntityType.AREA_EFFECT_CLOUD);
    Check if the location checks out.
     
  5. Offline

    SteveStage

    Solved, wrong check (valid: if hit block null - hit entity is target, else block is target). Just be careful about ProjectileHitEvent.
     

Share This Page