Search in sources :

Example 6 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project Skree by Skelril.

the class PatientXInstance method runAttack.

public void runAttack(PatientXAttack attackCase) {
    Optional<Zombie> optBoss = getBoss();
    if (!optBoss.isPresent()) {
        return;
    }
    Zombie boss = optBoss.get();
    Collection<Player> contained = getPlayers(PARTICIPANT);
    if (contained.isEmpty()) {
        return;
    }
    switch(attackCase) {
        case MUSICAL_CHAIRS:
            sendAttackBroadcast("Let's play musical chairs!", AttackSeverity.NORMAL);
            for (Player player : contained) {
                do {
                    player.setLocation(getRandomDest());
                } while (player.getLocation().getPosition().distanceSquared(boss.getLocation().getPosition()) <= 5 * 5);
                // TODO convert to Sponge
                if (((EntityZombie) boss).canEntityBeSeen(tf(player))) {
                    player.offer(Keys.HEALTH, Probability.getRandom(player.get(Keys.MAX_HEALTH).get()));
                    sendAttackBroadcast("Don't worry, I have a medical degree...", AttackSeverity.NORMAL);
                    sendAttackBroadcast("...or was that a certificate of insanity?", AttackSeverity.NORMAL);
                }
            }
            attackDur = System.currentTimeMillis() + 2000;
            break;
        case SMASHING_HIT:
            for (Player player : contained) {
                final double old = player.get(Keys.HEALTH).get();
                player.offer(Keys.HEALTH, 3D);
                Task.builder().execute(() -> {
                    if (!player.isRemoved() || !contains(player)) {
                        return;
                    }
                    player.offer(Keys.HEALTH, old * .75);
                }).delay(2, TimeUnit.SECONDS).submit(SkreePlugin.inst());
            }
            attackDur = System.currentTimeMillis() + 3000;
            sendAttackBroadcast("This special attack will be a \"smashing hit\"!", AttackSeverity.NORMAL);
            break;
        case BOMB_PERFORMANCE:
            double tntQuantity = Math.max(2, difficulty / 2.4);
            for (Player player : contained) {
                for (double i = Probability.getRangedRandom(tntQuantity, Math.pow(2, Math.min(9, tntQuantity))); i > 0; i--) {
                    PrimedTNT explosive = (PrimedTNT) getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, player.getLocation().getPosition());
                    explosive.setVelocity(new Vector3d(random.nextDouble() * 1 - .5, random.nextDouble() * .8 + .2, random.nextDouble() * 1 - .5));
                    explosive.offer(Keys.FUSE_DURATION, 20 * 4);
                    getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
                }
            }
            attackDur = System.currentTimeMillis() + 5000;
            sendAttackBroadcast("Your performance is really going to \"bomb\"!", AttackSeverity.NORMAL);
            break;
        case WITHER_AWAY:
            PotionEffect witherEffect = PotionEffect.of(PotionEffectTypes.WITHER, 1, 20 * 15);
            for (Player player : contained) {
                List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
                potionEffects.add(witherEffect);
                player.offer(Keys.POTION_EFFECTS, potionEffects);
            }
            attackDur = System.currentTimeMillis() + 15750;
            sendAttackBroadcast("Like a candle I hope you don't \"whither\" and die!", AttackSeverity.NORMAL);
            break;
        case SPLASH_TO_IT:
            for (Player player : contained) {
                for (int i = Probability.getRandom(6) + 2; i > 0; --i) {
                    throwSlashPotion(player.getLocation());
                }
            }
            attackDur = System.currentTimeMillis() + 2000;
            sendAttackBroadcast("Splash to it!", AttackSeverity.NORMAL);
            break;
        case COLD_FEET:
            PotionEffect slowEffect = PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, 20 * 60);
            for (Player player : contained) {
                List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
                potionEffects.add(slowEffect);
                player.offer(Keys.POTION_EFFECTS, potionEffects);
            }
            attackDur = System.currentTimeMillis() + 20000;
            sendAttackBroadcast("What's the matter, got cold feet?", AttackSeverity.NORMAL);
            break;
        case IM_JUST_BATTY:
            for (Player player : contained) {
                Cause cause = Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build();
                player.simulateChat(Text.of("I love Patient X!"), cause);
                Entity bat = getRegion().getExtent().createEntity(EntityTypes.BAT, player.getLocation().getPosition());
                getRegion().getExtent().spawnEntity(bat, cause);
                bat.getPassengers().add(player);
            }
            attackDur = System.currentTimeMillis() + 20000;
            sendAttackBroadcast("Awe, I love you too!", AttackSeverity.NORMAL);
            sendAttackBroadcast("But only cause I'm a little batty...", AttackSeverity.NORMAL);
            break;
        case RADIATION:
            ParticleEffect radiationEffect = ParticleEffect.builder().type(ParticleTypes.FLAME).quantity(1).build();
            Task.builder().execute(() -> {
                for (int i = config.radiationTimes; i > 0; i--) {
                    Task.builder().execute(() -> {
                        if (isBossSpawned()) {
                            for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
                                for (int e = 0; e < 30; ++e) {
                                    getRegion().getExtent().spawnParticles(radiationEffect, player.getLocation().getPosition().add(5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0), 5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0), 5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0)));
                                }
                                if (LightLevelUtil.getMaxLightLevel(player.getLocation()).get() >= config.radiationLightLevel) {
                                    player.damage(difficulty * config.radiationMultiplier, EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
                                }
                            }
                        }
                    }).delay(i * 500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
                }
            }).delay(3, TimeUnit.SECONDS).submit(SkreePlugin.inst());
            attackDur = System.currentTimeMillis() + (config.radiationTimes * 500);
            sendAttackBroadcast("Ahhh not the radiation treatment!", AttackSeverity.NORMAL);
            break;
        case SNOWBALL_FIGHT:
            final int burst = Probability.getRangedRandom(10, 20);
            Task.builder().execute(() -> {
                for (int i = burst; i > 0; i--) {
                    Task.builder().execute(() -> {
                        if (boss != null) {
                            freezeBlocks(true);
                        }
                    }).delay(i * 500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
                }
            }).delay(7, TimeUnit.SECONDS).submit(SkreePlugin.inst());
            attackDur = System.currentTimeMillis() + 7000 + (500 * burst);
            sendAttackBroadcast("Let's have a snow ball fight!", AttackSeverity.NORMAL);
            break;
    }
    lastAttack = attackCase;
}
Also used : PrimedTNT(org.spongepowered.api.entity.explosive.PrimedTNT) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) EntityZombie(net.minecraft.entity.monster.EntityZombie) Zombie(org.spongepowered.api.entity.living.monster.Zombie) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) ParticleEffect(org.spongepowered.api.effect.particle.ParticleEffect) EntityZombie(net.minecraft.entity.monster.EntityZombie) Vector3d(com.flowpowered.math.vector.Vector3d) SpawnCause(org.spongepowered.api.event.cause.entity.spawn.SpawnCause) Cause(org.spongepowered.api.event.cause.Cause)

