use of sanandreasp.mods.ClaySoldiersMod.entity.mount.EntityHorse in project ClaySoldiersMod by SanAndreasP.
the class EntityClayNexus method spawnSoldiers.
private void spawnSoldiers() {
if (worldObj.isRemote)
return;
for (int i = 0; i < getMaxSpwnSoldiers() && !isMaxSpawningReached(); i++) {
double clayX;
double clayY;
double clayZ;
clayX = posX + rand.nextInt(2) * 0.5F * (rand.nextBoolean() ? -1 : 1) + 0.2D;
clayY = posY + 0.5F;
clayZ = posZ + rand.nextInt(2) * 0.5F * (rand.nextBoolean() ? -1 : 1) + 0.2D;
EntityClayMan ec = null;
if (!getSpawnMount()) {
ec = new EntityClayMan(worldObj, (int) Math.floor(clayX), (int) Math.floor(clayY), (int) Math.floor(clayZ), getColor());
ec.setNexusSpawn();
}
EntityLiving mount = null;
if (nexusIS[1] != null && nexusIS[1].stackSize > 0) {
if (nexusIS[1].itemID == CSMModRegistry.horseDoll.itemID)
mount = new EntityHorse(worldObj, clayX, clayY, clayZ, nexusIS[1].getItemDamage()).setSpawnedFromNexus();
if (nexusIS[1].itemID == CSMModRegistry.pegasusDoll.itemID)
mount = new EntityPegasus(worldObj, clayX, clayY, clayZ, nexusIS[1].getItemDamage()).setSpawnedFromNexus();
if (nexusIS[1].itemID == CSMModRegistry.turtleDoll.itemID)
mount = new EntityTurtle(worldObj, clayX, clayY, clayZ, nexusIS[1].getItemDamage()).setSpawnedFromNexus();
if (nexusIS[1].itemID == CSMModRegistry.bunnyDoll.itemID)
mount = new EntityBunny(worldObj, clayX, clayY, clayZ, nexusIS[1].getItemDamage()).setSpawnedFromNexus();
if (nexusIS[1].itemID == CSMModRegistry.geckoDoll.itemID)
mount = new EntityGecko(worldObj, clayX, clayY, clayZ, nexusIS[1].getItemDamage()).setSpawnedFromNexus();
}
if (!getSpawnMount()) {
boolean[] usedStacks = new boolean[nexusIS.length];
for (int j = 2; j < nexusIS.length && !hasRandItems(); j++) {
if (nexusIS[j] != null && nexusIS[j].stackSize > 0 && !usedStacks[j]) {
if (checkIfItemIsValidAndApply(nexusIS[j], ec, false)) {
checkForUpgradeItem(ec);
}
usedStacks[j] = true;
}
}
if (hasRandItems()) {
int loopInd = 0;
do {
int index = rand.nextInt(nexusIS.length - 2) + 2;
if (nexusIS[index] != null && nexusIS[index].stackSize > 0 && !usedStacks[index]) {
loopInd = 0;
if (checkIfItemIsValidAndApply(nexusIS[index], ec, false)) {
checkForUpgradeItem(ec);
}
usedStacks[index] = true;
} else {
loopInd++;
}
} while (loopInd < nexusIS.length - 2);
}
worldObj.spawnEntityInWorld(ec);
CSMModRegistry.proxy.showEffect(this.worldObj, ec, 11);
// ec.spawnExplosionParticle();
}
if (mount != null) {
worldObj.spawnEntityInWorld(mount);
if (!getSpawnMount())
ec.mountEntity(mount);
}
}
}
use of sanandreasp.mods.ClaySoldiersMod.entity.mount.EntityHorse in project ClaySoldiersMod by SanAndreasP.
the class EntityClayNexus method isMaxSpawningReached.
private boolean isMaxSpawningReached() {
List<Entity> el = worldObj.loadedEntityList;
int count = 0;
for (Entity entity : el) {
if (entity instanceof EntityClayMan) {
if (((EntityClayMan) entity).getClayTeam() == getColor() && ((EntityClayMan) entity).spawnedFromNexus())
count++;
} else if (getSpawnMount() && (entity instanceof IMount) && ((IMount) entity).getType() == nexusIS[1].getItemDamage()) {
if (entity instanceof EntityPegasus && nexusIS[1].getItem() instanceof ItemHorses && ((ItemHorses) nexusIS[1].getItem()).horseType == 1) {
count++;
} else if (entity instanceof EntityHorse && nexusIS[1].getItem() instanceof ItemHorses && ((ItemHorses) nexusIS[1].getItem()).horseType == 0) {
count++;
} else if (entity instanceof EntityTurtle && nexusIS[1].getItem() instanceof ItemTurtle) {
count++;
} else if (entity instanceof EntityBunny && nexusIS[1].getItem() instanceof ItemBunny) {
count++;
} else if (entity instanceof EntityGecko && nexusIS[1].getItem() instanceof ItemGecko) {
count++;
}
}
}
return count >= getMaxLvngSoldiers();
}
use of sanandreasp.mods.ClaySoldiersMod.entity.mount.EntityHorse in project ClaySoldiersMod by SanAndreasP.
the class ItemHorses method spawnHorse.
public boolean spawnHorse(World par0World, int par1, double par2, double par4, double par6) {
EntityHorse var8 = new EntityHorse(par0World, par2, par4, par6, par1);
if (horseType == 1)
var8 = new EntityPegasus(par0World, par2, par4, par6, par1);
if (var8 != null) {
var8.setLocationAndAngles(par2, par4, par6, par0World.rand.nextFloat() * 360.0F, 0.0F);
par0World.spawnEntityInWorld(var8);
var8.playLivingSound();
}
return var8 != null;
}
use of sanandreasp.mods.ClaySoldiersMod.entity.mount.EntityHorse in project ClaySoldiersMod by SanAndreasP.
the class Handler_BehaviorDispenseItem method getLivingFromItem.
private static EntityLiving getLivingFromItem(World world, double x, double y, double z, ItemStack item) {
if (item.getItem() instanceof ItemClayMan) {
EntityClayMan entityclayman = new EntityClayMan(world, x, y, z, item.getItemDamage());
world.playSoundEffect(x, y, z, "step.gravel", 1.0F, 1.0F / 0.4F + 0.8F);
return entityclayman;
} else if (item.getItem() instanceof ItemHorses) {
EntityHorse entityhorse = new EntityHorse(world, x, y, z, item.getItemDamage());
if (item.getItem() == CSMModRegistry.pegasusDoll) {
entityhorse = new EntityPegasus(world, x, y, z, item.getItemDamage());
}
world.playSoundEffect(x, y, z, "step.gravel", 1.0F, 1.0F / 0.4F + 1.2F);
return entityhorse;
} else if (item.getItem() instanceof ItemTurtle) {
EntityTurtle entityturtle = new EntityTurtle(world, x, y, z, item.getItemDamage());
world.playSoundEffect(x, y, z, "step.stone", 1.0F, 1.0F / 0.4F + 0.8F);
return entityturtle;
} else if (item.getItem() instanceof ItemBunny) {
EntityBunny entitybunny = new EntityBunny(world, x, y, z, item.getItemDamage());
world.playSoundEffect(x, y, z, "step.stone", 1.0F, 1.0F / 0.4F + 0.8F);
return entitybunny;
} else if (item.getItem() instanceof ItemGecko) {
EntityGecko entitygecko = new EntityGecko(world, x, y, z, item.getItemDamage());
world.playSoundEffect(x, y, z, "step.gravel", 1.0F, 1.0F / 0.4F + 1.2F);
return entitygecko;
}
return null;
}
Aggregations