Search in sources :

Example 51 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType 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;
}
Also used : DemonWillHolder(WayofTime.bloodmagic.soul.DemonWillHolder) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 52 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class InversionPillarHandler method onPillarRemoved.

private static void onPillarRemoved(World world, EnumDemonWillType type, BlockPos pos) {
    BMLog.DEBUG.info("Removing...");
    int dim = world.provider.getDimension();
    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);
            List<BlockPos> posList = posMap.get(pos);
            if (posList != null) {
                for (BlockPos checkPos : posList) {
                    List<BlockPos> checkPosList = posMap.get(checkPos);
                    if (checkPosList != null) {
                        checkPosList.remove(pos);
                    }
                }
                posMap.remove(pos);
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 53 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class InversionPillarHandler method getAllConnectedPillars.

public static List<BlockPos> getAllConnectedPillars(World world, EnumDemonWillType type, BlockPos pos) {
    List<BlockPos> checkedPosList = new ArrayList<>();
    // Positions where we did not check their connections.
    List<BlockPos> uncheckedPosList = new ArrayList<>();
    uncheckedPosList.add(pos);
    int dim = world.provider.getDimension();
    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);
            while (!uncheckedPosList.isEmpty()) {
                // Positions that are new this iteration and need to be dumped into uncheckedPosList next iteration.
                List<BlockPos> newPosList = new ArrayList<>();
                for (BlockPos checkPos : uncheckedPosList) {
                    List<BlockPos> posList = posMap.get(checkPos);
                    if (posList != null) {
                        for (BlockPos testPos : posList) {
                            // Check if the position has already been checked, is scheduled to be checked, or is already found it needs to be checked.
                            if (!checkedPosList.contains(testPos) && !uncheckedPosList.contains(testPos) && !newPosList.contains(testPos)) {
                                newPosList.add(testPos);
                            }
                        }
                    }
                }
                checkedPosList.addAll(uncheckedPosList);
                uncheckedPosList = newPosList;
            }
        }
    }
    return checkedPosList;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 54 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class ItemSentientPickaxe 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);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 55 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class ItemSentientBow method getArrowEntity.

public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) {
    EnumDemonWillType type = this.getCurrentType(stack);
    double amount = user instanceof EntityPlayer ? (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)) : 0;
    float newArrowVelocity = velocity * getVelocityOfArrow(stack);
    double soulsRemaining = user instanceof EntityPlayer ? (PlayerDemonWillHandler.getTotalDemonWill(type, (EntityPlayer) user)) : 0;
    EntitySentientArrow entityArrow = new EntitySentientArrow(world, user, type, amount, getLevel(soulsRemaining));
    double d0 = target.posX - user.posX;
    double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityArrow.posY;
    double d2 = target.posZ - user.posZ;
    double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
    entityArrow.shoot(d0, d1 + d3 * 0.05, d2, newArrowVelocity, 0);
    if (newArrowVelocity == 0) {
        world.playSound(null, user.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F);
        return null;
    }
    if (velocity == 1.0F) {
        entityArrow.setIsCritical(true);
    }
    int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
    entityArrow.setDamage(entityArrow.getDamage() + this.getDamageAdded(stack) + (j > 0 ? j * 0.5 + 0.5 : 0));
    int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
    if (k > 0) {
        entityArrow.setKnockbackStrength(k);
    }
    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
        entityArrow.setFire(100);
    }
    entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
    return entityArrow;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySentientArrow(WayofTime.bloodmagic.entity.projectile.EntitySentientArrow) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Aggregations

EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)65 ItemStack (net.minecraft.item.ItemStack)21 BlockPos (net.minecraft.util.math.BlockPos)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 World (net.minecraft.world.World)13 PotionEffect (net.minecraft.potion.PotionEffect)6 TileEntity (net.minecraft.tileentity.TileEntity)6 EntitySentientSpecter (WayofTime.bloodmagic.entity.mob.EntitySentientSpecter)5 IDemonWill (WayofTime.bloodmagic.soul.IDemonWill)5 IBlockState (net.minecraft.block.state.IBlockState)5 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 ISentientSwordEffectProvider (WayofTime.bloodmagic.iface.ISentientSwordEffectProvider)4 DemonWillHolder (WayofTime.bloodmagic.soul.DemonWillHolder)4 EntitySlime (net.minecraft.entity.monster.EntitySlime)4 IMob (net.minecraft.entity.monster.IMob)4 ArrayList (java.util.ArrayList)3 EntitySentientArrow (WayofTime.bloodmagic.entity.projectile.EntitySentientArrow)2 IDiscreteDemonWill (WayofTime.bloodmagic.soul.IDiscreteDemonWill)2 List (java.util.List)2