use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.
the class WorldGenClayHut method placeSoldiers.
private static void placeSoldiers(World world, Random rand, int x, int y, int z, String team) {
int soldiers = rand.nextInt(2) + 2;
boolean zombified = ModConfig.clayHutZombieChance > 0 && rand.nextInt(ModConfig.clayHutZombieChance) == 0;
if (zombified) {
world.setBlock(x, y + 4, z, Blocks.redstone_torch, 0, 3);
}
for (int i = 0; i < soldiers; i++) {
double sldX = x + rand.nextFloat();
double sldY = y + 1.5D;
double sldZ = z + rand.nextFloat();
EntityClayMan jack = new EntityClayMan(world, team);
jack.setPositionAndRotation(sldX, sldY, sldZ, rand.nextFloat() * (float) Math.PI, 0.0F);
if (zombified) {
jack.addUpgrade(SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_ENDERPEARL));
} else {
jack.addUpgrade(SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_WHEAT));
}
jack.nexusSpawn = true;
world.spawnEntityInWorld(jack);
}
}
use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.
the class UpgradeSlimeball method onProjectileHit.
@Override
public void onProjectileHit(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, MovingObjectPosition target, ISoldierProjectile<? extends EntityThrowable> projectile) {
if (target.entityHit instanceof EntityClayMan) {
EntityClayMan caddicarus = (EntityClayMan) target.entityHit;
if (caddicarus.addEffect(SoldierEffects.getEffect(SoldierEffects.EFF_SLIMEFEET)) != null) {
caddicarus.playSound("mob.slime.attack", 1.0F, 1.0F);
upgradeInst.getNbtTag().setShort(NBT_USES, (short) (upgradeInst.getNbtTag().getShort(NBT_USES) - 1));
}
}
}
use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.
the class EntityBunnyMount method attackEntityFrom.
@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
if (source == IDisruptable.DISRUPT_DAMAGE) {
return super.attackEntityFrom(source, damage);
}
Entity entity = source.getSourceOfDamage();
if (!(entity instanceof EntityClayMan) && !source.isFireDamage()) {
damage = 999;
}
if (this.riddenByEntity instanceof EntityClayMan && source.getEntity() instanceof ISoldierProjectile) {
EntityClayMan clayMan = (EntityClayMan) this.riddenByEntity;
ISoldierProjectile projectile = (ISoldierProjectile) source.getEntity();
if (clayMan.getClayTeam().equals(projectile.getTrowingTeam())) {
return false;
}
}
return super.attackEntityFrom(source, damage);
}
use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.
the class EntityTurtleMount method attackEntityFrom.
@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
if (source == IDisruptable.DISRUPT_DAMAGE) {
return super.attackEntityFrom(source, damage);
}
boolean shouldSpawnSpecial = rand.nextInt(16) == 0;
this.specialDeath = source.isFireDamage() && !this.isSpecial() && shouldSpawnSpecial;
Entity entity = source.getSourceOfDamage();
if (!(entity instanceof EntityClayMan) && !source.isFireDamage()) {
damage = 999;
} else if (source.isFireDamage() && this.getType() == EnumTurtleType.NETHERRACK.ordinal()) {
return false;
}
if (this.riddenByEntity instanceof EntityClayMan && source.getEntity() instanceof ISoldierProjectile) {
EntityClayMan clayMan = (EntityClayMan) this.riddenByEntity;
ISoldierProjectile projectile = (ISoldierProjectile) source.getEntity();
if (clayMan.getClayTeam().equals(projectile.getTrowingTeam())) {
return false;
}
}
boolean damageSuccess = super.attackEntityFrom(source, damage);
if (damageSuccess && this.getHealth() <= 0) {
if (source.isFireDamage() && !this.isSpecial() && shouldSpawnSpecial) {
EntityTurtleMount kawako = new EntityTurtleMount(this.worldObj, EnumTurtleType.VALUES[this.getType()]);
kawako.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
kawako.setSpecial();
kawako.chooseTexture();
kawako.setTurtleSpecs();
this.worldObj.spawnEntityInWorld(kawako);
}
}
return damageSuccess;
}
use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.
the class TileEntityClayNexus method updateEntity.
@Override
public void updateEntity() {
if (this.p_searchArea == null || this.p_damageArea == null) {
this.p_searchArea = AxisAlignedBB.getBoundingBox(this.xCoord - 63.0D, this.yCoord - 63.0D, this.zCoord - 63.0D, this.xCoord + 64.0D, this.yCoord + 64.0D, this.zCoord + 64.0D);
this.p_damageArea = AxisAlignedBB.getBoundingBox(this.xCoord + 0.1D, this.yCoord + 0.1D, this.zCoord + 0.1D, this.xCoord + 0.9D, this.yCoord + 0.9D, this.zCoord + 0.9D);
}
super.updateEntity();
boolean isRsPowered = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.getIndirectPowerLevelTo(this.xCoord - 1, this.yCoord, this.zCoord, 1) > 0 || this.worldObj.getIndirectPowerLevelTo(this.xCoord, this.yCoord, this.zCoord + 1, 1) > 0 || this.worldObj.getIndirectPowerLevelTo(this.xCoord, this.yCoord, this.zCoord - 1, 1) > 0 || this.worldObj.getIndirectPowerLevelTo(this.xCoord + 1, this.yCoord, this.zCoord, 1) > 0;
if (!this.worldObj.isRemote && !this.p_prevRsPowerState && isRsPowered) {
this.isActive = !this.isActive;
this.markDirty();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
this.p_prevRsPowerState = isRsPowered;
if (this.isActive) {
if (this.p_health <= 0.0F) {
this.isActive = false;
} else {
this.ticksActive++;
}
if (!this.worldObj.isRemote && this.p_health > 0.0F) {
if (this.ticksActive % 20 == 0) {
int dmgEnemies = this.countDamagingEnemies();
if (dmgEnemies > 0) {
float healthDamage = 0.5F;
if (dmgEnemies > 1) {
healthDamage = 0.125F * dmgEnemies;
}
this.p_health -= healthDamage;
if (this.p_health < 0.0F) {
this.p_health = 0.0F;
}
this.markDirty();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
List<EntityClayMan> enemies = this.getEnemies(true);
for (EntityClayMan dalek : enemies) {
if (!dalek.hasPath()) {
dalek.setPathToEntity(BugfixHelper.getEntityPathToXYZ(this.worldObj, dalek, this.xCoord, this.yCoord, this.zCoord, 64.0F, true, false, false, true));
}
}
}
if (ticksActive % this.spawnThrowableInterval == 0 && this.p_throwableSlot != null) {
List<EntityClayMan> clayMen = getEnemies(true);
if (clayMen.size() > 0) {
EntityClayMan target = clayMen.get(SAPUtils.RNG.nextInt(clayMen.size()));
double deltaX = target.posX - this.xCoord + 0.5F;
double deltaZ = target.posZ - this.zCoord + 0.5F;
try {
ISoldierProjectile<? extends EntityThrowable> projectile = this.p_tempThrowableCls.getConstructor(World.class, double.class, double.class, double.class).newInstance(this.worldObj, this.xCoord + 0.5F, this.yCoord + 0.875F, this.zCoord + 0.5F);
projectile.initProjectile(target, true, this.p_tempClayTeam.getTeamName());
EntityThrowable throwable = projectile.getProjectileEntity();
double d2 = (target.posY + target.getEyeHeight()) - 0.10000000298023224D - throwable.posY;
float f1 = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ) * 0.2F;
this.worldObj.spawnEntityInWorld(throwable);
throwable.setThrowableHeading(deltaX, d2 + f1, deltaZ, 0.6F, 12.0F);
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
FMLLog.log(ClaySoldiersMod.MOD_LOG, Level.ERROR, "%1$s cannot be instantiated! %1$s is not thrown to target!", this.p_tempThrowableCls.getName());
e.printStackTrace();
}
}
}
if (this.p_soldierSlot != null) {
if (this.ticksActive % this.spawnSoldierInterval == 0 && this.p_spawningSoldierCounter <= 0) {
this.p_spawningSoldierCounter = Math.min(this.soldierSpawnCount, this.maxSoldierCount - this.countTeammates());
this.p_prevSpawningSoldierCounter = this.p_spawningSoldierCounter;
}
if (ticksActive % 5 == 0) {
if (this.p_spawningSoldierCounter > 0) {
this.p_spawningSoldierCounter = Math.min(this.p_prevSpawningSoldierCounter, this.maxSoldierCount - this.countTeammates());
this.p_prevSpawningSoldierCounter = this.p_spawningSoldierCounter - 1;
if (this.p_spawningSoldierCounter > 0) {
ItemClayManDoll.spawnClayMan(this.worldObj, this.p_tempClayTeam.getTeamName(), this.xCoord + 0.5F, this.yCoord + 0.2D, this.zCoord + 0.5F).nexusSpawn = true;
}
}
}
}
}
}
if (this.worldObj.isRemote) {
this.prevSpinAngle = this.spinAngle;
if (this.isActive && this.p_health > 0.0F) {
this.spinAngle += 4;
RGBAValues rgba = SAPUtils.getRgbaFromColorInt(ItemClayManDoll.getTeam(this.p_soldierSlot).getTeamColor());
ClaySoldiersMod.proxy.spawnParticles(EnumParticleFx.FX_NEXUS, Sextet.with((double) this.xCoord, (double) this.yCoord, (double) this.zCoord, rgba.getRed() / 255.0F, rgba.getGreen() / 255.0F, rgba.getBlue() / 255.0F));
} else if (this.spinAngle % 90 != 0) {
this.spinAngle += 2;
}
if (this.spinAngle >= 360) {
this.prevSpinAngle = -1;
this.spinAngle = 0;
}
}
}
Aggregations