Search in sources :

Example 21 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class TileEntityClayNexus method countTeammates.

private int countTeammates() {
    @SuppressWarnings("unchecked") List<EntityClayMan> soldiers = this.worldObj.getEntitiesWithinAABB(EntityClayMan.class, this.p_searchArea);
    int cnt = 0;
    for (EntityClayMan dodger : soldiers) {
        if (dodger.getClayTeam().equals(this.p_tempClayTeam.getTeamName())) {
            cnt++;
        }
    }
    return cnt;
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan)

Example 22 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class TileEntityClayNexus method getEnemies.

private List<EntityClayMan> getEnemies(boolean mustBeSeen) {
    @SuppressWarnings("unchecked") List<EntityClayMan> soldiers = this.worldObj.getEntitiesWithinAABB(EntityClayMan.class, this.p_searchArea);
    Iterator<EntityClayMan> iterator = soldiers.iterator();
    while (iterator.hasNext()) {
        EntityClayMan roomie = iterator.next();
        if (roomie.getClayTeam().equals(this.p_tempClayTeam.getTeamName()) || (mustBeSeen && !this.canEntityBeSeen(roomie))) {
            iterator.remove();
        }
    }
    return soldiers;
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan)

Example 23 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class UpgradeEnderpearl method onUpdate.

@Override
public boolean onUpdate(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst) {
    short ticksAlive = upgradeInst.getNbtTag().getShort("ticksActive");
    upgradeInst.getNbtTag().setShort("ticksActive", ++ticksAlive);
    if (!(clayMan.getEntityToAttack() instanceof EntityClayMan && ((EntityClayMan) clayMan.getEntityToAttack()).getClayTeam().equals(clayMan.getClayTeam()))) {
        EntityPlayer closestPlayer = clayMan.worldObj.getClosestPlayer(clayMan.posX, clayMan.posY, clayMan.posZ, clayMan.getLookRangeRad());
        if (!(clayMan.getEntityToAttack() instanceof EntityPlayer) && closestPlayer != null && !closestPlayer.isDead && !(closestPlayer.isEntityInvulnerable() || closestPlayer.capabilities.isCreativeMode)) {
            clayMan.setTarget(closestPlayer);
        }
    }
    if (ticksAlive == 12000) {
        clayMan.attackEntityFrom(DamageSource.magic, 10000.0F);
    }
    return false;
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 24 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class RenderStatDisplayOverlay method renderSoldiers.

private void renderSoldiers(Minecraft mc) {
    @SuppressWarnings("unchecked") List<EntityClayMan> soldiers = mc.theWorld.getEntitiesWithinAABB(EntityClayMan.class, getRangeAabbFromPlayer(mc.thePlayer));
    // team background color, team name, team count
    List<Quartet<Integer, String, Integer, ItemStack>> teams = new ArrayList<>();
    Map<String, Integer> teamCounts = Maps.newHashMap();
    for (EntityClayMan dex : soldiers) {
        String team = dex.getClayTeam();
        if (teamCounts.containsKey(team)) {
            teamCounts.put(team, teamCounts.get(team) + 1);
        } else {
            teamCounts.put(team, 1);
        }
    }
    for (Entry<String, Integer> team : teamCounts.entrySet()) {
        ClaymanTeam teamInst = ClaymanTeam.getTeam(team.getKey());
        ItemStack renderedItem = new ItemStack(RegistryItems.dollSoldier);
        ItemClayManDoll.setTeamForItem(team.getKey(), renderedItem);
        teams.add(Quartet.with(teamInst.getTeamColor(), renderedItem.getUnlocalizedName() + ".color", team.getValue(), renderedItem));
    }
    this.renderStats(mc, SAPUtils.translate(RegistryItems.statDisplay.getUnlocalizedName() + ".title.soldiers"), teams, 5, 5);
}
Also used : Quartet(de.sanandrew.core.manpack.util.javatuples.Quartet) ClaymanTeam(de.sanandrew.mods.claysoldiers.util.soldier.ClaymanTeam) EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 25 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class BehaviorDollDispenseItem method doDispense.

private static void doDispense(World world, ItemStack stack, EnumFacing facing, IPosition position) {
    double x = position.getX();
    double y = position.getY() - (facing == EnumFacing.UP ? 0.0D : 0.3D);
    double z = position.getZ();
    if (stack.getItem() == RegistryItems.dollSoldier) {
        EntityClayMan spencer = ItemClayManDoll.spawnClayMan(world, ItemClayManDoll.getTeam(stack).getTeamName(), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollHorseMount) {
        EntityHorseMount spencer = ItemHorseDoll.spawnHorse(world, ItemHorseDoll.getType(stack), ItemHorseDoll.isPegasus(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollTurtleMount) {
        EntityTurtleMount spencer = ItemTurtleDoll.spawnTurtle(world, ItemTurtleDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollGeckoMount) {
        EntityGeckoMount spencer = ItemGeckoDoll.spawnGecko(world, ItemGeckoDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollBunnyMount) {
        EntityBunnyMount spencer = ItemBunnyDoll.spawnBunny(world, ItemBunnyDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    }
}
Also used : EntityHorseMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityHorseMount) EntityTurtleMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityTurtleMount) EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) EntityGeckoMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityGeckoMount) EntityBunnyMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)

Aggregations

EntityClayMan (de.sanandrew.mods.claysoldiers.entity.EntityClayMan)30 Entity (net.minecraft.entity.Entity)7 ISoldierProjectile (de.sanandrew.mods.claysoldiers.entity.projectile.ISoldierProjectile)4 DamageSource (net.minecraft.util.DamageSource)4 Block (net.minecraft.block.Block)2 World (net.minecraft.world.World)2 RGBAValues (de.sanandrew.core.manpack.util.helpers.SAPUtils.RGBAValues)1 Quartet (de.sanandrew.core.manpack.util.javatuples.Quartet)1 EntityBunnyMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)1 EntityGeckoMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityGeckoMount)1 EntityHorseMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityHorseMount)1 EntityTurtleMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityTurtleMount)1 ClaymanTeam (de.sanandrew.mods.claysoldiers.util.soldier.ClaymanTeam)1 ASoldierEffect (de.sanandrew.mods.claysoldiers.util.soldier.effect.ASoldierEffect)1 SoldierEffectInst (de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst)1 ASoldierUpgrade (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityThrowable (net.minecraft.entity.projectile.EntityThrowable)1