use of WayofTime.bloodmagic.entity.projectile.EntityMeteor in project BloodMagic by WayofTime.
the class RitualMeteor method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
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 itemDetectionRange = getBlockRange(ITEM_RANGE);
List<EntityItem> itemList = world.getEntitiesWithinAABB(EntityItem.class, itemDetectionRange.getAABB(pos));
double radiusModifier = getRadiusModifier(rawWill);
double explosionModifier = getExplosionModifier(steadfastWill);
double fillerChance = getFillerChance(corrosiveWill);
boolean successful = false;
for (EntityItem entityItem : itemList) {
ItemStack stack = entityItem.getItem();
Meteor meteor = MeteorRegistry.getMeteorForItem(stack);
if (meteor != null) {
EntityMeteor entityMeteor = new EntityMeteor(world, pos.getX(), 260, pos.getZ(), 0, -0.1, 0, radiusModifier, explosionModifier, fillerChance);
entityMeteor.setMeteorStack(stack.copy());
world.spawnEntity(entityMeteor);
entityItem.setDead();
if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) {
masterRitualStone.getOwnerNetwork().syphon(1000000);
} else {
masterRitualStone.setActive(false);
}
successful = true;
break;
}
}
if (successful) {
if (rawWill > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWill, true);
}
if (corrosiveWill > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveWill, true);
}
if (steadfastWill > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastWill, true);
}
}
}
Aggregations