Search in sources :

Example 1 with EntityMeteor

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);
        }
    }
}
Also used : Meteor(WayofTime.bloodmagic.meteor.Meteor) EntityMeteor(WayofTime.bloodmagic.entity.projectile.EntityMeteor) EntityMeteor(WayofTime.bloodmagic.entity.projectile.EntityMeteor) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityMeteor (WayofTime.bloodmagic.entity.projectile.EntityMeteor)1 Meteor (WayofTime.bloodmagic.meteor.Meteor)1 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1