Example 7 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project Skree by Skelril.

the class ShnugglesPrimeInstance method runAttack.

public void runAttack(ShnugglesPrimeAttack attackCase) {
    Optional<Giant> optBoss = getBoss();
    if (!optBoss.isPresent()) {
        return;
    }
    Giant boss = optBoss.get();
    double bossHealth = getHealth(boss);
    double maxBossHealth = getMaxHealth(boss);
    double delay = 15000;
    if (lastAttackTime != 0 && System.currentTimeMillis() - lastAttackTime <= delay) {
        return;
    }
    Collection<Player> contained = getPlayers(PARTICIPANT);
    if (contained.isEmpty()) {
        return;
    }
    // AI-ish system
    if ((attackCase == ShnugglesPrimeAttack.EVERLASTING || attackCase == ShnugglesPrimeAttack.MINION_LEECH) && bossHealth > maxBossHealth * .9) {
        attackCase = Probability.getChance(2) ? ShnugglesPrimeAttack.DARK_POTIONS : ShnugglesPrimeAttack.CORRUPTION;
    }
    for (Player player : contained) {
        if (player.get(Keys.HEALTH).get() < 4) {
            attackCase = ShnugglesPrimeAttack.CORRUPTION;
            break;
        }
    }
    Collection<Zombie> zombies = getContained(Zombie.class);
    if (zombies.size() > 200) {
        attackCase = ShnugglesPrimeAttack.BASK_IN_MY_GLORY;
    }
    if (bossHealth < maxBossHealth * .4 && Probability.getChance(5)) {
        if (zombies.size() < 100 && bossHealth > 200) {
            attackCase = ShnugglesPrimeAttack.EVERLASTING;
        } else {
            attackCase = ShnugglesPrimeAttack.MINION_LEECH;
        }
    }
    if ((attackCase == ShnugglesPrimeAttack.BLINDNESS || attackCase == ShnugglesPrimeAttack.FIRE) && bossHealth < maxBossHealth * .15) {
        runRandomAttack();
        return;
    }
    switch(attackCase) {
        case WRATH:
            sendAttackBroadcast("Taste my wrath!", AttackSeverity.NORMAL);
            for (Player player : contained) {
                player.offer(Keys.VELOCITY, new Vector3d(random.nextDouble() * 3 - 1.5, random.nextDouble() * 1 + .5, random.nextDouble() * 3 - 1.5));
                player.offer(Keys.FIRE_TICKS, 20 * 3);
            }
            break;
        case CORRUPTION:
            sendAttackBroadcast("Embrace my corruption!", AttackSeverity.NORMAL);
            PotionEffect witherEffect = PotionEffect.of(PotionEffectTypes.WITHER, 1, 20 * 3);
            for (Player player : contained) {
                List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
                potionEffects.add(witherEffect);
                player.offer(Keys.POTION_EFFECTS, potionEffects);
            }
            break;
        case BLINDNESS:
            sendAttackBroadcast("Are you BLIND? Mwhahahaha!", AttackSeverity.NORMAL);
            PotionEffect blindnessEffect = PotionEffect.of(PotionEffectTypes.BLINDNESS, 0, 20 * 4);
            for (Player player : contained) {
                List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
                potionEffects.add(blindnessEffect);
                player.offer(Keys.POTION_EFFECTS, potionEffects);
            }
            break;
        case TANGO_TIME:
            sendAttackBroadcast("Tango time!", AttackSeverity.ULTIMATE);
            activeAttacks.add(ShnugglesPrimeAttack.TANGO_TIME);
            Task.builder().delay(7, TimeUnit.SECONDS).execute(() -> {
                if (!isBossSpawned()) {
                    return;
                }
                for (Player player : getPlayers(PARTICIPANT)) {
                    // TODO Convert to Sponge
                    if (((EntityGiantZombie) boss).canEntityBeSeen(tf(player))) {
                        player.sendMessage(Text.of(TextColors.YELLOW, "Come closer..."));
                        player.setLocation(boss.getLocation());
                        EntityDamageSource source = EntityDamageSource.builder().entity(boss).type(DamageTypes.ATTACK).build();
                        player.damage(100, source, Cause.source(boss).build());
                        player.offer(Keys.VELOCITY, new Vector3d(random.nextDouble() * 1.7 - 1.5, random.nextDouble() * 2, random.nextDouble() * 1.7 - 1.5));
                    } else {
                        player.sendMessage(Text.of(TextColors.YELLOW, "Fine... No tango this time..."));
                    }
                }
                sendAttackBroadcast("Now wasn't that fun?", AttackSeverity.INFO);
                activeAttacks.remove(ShnugglesPrimeAttack.TANGO_TIME);
            }).submit(SkreePlugin.inst());
            break;
        case EVERLASTING:
            if (!damageHeals) {
                activeAttacks.add(ShnugglesPrimeAttack.EVERLASTING);
                sendAttackBroadcast("I am everlasting!", AttackSeverity.NORMAL);
                damageHeals = true;
                Task.builder().delay(12, TimeUnit.SECONDS).execute(() -> {
                    if (damageHeals) {
                        damageHeals = false;
                        if (!isBossSpawned()) {
                            return;
                        }
                        sendAttackBroadcast("Thank you for your assistance.", AttackSeverity.INFO);
                    }
                    activeAttacks.remove(ShnugglesPrimeAttack.EVERLASTING);
                }).submit(SkreePlugin.inst());
                break;
            }
            runRandomAttack();
            return;
        case FIRE:
            sendAttackBroadcast("Fire is your friend...", AttackSeverity.NORMAL);
            for (Player player : contained) {
                player.offer(Keys.FIRE_TICKS, 20 * 5);
            }
            break;
        case BASK_IN_MY_GLORY:
            if (!damageHeals) {
                sendAttackBroadcast("Bask in my glory!", AttackSeverity.ULTIMATE);
                activeAttacks.add(ShnugglesPrimeAttack.BASK_IN_MY_GLORY);
                Task.builder().delay(7, TimeUnit.SECONDS).execute(() -> {
                    if (!isBossSpawned()) {
                        return;
                    }
                    boolean baskInGlory = false;
                    for (Player player : getContained(Player.class)) {
                        // TODO Convert to Sponge
                        if (((EntityGiantZombie) boss).canEntityBeSeen(tf(player))) {
                            player.sendMessage(Text.of(TextColors.DARK_RED, "You!"));
                            baskInGlory = true;
                        }
                    }
                    // Attack
                    if (baskInGlory) {
                        damageHeals = true;
                        spawnPts.stream().filter(pt -> Probability.getChance(12)).forEach(pt -> {
                            Explosion explosion = Explosion.builder().shouldDamageEntities(true).location(pt).radius(10).build();
                            getRegion().getExtent().triggerExplosion(explosion, Cause.source(SkreePlugin.container()).owner(boss).build());
                        });
                        // Schedule Reset
                        Task.builder().delay(500, TimeUnit.MILLISECONDS).execute(() -> {
                            damageHeals = false;
                        }).submit(SkreePlugin.inst());
                        return;
                    }
                    // Notify if avoided
                    sendAttackBroadcast("Gah... Afraid are you friends?", AttackSeverity.INFO);
                    activeAttacks.remove(ShnugglesPrimeAttack.BASK_IN_MY_GLORY);
                }).submit(SkreePlugin.inst());
                break;
            }
            runRandomAttack();
            break;
        case DARK_POTIONS:
            sendAttackBroadcast("Unleash the inner darkness!", AttackSeverity.NORMAL);
            PotionEffect instantDamageEffect = PotionEffect.of(PotionEffectTypes.INSTANT_DAMAGE, 0, 1);
            for (Living entity : getContained(Zombie.class)) {
                if (!Probability.getChance(5)) {
                    continue;
                }
                entity.offer(Keys.HEALTH, 0D);
                Location targetLoc = entity.getLocation();
                Entity potion = getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, targetLoc.getPosition());
                potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(instantDamageEffect));
                getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
            }
            return;
        case MINION_LEECH:
            sendAttackBroadcast("My minions our time is now!", AttackSeverity.ULTIMATE);
            activeAttacks.add(ShnugglesPrimeAttack.MINION_LEECH);
            IntegratedRunnable minionEater = new IntegratedRunnable() {

                @Override
                public boolean run(int times) {
                    if (!isBossSpawned()) {
                        return true;
                    }
                    for (Living entity : getContained(Living.class)) {
                        // TODO convert to Sponge
                        if (entity instanceof Giant || !Probability.getChance(5) || !((EntityGiantZombie) boss).canEntityBeSeen((EntityLivingBase) entity)) {
                            continue;
                        }
                        double realDamage = entity.get(Keys.HEALTH).get();
                        // TODO convert to Sponge
                        if (entity instanceof Zombie && ((EntityZombie) entity).isChild()) {
                            entity.offer(Keys.HEALTH, 0D);
                        } else {
                            DamageSource source = DamageSource.builder().type(DamageTypes.ATTACK).build();
                            entity.damage(realDamage, source, Cause.source(boss).build());
                        }
                        toHeal += Math.min(1, realDamage / 3);
                    }
                    if (new TimeFilter(-1, 2).matchesFilter(times + 1)) {
                        getPlayerMessageChannel(SPECTATOR).send(Text.of(TextColors.DARK_AQUA, "The boss has drawn in: " + (int) toHeal + " health."));
                    }
                    return true;
                }

                @Override
                public void end() {
                    if (!isBossSpawned()) {
                        return;
                    }
                    heal(boss, toHeal);
                    toHeal = 0;
                    sendAttackBroadcast("Thank you my minions!", AttackSeverity.INFO);
                    printBossHealth();
                    activeAttacks.remove(ShnugglesPrimeAttack.MINION_LEECH);
                }
            };
            TimedRunnable<IntegratedRunnable> minonEatingTask = new TimedRunnable<>(minionEater, 20);
            Task minionEatingTaskExecutor = Task.builder().interval(500, TimeUnit.MILLISECONDS).execute(minonEatingTask).submit(SkreePlugin.inst());
            minonEatingTask.setTask(minionEatingTaskExecutor);
            break;
    }
    lastAttackTime = System.currentTimeMillis();
    lastAttack = attackCase;
}
Also used : Boss(com.skelril.openboss.Boss) BossManager(com.skelril.openboss.BossManager) SpawnCause(org.spongepowered.api.event.cause.entity.spawn.SpawnCause) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) TimedRunnable(com.skelril.nitro.time.TimedRunnable) PotionEffectTypes(org.spongepowered.api.effect.potion.PotionEffectTypes) SkreePlugin(com.skelril.skree.SkreePlugin) TextColor(org.spongepowered.api.text.format.TextColor) TimeFilter(com.skelril.nitro.time.TimeFilter) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail) Living(org.spongepowered.api.entity.living.Living) ForgeTransformer.tf(com.skelril.nitro.transformer.ForgeTransformer.tf) Location(org.spongepowered.api.world.Location) BlockTypes(org.spongepowered.api.block.BlockTypes) DamageTypes(org.spongepowered.api.event.cause.entity.damage.DamageTypes) CustomItemTypes(com.skelril.skree.content.registry.item.CustomItemTypes) Cause(org.spongepowered.api.event.cause.Cause) Explosion(org.spongepowered.api.world.explosion.Explosion) World(org.spongepowered.api.world.World) BlockType(org.spongepowered.api.block.BlockType) Player(org.spongepowered.api.entity.living.player.Player) Giant(org.spongepowered.api.entity.living.monster.Giant) EntityHealthPrinter(com.skelril.nitro.entity.EntityHealthPrinter) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) EntityHealthUtil(com.skelril.nitro.entity.EntityHealthUtil) LegacyZoneBase(com.skelril.skree.content.zone.LegacyZoneBase) java.util(java.util) Keys(org.spongepowered.api.data.key.Keys) EntityZombie(net.minecraft.entity.monster.EntityZombie) PARTICIPANT(com.skelril.skree.service.internal.zone.PlayerClassifier.PARTICIPANT) Vector3d(com.flowpowered.math.vector.Vector3d) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) Lists(com.google.common.collect.Lists) EntityTypes(org.spongepowered.api.entity.EntityTypes) Text(org.spongepowered.api.text.Text) ZoneRegion(com.skelril.skree.service.internal.zone.ZoneRegion) Task(org.spongepowered.api.scheduler.Task) ZoneStatus(com.skelril.skree.service.internal.zone.ZoneStatus) Probability(com.skelril.nitro.probability.Probability) Zombie(org.spongepowered.api.entity.living.monster.Zombie) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) PlaceHolderText(com.skelril.nitro.text.PlaceHolderText) Zone(com.skelril.skree.service.internal.zone.Zone) Entity(org.spongepowered.api.entity.Entity) SPECTATOR(com.skelril.skree.service.internal.zone.PlayerClassifier.SPECTATOR) TimeUnit(java.util.concurrent.TimeUnit) SpawnTypes(org.spongepowered.api.event.cause.entity.spawn.SpawnTypes) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vector3i(com.flowpowered.math.vector.Vector3i) CombinedText(com.skelril.nitro.text.CombinedText) EntityGiantZombie(net.minecraft.entity.monster.EntityGiantZombie) Clause(com.skelril.nitro.Clause) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) Task(org.spongepowered.api.scheduler.Task) Explosion(org.spongepowered.api.world.explosion.Explosion) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) EntityZombie(net.minecraft.entity.monster.EntityZombie) Zombie(org.spongepowered.api.entity.living.monster.Zombie) EntityGiantZombie(net.minecraft.entity.monster.EntityGiantZombie) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) Living(org.spongepowered.api.entity.living.Living) TimeFilter(com.skelril.nitro.time.TimeFilter) EntityGiantZombie(net.minecraft.entity.monster.EntityGiantZombie) TimedRunnable(com.skelril.nitro.time.TimedRunnable) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) Vector3d(com.flowpowered.math.vector.Vector3d) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) Giant(org.spongepowered.api.entity.living.monster.Giant) Location(org.spongepowered.api.world.Location)

