Search in sources :

Example 1 with PacketNutrientTank

use of crazypants.enderio.machines.machine.generator.zombie.PacketNutrientTank in project EnderIO by SleepyTrousers.

the class TileInventoryPanel method doUpdate.

@Override
public void doUpdate() {
    if (world.isRemote) {
        updateEntityClient();
        return;
    }
    if (shouldDoWorkThisTick(20)) {
        scanNetwork();
    }
    if (updateClients) {
        forceUpdatePlayers();
        markDirty();
        updateClients = false;
    }
    if (tanksDirty) {
        tanksDirty = false;
        PacketHandler.sendToAllAround(new PacketNutrientTank(this), this);
    }
}
Also used : PacketNutrientTank(crazypants.enderio.machines.machine.generator.zombie.PacketNutrientTank)

Example 2 with PacketNutrientTank

use of crazypants.enderio.machines.machine.generator.zombie.PacketNutrientTank 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)

Aggregations

PacketNutrientTank (crazypants.enderio.machines.machine.generator.zombie.PacketNutrientTank)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityZombie (net.minecraft.entity.monster.EntityZombie)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TargetContext (net.minecraftforge.server.permission.context.TargetContext)1