use of WayofTime.bloodmagic.soul.DemonWillHolder in project BloodMagic by WayofTime.
the class GenericHandler method sendPlayerDemonWillAura.
// @SideOnly(Side.SERVER)
public static void sendPlayerDemonWillAura(EntityPlayer player) {
if (player instanceof EntityPlayerMP) {
BlockPos pos = player.getPosition();
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.getEntityWorld().provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4);
if (holder != null) {
BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(holder), (EntityPlayerMP) player);
} else {
BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(new DemonWillHolder()), (EntityPlayerMP) player);
}
}
}
use of WayofTime.bloodmagic.soul.DemonWillHolder in project BloodMagic by WayofTime.
the class WorldDemonWillHandler method fillWill.
public static double fillWill(World world, BlockPos pos, EnumDemonWillType type, double amount, boolean doFill) {
WillChunk willChunk = getWillChunk(world, pos);
DemonWillHolder currentWill = willChunk.getCurrentWill();
if (!doFill) {
return amount;
}
currentWill.addWill(type, amount);
markChunkAsDirty(willChunk, world.provider.getDimension());
return amount;
}
use of WayofTime.bloodmagic.soul.DemonWillHolder in project BloodMagic by WayofTime.
the class WorldDemonWillHandler method getHighestDemonWillType.
public static EnumDemonWillType getHighestDemonWillType(World world, BlockPos pos) {
double currentMax = 0;
EnumDemonWillType currentHighest = EnumDemonWillType.DEFAULT;
WillChunk willChunk = getWillChunk(world, pos);
DemonWillHolder currentWill = willChunk.getCurrentWill();
for (EnumDemonWillType type : EnumDemonWillType.values()) {
if (currentWill.getWill(type) > currentMax) {
currentMax = currentWill.getWill(type);
currentHighest = type;
}
}
return currentHighest;
}
use of WayofTime.bloodmagic.soul.DemonWillHolder in project BloodMagic by WayofTime.
the class WorldDemonWillHandler method getCurrentWill.
public static double getCurrentWill(World world, BlockPos pos, EnumDemonWillType type) {
WillChunk willChunk = getWillChunk(world, pos);
if (willChunk == null) {
return 0;
}
DemonWillHolder currentWill = willChunk.getCurrentWill();
return currentWill.getWill(type);
}
use of WayofTime.bloodmagic.soul.DemonWillHolder in project BloodMagic by WayofTime.
the class RitualLava method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
timer++;
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
int lpDrain = 0;
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
double rawDrained = 0;
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE);
int maxLavaVolume = getMaxVolumeForRange(LAVA_RANGE, willConfig, holder);
if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume)) {
return;
}
for (BlockPos newPos : lavaRange.getContainedPositions(pos)) {
IBlockState state = world.getBlockState(newPos);
if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state)) {
int lpCost = getLPCostForRawWill(rawWill);
if (currentEssence < lpCost) {
break;
}
world.setBlockState(newPos, Blocks.FLOWING_LAVA.getDefaultState());
currentEssence -= lpCost;
lpDrain += lpCost;
if (rawWill > 0) {
double drain = getWillCostForRawWill(rawWill);
rawWill -= drain;
rawDrained += drain;
}
}
}
if (rawWill > 0) {
AreaDescriptor chestRange = getBlockRange(LAVA_TANK_RANGE);
TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0));
double drain = getWillCostForRawWill(rawWill);
int lpCost = getLPCostForRawWill(rawWill);
if (rawWill >= drain && currentEssence >= lpCost) {
if (tile != null) {
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
double filled = handler.fill(new FluidStack(FluidRegistry.LAVA, 1000), true);
double ratio = filled / 1000;
rawWill -= drain * ratio;
rawDrained += drain * ratio;
currentEssence -= Math.ceil(lpCost * ratio);
lpDrain += Math.ceil(lpCost * ratio);
}
}
}
}
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
if (vengefulWill >= vengefulWillDrain) {
double vengefulDrained = 0;
AreaDescriptor fuseRange = getBlockRange(FIRE_FUSE_RANGE);
AxisAlignedBB fuseArea = fuseRange.getAABB(pos);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, fuseArea);
for (EntityLivingBase entity : entities) {
if (vengefulWill < vengefulWillDrain) {
break;
}
if (entity instanceof EntityPlayer) {
continue;
}
if (!entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) {
entity.addPotionEffect(new PotionEffect(RegistrarBloodMagic.FIRE_FUSE, 100, 0));
vengefulDrained += vengefulWillDrain;
vengefulWill -= vengefulWillDrain;
}
}
if (vengefulDrained > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrained, true);
}
}
if (steadfastWill >= steadfastWillDrain) {
double steadfastDrained = 0;
AreaDescriptor resistRange = getBlockRange(FIRE_RESIST_RANGE);
int duration = getFireResistForWill(steadfastWill);
AxisAlignedBB resistArea = resistRange.getAABB(pos);
List<EntityPlayer> entities = world.getEntitiesWithinAABB(EntityPlayer.class, resistArea);
for (EntityPlayer entity : entities) {
if (steadfastWill < steadfastWillDrain) {
break;
}
if (!entity.isPotionActive(MobEffects.FIRE_RESISTANCE) || (entity.getActivePotionEffect(MobEffects.FIRE_RESISTANCE).getDuration() < 2)) {
entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 100, 0));
steadfastDrained += steadfastWillDrain;
steadfastWill -= steadfastWillDrain;
}
}
if (steadfastDrained > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrained, true);
}
}
if (timer % corrosiveRefreshTime == 0 && corrosiveWill >= corrosiveWillDrain) {
double corrosiveDrained = 0;
AreaDescriptor resistRange = getBlockRange(FIRE_DAMAGE_RANGE);
float damage = getCorrosiveDamageForWill(corrosiveWill);
AxisAlignedBB damageArea = resistRange.getAABB(pos);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, damageArea);
for (EntityLivingBase entity : entities) {
if (corrosiveWill < corrosiveWillDrain) {
break;
}
if (!entity.isDead && entity.hurtTime <= 0 && Utils.isImmuneToFireDamage(entity)) {
if (entity.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, damage)) {
corrosiveDrained += corrosiveWillDrain;
corrosiveWill -= corrosiveWillDrain;
}
}
}
if (corrosiveDrained > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrained, true);
}
}
if (rawDrained > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true);
}
masterRitualStone.getOwnerNetwork().syphon(lpDrain);
}
Aggregations