Example 8 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project EnderIO by SleepyTrousers.

the class TileKillerJoe method processTasks.

// TODO 1.11 check that broken tools can be removed by automation
@Override
protected boolean processTasks(boolean redstoneCheck) {
    updateArmSwingProgress();
    if (Prep.isValid(getWeapon()) != hasSword) {
        hasSword = Prep.isValid(getWeapon());
        forceUpdatePlayers();
    }
    if (tanksDirty && shouldDoWorkThisTick(20)) {
        PacketHandler.sendToAllAround(new PacketNutrientTank(this), this);
        tanksDirty = false;
    }
    if (!redstoneCheck) {
        return false;
    }
    if (tank.getFluidAmount() < getActivationAmount()) {
        return false;
    }
    if (!hasSword) {
        return false;
    }
    if (doMending()) {
        hooverXP();
        if (!needsMending()) {
            endMending();
        }
    }
    getAttackera().onUpdate();
    Attackera atackera = getAttackera();
    if (atackera.getTicksSinceLastSwing() < atackera.getCooldownPeriod()) {
        return false;
    }
    List<EntityLivingBase> entsInBounds = world.getEntitiesWithinAABB(EntityLivingBase.class, getKillBounds());
    for (EntityLivingBase ent : entsInBounds) {
        if (!ent.isDead && ent.deathTime <= 0 && !ent.isEntityInvulnerable(DamageSource.GENERIC) && ent.hurtResistantTime == 0) {
            if (ent instanceof EntityPlayer && ((EntityPlayer) ent).capabilities.disableDamage) {
                // Ignore players in creative, can't damage them;
                continue;
            }
            boolean togglePvp = false;
            if (ent instanceof EntityPlayer && !FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()) {
                if (KillerJoeConfig.killerPvPoffDisablesSwing.get()) {
                    continue;
                } else if (KillerJoeConfig.killerPvPoffIsIgnored.get()) {
                    togglePvp = true;
                }
            }
            if (KillerJoeConfig.killerJoeMustSee.get() && !canJoeSee(ent)) {
                continue;
            }
            if (!PermissionAPI.hasPermission(getOwner().getAsGameProfile(), BlockKillerJoe.permissionAttacking, new TargetContext(atackera, ent))) {
                continue;
            }
            if (ent instanceof EntityZombie) {
                // TODO: tag the entity instead (see Powered Spawner)
                ZombieCache.cache.add(ent.getUniqueID());
            }
            try {
                if (togglePvp) {
                    FMLCommonHandler.instance().getMinecraftServerInstance().setAllowPvp(true);
                }
                atackera.attackTargetEntityWithCurrentItem(ent);
            } finally {
                if (togglePvp) {
                    FMLCommonHandler.instance().getMinecraftServerInstance().setAllowPvp(false);
                }
            }
            atackera.resetCooldown();
            useNutrient();
            swingWeapon();
            return false;
        }
    }
    return false;
}
Also used : PacketNutrientTank(crazypants.enderio.machines.machine.generator.zombie.PacketNutrientTank) EntityZombie(net.minecraft.entity.monster.EntityZombie) TargetContext(net.minecraftforge.server.permission.context.TargetContext) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 9 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project Galacticraft by micdoodle8.

