use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSentientAxe method recalculatePowers.
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT);
int level = getLevel(stack, soulsRemaining);
double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
double extraDamage = getExtraDamage(type, level);
setDrainOfActivatedSword(stack, drain);
setDamageOfActivatedSword(stack, baseAttackDamage + extraDamage);
setStaticDropOfActivatedSword(stack, level >= 0 ? staticDrop[level] : 1);
setDropOfActivatedSword(stack, level >= 0 ? soulDrop[level] : 0);
setAttackSpeedOfSword(stack, level >= 0 ? getAttackSpeed(type, level) : baseAttackSpeed);
setHealthBonusOfSword(stack, level >= 0 ? getHealthBonus(type, level) : 0);
setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0);
setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0);
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class RitualSpeed method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
double destructiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DESTRUCTIVE, willConfig);
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
AreaDescriptor speedRange = getBlockRange(SPEED_RANGE);
double vengefulDrain = 0;
double destructiveDrain = 0;
double rawDrain = 0;
if (rawWill < rawWillDrain) {
// Simplifies later calculations
rawWill = 0;
}
for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, speedRange.getAABB(masterRitualStone.getBlockPos()))) {
if (entity.isSneaking())
continue;
boolean transportChildren = destructiveWill < destructiveWillDrain;
boolean transportAdults = vengefulWill < vengefulWillDrain;
if ((entity.isChild() && !transportChildren) || (!entity.isChild() && !transportAdults)) {
continue;
}
if (entity instanceof EntityPlayer && (transportChildren ^ transportAdults)) {
continue;
}
if (!transportChildren) {
destructiveWill -= destructiveWillDrain;
destructiveDrain += destructiveWillDrain;
}
if (!transportAdults) {
vengefulWill -= vengefulWillDrain;
vengefulDrain += vengefulWillDrain;
}
double motionY = getVerticalSpeedForWill(rawWill);
double speed = getHorizontalSpeedForWill(rawWill);
EnumFacing direction = masterRitualStone.getDirection();
if (rawWill >= rawWillDrain) {
rawWill -= rawWillDrain;
rawDrain += rawWillDrain;
}
entity.motionY = motionY;
entity.fallDistance = 0;
switch(direction) {
case NORTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = -speed;
break;
case SOUTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = speed;
break;
case WEST:
entity.motionX = -speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
case EAST:
entity.motionX = speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
default:
break;
}
if (entity instanceof EntityPlayer) {
Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ);
}
}
if (rawDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true);
}
if (vengefulDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true);
}
if (destructiveDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true);
}
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class RitualRegeneration method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
int totalCost = 0;
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
double destructiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DESTRUCTIVE, willConfig);
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
double vengefulDrain = 0;
double steadfastDrain = 0;
double destructiveDrain = 0;
double corrosiveDrain = 0;
boolean syphonHealth = corrosiveWill >= corrosiveWillDrain;
boolean applyAbsorption = false;
float absorptionRate = 1;
int maxAbsorption = 20;
AreaDescriptor healArea = getBlockRange(HEAL_RANGE);
AxisAlignedBB healRange = healArea.getAABB(pos);
AreaDescriptor damageArea = getBlockRange(VAMPIRE_RANGE);
AxisAlignedBB damageRange = damageArea.getAABB(pos);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, healRange);
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, healRange);
List<EntityLivingBase> damagedEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, damageRange);
if (syphonHealth) {
for (EntityPlayer player : players) {
if (player.getHealth() <= player.getMaxHealth() - 1) {
float syphonedHealthAmount = getSyphonAmountForWill(corrosiveWill);
Collections.shuffle(damagedEntities);
for (EntityLivingBase damagedEntity : damagedEntities) {
if (damagedEntity instanceof EntityPlayer) {
continue;
}
float currentHealth = damagedEntity.getHealth();
damagedEntity.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, Math.min(player.getMaxHealth() - player.getHealth(), syphonedHealthAmount));
float healthDifference = currentHealth - damagedEntity.getHealth();
if (healthDifference > 0) {
corrosiveDrain += corrosiveWillDrain;
corrosiveWill -= corrosiveWillDrain;
player.heal(healthDifference);
}
break;
}
}
}
}
for (EntityLivingBase entity : entities) {
float health = entity.getHealth();
if (health <= entity.getMaxHealth() - 1) {
if (entity.isPotionApplicable(new PotionEffect(MobEffects.REGENERATION))) {
if (entity instanceof EntityPlayer) {
totalCost += getRefreshCost();
currentEssence -= getRefreshCost();
} else {
totalCost += getRefreshCost() / 10;
currentEssence -= getRefreshCost() / 10;
}
entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 50, 0, false, false));
totalEffects++;
if (totalEffects >= maxEffects) {
break;
}
}
}
if (applyAbsorption && entity instanceof EntityPlayer) {
if (applyAbsorption) {
float added = Utils.addAbsorptionToMaximum(entity, absorptionRate, maxAbsorption, 1000);
}
}
}
if (corrosiveDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
}
masterRitualStone.getOwnerNetwork().syphon(totalCost);
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class InversionPillarHandler method onPillarAdded.
// Assume that it has been added already.
private static void onPillarAdded(World world, EnumDemonWillType type, BlockPos pos) {
BMLog.DEBUG.info("Adding...");
List<BlockPos> closePosList = new ArrayList<>();
int dim = world.provider.getDimension();
if (pillarMap.containsKey(dim)) {
Map<EnumDemonWillType, List<BlockPos>> willMap = pillarMap.get(dim);
if (willMap.containsKey(type)) {
List<BlockPos> otherPosList = willMap.get(type);
for (BlockPos closePos : otherPosList) {
if (!closePos.equals(pos) && closePos.distanceSq(pos) <= farthestDistanceSquared) {
closePosList.add(closePos);
}
}
}
}
if (nearPillarMap.containsKey(dim)) {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = nearPillarMap.get(dim);
if (willMap.containsKey(type)) {
Map<BlockPos, List<BlockPos>> posMap = willMap.get(type);
for (BlockPos closePos : closePosList) {
List<BlockPos> posList = posMap.get(closePos);
if (posList != null && !posList.contains(pos)) {
posList.add(pos);
} else {
posList = new ArrayList<>();
posList.add(pos);
posMap.put(closePos, posList);
}
}
posMap.put(pos, closePosList);
} else {
Map<BlockPos, List<BlockPos>> posMap = new HashMap<>();
posMap.put(pos, closePosList);
willMap.put(type, posMap);
}
} else {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = new HashMap<>();
Map<BlockPos, List<BlockPos>> posMap = new HashMap<>();
posMap.put(pos, closePosList);
willMap.put(type, posMap);
nearPillarMap.put(dim, willMap);
}
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSentientSword method spawnSentientEntityOnDrop.
@Override
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
World world = player.getEntityWorld();
if (!world.isRemote) {
this.recalculatePowers(droppedStack, world, player);
EnumDemonWillType type = this.getCurrentType(droppedStack);
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
if (soulsRemaining < 1024) {
return false;
}
PlayerDemonWillHandler.consumeDemonWill(type, player, 100);
EntitySentientSpecter specterEntity = new EntitySentientSpecter(world);
specterEntity.setPosition(player.posX, player.posY, player.posZ);
world.spawnEntity(specterEntity);
specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy());
specterEntity.setType(this.getCurrentType(droppedStack));
specterEntity.setOwner(player);
specterEntity.setTamed(true);
return true;
}
return false;
}
Aggregations