use of de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst in project ClaySoldiersMod by SanAndreasP.
the class EntityClayMan method readEntityFromNBT.
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
this.dataWatcher.updateObject(DW_TEAM, nbt.getString("team"));
this.dataWatcher.updateObject(DW_MISC_COLOR, nbt.getByte("miscColor"));
this.dataWatcher.updateObject(DW_IS_TEXTURE_RARE_OR_UNIQUE, nbt.getByte("isRareOrUnique"));
this.dataWatcher.updateObject(DW_TEXTURE_INDEX, nbt.getInteger("textureIndex"));
this.canMove = nbt.getBoolean("canMove");
this.nexusSpawn = nbt.getBoolean("nexusSpawned");
if (nbt.hasKey("dollItem")) {
this.dollItem = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("dollItem"));
}
NBTTagList upgNbtList = nbt.getTagList("upgrade", NBT.TAG_COMPOUND);
for (int i = 0; i < upgNbtList.tagCount(); i++) {
NBTTagCompound savedUpg = upgNbtList.getCompoundTagAt(i);
SoldierUpgradeInst upgInst = new SoldierUpgradeInst(SoldierUpgrades.getUpgrade(savedUpg.getString("name")));
upgInst.setNbtTag(savedUpg.getCompoundTag("data"));
if (savedUpg.hasKey("item")) {
upgInst.readStoredItemFromNBT(savedUpg.getCompoundTag("item"));
}
this.p_upgrades.put(upgInst.getUpgrade(), upgInst);
}
NBTTagList effNbtList = nbt.getTagList("effect", NBT.TAG_COMPOUND);
for (int i = 0; i < effNbtList.tagCount(); i++) {
NBTTagCompound savedEff = effNbtList.getCompoundTagAt(i);
SoldierEffectInst effInst = new SoldierEffectInst(SoldierEffects.getEffect(savedEff.getString("name")));
effInst.setNbtTag(savedEff.getCompoundTag("data"));
this.p_effects.put(effInst.getEffect(), effInst);
}
}
use of de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst in project ClaySoldiersMod by SanAndreasP.
the class EntityEmeraldChunk method onImpact.
@Override
protected void onImpact(MovingObjectPosition movObjPos) {
if (movObjPos.entityHit != null) {
boolean isEnemy = movObjPos.entityHit instanceof EntityClayMan && this.target instanceof EntityClayMan && !((EntityClayMan) movObjPos.entityHit).getClayTeam().equals(((EntityClayMan) this.target).getClayTeam());
DamageSource dmgSrc = DamageSource.causeThrownDamage(this, this.getThrower());
if (this.getThrower() == null) {
dmgSrc = DamageSource.causeThrownDamage(this, this);
}
dmgSrc.setDamageBypassesArmor();
if (movObjPos.entityHit == this.target || isEnemy) {
float attackDmg = 3.0F + this.rand.nextFloat();
if (movObjPos.entityHit.isWet()) {
attackDmg *= 2.0F;
}
if (movObjPos.entityHit.attackEntityFrom(dmgSrc, attackDmg)) {
if (this.getThrower() instanceof EntityClayMan) {
((EntityClayMan) this.getThrower()).onProjectileHit(this, movObjPos);
}
if (movObjPos.entityHit instanceof EntityClayMan) {
EntityClayMan iChun = (EntityClayMan) movObjPos.entityHit;
movObjPos.entityHit.playSound("ambient.weather.thunder", 1.0F, 8.0F);
SoldierEffectInst effect = iChun.addEffect(SoldierEffects.getEffect(SoldierEffects.EFF_THUNDER));
if (effect != null && this.origin != null) {
effect.getNbtTag().setDouble("originX", this.origin.getValue0());
effect.getNbtTag().setDouble("originY", this.origin.getValue1());
effect.getNbtTag().setDouble("originZ", this.origin.getValue2());
}
iChun.updateUpgradeEffectRenders();
}
}
} else {
return;
}
}
if (!this.worldObj.isRemote) {
if (movObjPos.typeOfHit != MovingObjectType.BLOCK || this.getBlockCollisionBox(this.worldObj, movObjPos.blockX, movObjPos.blockY, movObjPos.blockZ) != null) {
ParticlePacketSender.sendDiggingFx(this.posX, this.posY, this.posZ, this.dimension, Blocks.snow);
this.setDead();
}
this.dataWatcher.updateObject(DW_DEAD, (byte) (this.isDead ? 1 : 0));
}
}
Aggregations