the class GameScreenText method render.

@Override
@SideOnly(Side.CLIENT)
public void render(int type, float ticks, float sizeX, float sizeY, IScreenManager scr) {
    DrawGameScreen screen = (DrawGameScreen) scr;
    frameBx = sizeX - frameA;
    frameBy = sizeY - frameA;
    drawBlackBackground(0.0F);
    planeEquation(frameA, frameA, 0, frameA, frameBy, 0, frameA, frameBy, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE0, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE0);
    planeEquation(frameBx, frameBy, 0, frameBx, frameA, 0, frameBx, frameA, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE1, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE1);
    planeEquation(frameA, frameBy, 0, frameBx, frameBy, 0, frameBx, frameBy, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE2, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE2);
    planeEquation(frameBx, frameA, 0, frameA, frameA, 0, frameA, frameA, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE3, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE3);
    yPos = 0;
    TileEntityTelemetry telemeter = TileEntityTelemetry.getNearest(screen.driver);
    // Make the text to draw.  To look good it's important the width and height
    // of the whole text box are correctly set here.
    String strName = "";
    String[] str = { GCCoreUtil.translate("gui.display.nolink"), "", "", "", "" };
    Render renderEntity = null;
    Entity entity = null;
    float Xmargin = 0;
    if (telemeter != null && telemeter.clientData.length >= 3) {
        if (telemeter.clientClass != null) {
            if (telemeter.clientClass == screen.telemetryLastClass && (telemeter.clientClass != EntityPlayerMP.class || telemeter.clientName.equals(screen.telemetryLastName))) {
                // Used cached data from last time if possible
                entity = screen.telemetryLastEntity;
                renderEntity = screen.telemetryLastRender;
                strName = screen.telemetryLastName;
            } else {
                // Create an entity to render, based on class, and get its name
                entity = null;
                if (telemeter.clientClass == EntityPlayerMP.class) {
                    strName = telemeter.clientName;
                    entity = new EntityOtherPlayerMP(screen.driver.getWorld(), telemeter.clientGameProfile);
                    renderEntity = (Render) FMLClientHandler.instance().getClient().getRenderManager().getEntityRenderObject(entity);
                } else {
                    try {
                        entity = (Entity) telemeter.clientClass.getConstructor(World.class).newInstance(screen.driver.getWorld());
                    } catch (Exception ex) {
                    }
                    if (entity != null) {
                        strName = entity.getName();
                    }
                    renderEntity = (Render) FMLClientHandler.instance().getClient().getRenderManager().entityRenderMap.get(telemeter.clientClass);
                }
            }
            // Setup special visual types from data sent by Telemetry
            if (entity instanceof EntityHorse) {
                ((EntityHorse) entity).setHorseType(telemeter.clientData[3]);
                ((EntityHorse) entity).setHorseVariant(telemeter.clientData[4]);
            }
            if (entity instanceof EntityVillager) {
                ((EntityVillager) entity).setProfession(telemeter.clientData[3]);
                ((EntityVillager) entity).setGrowingAge(telemeter.clientData[4]);
            } else if (entity instanceof EntityWolf) {
                ((EntityWolf) entity).setCollarColor(EnumDyeColor.byDyeDamage(telemeter.clientData[3]));
                ((EntityWolf) entity).setBegging(telemeter.clientData[4] == 1);
            } else if (entity instanceof EntitySheep) {
                ((EntitySheep) entity).setFleeceColor(EnumDyeColor.byDyeDamage(telemeter.clientData[3]));
                ((EntitySheep) entity).setSheared(telemeter.clientData[4] == 1);
            } else if (entity instanceof EntityOcelot) {
                ((EntityOcelot) entity).setTameSkin(telemeter.clientData[3]);
            } else if (entity instanceof EntitySkeleton) {
                ((EntitySkeleton) entity).setSkeletonType(telemeter.clientData[3]);
            } else if (entity instanceof EntityZombie) {
                ((EntityZombie) entity).setVillager(telemeter.clientData[3] == 1);
                ((EntityZombie) entity).setChild(telemeter.clientData[4] == 1);
            }
        }
        if (entity instanceof ITelemetry) {
            ((ITelemetry) entity).receiveData(telemeter.clientData, str);
        } else if (entity instanceof EntityLivingBase) {
            // Living entity:
            // data0 = time to show red damage
            // data1 = health in half-hearts
            // data2 = pulse
            // data3 = hunger (for player); horsetype (for horse)
            // data4 = oxygen (for player); horsevariant (for horse)
            str[0] = telemeter.clientData[0] > 0 ? GCCoreUtil.translate("gui.player.ouch") : "";
            if (telemeter.clientData[1] >= 0) {
                str[1] = GCCoreUtil.translate("gui.player.health") + ": " + telemeter.clientData[1] + "%";
            } else {
                str[1] = "";
            }
            str[2] = "" + telemeter.clientData[2] + " " + GCCoreUtil.translate("gui.player.bpm");
            if (telemeter.clientData[3] > -1) {
                str[3] = GCCoreUtil.translate("gui.player.food") + ": " + telemeter.clientData[3] + "%";
            }
            if (telemeter.clientData[4] > -1) {
                int oxygen = telemeter.clientData[4];
                oxygen = (oxygen % 4096) + (oxygen / 4096);
                if (oxygen == 180 || oxygen == 90) {
                    str[4] = GCCoreUtil.translate("gui.oxygen_storage.desc.1") + ": OK";
                } else {
                    str[4] = GCCoreUtil.translate("gui.oxygen_storage.desc.1") + ": " + this.makeOxygenString(oxygen) + GCCoreUtil.translate("gui.seconds");
                }
            }
        } else // TODO  can add more here, e.g. position data?
        if (telemeter.clientData[2] >= 0) {
            str[2] = makeSpeedString(telemeter.clientData[2]);
        }
    } else {
        // Default - draw a simple time display just to show the Display Screen is working
        World w1 = screen.driver.getWorld();
        int time1 = w1 != null ? (int) ((w1.getWorldTime() + 6000L) % 24000L) : 0;
        str[2] = makeTimeString(time1 * 360);
    }
    int textWidthPixels = 155;
    // 1 lines
    int textHeightPixels = 60;
    if (str[3].isEmpty()) {
        textHeightPixels -= 10;
    }
    if (str[4].isEmpty()) {
        textHeightPixels -= 10;
    }
    // First pass - approximate border size
    float borders = frameA * 2 + 0.05F * Math.min(sizeX, sizeY);
    float scaleXTest = (sizeX - borders) / textWidthPixels;
    float scaleYTest = (sizeY - borders) / textHeightPixels;
    float scale = sizeX;
    if (scaleYTest < scaleXTest) {
        scale = sizeY;
    }
    // Second pass - the border size may be more accurate now
    borders = frameA * 2 + 0.05F * scale;
    scaleXTest = (sizeX - borders) / textWidthPixels;
    scaleYTest = (sizeY - borders) / textHeightPixels;
    scale = sizeX;
    float scaleText = scaleXTest;
    if (scaleYTest < scaleXTest) {
        scale = sizeY;
        scaleText = scaleYTest;
    }
    // Centre the text in the display
    float border = frameA + 0.025F * scale;
    if (entity != null && renderEntity != null) {
        Xmargin = (sizeX - borders) / 2;
    }
    float Xoffset = (sizeX - borders - textWidthPixels * scaleText) / 2 + Xmargin;
    float Yoffset = (sizeY - borders - textHeightPixels * scaleText) / 2 + scaleText;
    GL11.glTranslatef(border + Xoffset, border + Yoffset, 0.0F);
    GL11.glScalef(scaleText, scaleText, 1.0F);
    // Actually draw the text
    int whiteColour = ColorUtil.to32BitColor(255, 240, 216, 255);
    drawText(strName, whiteColour);
    drawText(str[0], whiteColour);
    drawText(str[1], whiteColour);
    drawText(str[2], whiteColour);
    drawText(str[3], whiteColour);
    drawText(str[4], whiteColour);
    // If there is an entity to render, draw it on the left of the text
    if (renderEntity != null && entity != null) {
        GL11.glTranslatef(-Xmargin / 2 / scaleText, textHeightPixels / 2 + (-Yoffset + (sizeY - borders) / 2) / scaleText, -0.0005F);
        float scalefactor = 38F / (float) Math.pow(Math.max(entity.height, entity.width), 0.65);
        GL11.glScalef(scalefactor, scalefactor, 0.0015F);
        GL11.glRotatef(180F, 0, 0, 1);
        GL11.glRotatef(180F, 0, 1, 0);
        if (entity instanceof ITelemetry) {
            ((ITelemetry) entity).adjustDisplay(telemeter.clientData);
        }
        RenderPlayerGC.flagThermalOverride = true;
        if (entity instanceof EntityLivingBase && renderEntity instanceof RendererLivingEntity && renderModelMethod != null) {
            this.renderLiving((EntityLivingBase) entity, (RendererLivingEntity) renderEntity, ticks % 1F);
        } else {
            renderEntity.doRender(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
        }
        RenderPlayerGC.flagThermalOverride = false;
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    }
    // TODO  Cross-dimensional tracking (i.e. old entity setDead, new entity created)
    // TODO  Deal with text off screen (including where localizations longer than English)
    screen.telemetryLastClass = (telemeter == null) ? null : telemeter.clientClass;
    screen.telemetryLastEntity = entity;
    screen.telemetryLastRender = renderEntity;
    screen.telemetryLastName = strName;
    GL11.glDisable(GL11.GL_CLIP_PLANE3);
    GL11.glDisable(GL11.GL_CLIP_PLANE2);
    GL11.glDisable(GL11.GL_CLIP_PLANE1);
    GL11.glDisable(GL11.GL_CLIP_PLANE0);
}
Also used : Entity(net.minecraft.entity.Entity) RendererLivingEntity(net.minecraft.client.renderer.entity.RendererLivingEntity) EntityOtherPlayerMP(net.minecraft.client.entity.EntityOtherPlayerMP) TileEntityTelemetry(micdoodle8.mods.galacticraft.core.tile.TileEntityTelemetry) Render(net.minecraft.client.renderer.entity.Render) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) World(net.minecraft.world.World) EntityZombie(net.minecraft.entity.monster.EntityZombie) ITelemetry(micdoodle8.mods.galacticraft.api.entity.ITelemetry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RendererLivingEntity(net.minecraft.client.renderer.entity.RendererLivingEntity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 10 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project Minechem by iopleke.

the class PolytoolEventHandler method onDrop.

@SubscribeEvent
public void onDrop(LivingDropsEvent event) {
    // Thanks to mDiyo
    if ("player".equals(event.source.damageType)) {
        EntityPlayer player = (EntityPlayer) event.source.getEntity();
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem() instanceof PolytoolItem) {
            float powerSilicon = PolytoolItem.getPowerOfType(stack, ElementEnum.Si);
            if (powerSilicon > 0) {
                int amount = (int) Math.ceil(random.nextDouble() * powerSilicon);
                Iterator iter = event.drops.iterator();
                if (random.nextInt(16) < 1 + powerSilicon) {
                    ArrayList<EntityItem> trueResult = new ArrayList<EntityItem>();
                    while (iter.hasNext()) {
                        EntityItem entityItem = (EntityItem) iter.next();
                        ItemStack item = entityItem.getEntityItem();
                        while (item.stackSize > 0) {
                            // Always avoid chances
                            DecomposerRecipe recipe = DecomposerRecipeHandler.instance.getRecipe(item);
                            if (recipe != null) {
                                ArrayList<ItemStack> items = MinechemUtil.convertChemicalsIntoItemStacks(recipe.getOutput());
                                for (ItemStack itemStack : items) {
                                    trueResult.add(new EntityItem(entityItem.worldObj, entityItem.posX, entityItem.posY, entityItem.posZ, itemStack));
                                }
                            } else {
                                trueResult.add(entityItem);
                                break;
                            }
                            item.stackSize--;
                        }
                    }
                    event.drops.clear();
                    event.drops.addAll(trueResult);
                }
            }
        }
        if (event.entityLiving instanceof EntitySkeleton || event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntityPlayer) {
            EntityLivingBase enemy = event.entityLiving;
            if (stack != null && stack.getItem() instanceof PolytoolItem) {
                // Nitrogen preservation
                if (enemy instanceof EntityZombie) {
                    float power = PolytoolItem.getPowerOfType(stack, ElementEnum.N);
                    if (power > 0) {
                        int amount = (int) Math.ceil(random.nextDouble() * power);
                        addDrops(event, new ItemStack(Items.cooked_beef, amount, 0));
                        Iterator iter = event.drops.iterator();
                        while (iter.hasNext()) {
                            EntityItem entityItem = (EntityItem) iter.next();
                            if (entityItem.getEntityItem().getItem() == Items.rotten_flesh) {
                                iter.remove();
                            }
                        }
                    }
                }
                // Calcium bonus
                if (enemy instanceof EntitySkeleton) {
                    float power = PolytoolItem.getPowerOfType(stack, ElementEnum.Ca);
                    if (power > 0) {
                        int amount = (int) Math.ceil(random.nextDouble() * power);
                        Iterator iter = event.drops.iterator();
                        while (iter.hasNext()) {
                            EntityItem entityItem = (EntityItem) iter.next();
                            if (entityItem.getEntityItem().getItem() == Items.bone) {
                                entityItem.getEntityItem().stackSize += amount;
                            }
                        }
                    }
                }
                // Beryllium beheading
                float beheading = PolytoolItem.getPowerOfType(stack, ElementEnum.Be);
                while (beheading > 5) {
                    if (beheading > 0 && random.nextInt(5) < beheading * 10) {
                        if (event.entityLiving instanceof EntitySkeleton) {
                            EntitySkeleton skeleton = (EntitySkeleton) enemy;
                            addDrops(event, new ItemStack(Items.skull, 1, skeleton.getSkeletonType()));
                        } else if (event.entityLiving instanceof EntityZombie) {
                            addDrops(event, new ItemStack(Items.skull, 1, 2));
                        } else if (event.entityLiving instanceof EntityPlayer) {
                            ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
                            NBTTagCompound nametag = new NBTTagCompound();
                            nametag.setString("SkullOwner", player.getDisplayName());
                            addDrops(event, dropStack);
                        }
                    }
                    // More head drops if level>5
                    beheading--;
                }
            }
        }
    }
}
Also used : EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityZombie(net.minecraft.entity.monster.EntityZombie) Iterator(java.util.Iterator) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityZombie (net.minecraft.entity.monster.EntityZombie)22 EntityLivingBase (net.minecraft.entity.EntityLivingBase)7 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)7 BlockPos (net.minecraft.util.math.BlockPos)6 EntityVillager (net.minecraft.entity.passive.EntityVillager)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 Zombie (org.spongepowered.api.entity.living.monster.Zombie)4 EntityLiving (net.minecraft.entity.EntityLiving)3 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)3 EntityPig (net.minecraft.entity.passive.EntityPig)3 Entity (org.spongepowered.api.entity.Entity)3 Player (org.spongepowered.api.entity.living.player.Player)3 Vector3d (com.flowpowered.math.vector.Vector3d)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Entity (net.minecraft.entity.Entity)2 PotionEffect (net.minecraft.potion.PotionEffect)2 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)2 Living (org.spongepowered.api.entity.living.Living)2