Search in sources :

Example 36 with EnumDemonWillType

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

the class TileDemonCrystal method dropSingleCrystal.

public boolean dropSingleCrystal() {
    if (!getWorld().isRemote && crystalCount > 1) {
        IBlockState state = getWorld().getBlockState(pos);
        EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE);
        ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1);
        if (stack != null) {
            crystalCount--;
            getWorld().spawnEntity(new EntityItem(getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack));
            return true;
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 37 with EnumDemonWillType

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

the class TileDemonCrystal method onUpdate.

@Override
public void onUpdate() {
    if (getWorld().isRemote) {
        return;
    }
    internalCounter++;
    if (internalCounter % 20 == 0 && crystalCount < 7) {
        EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()];
        double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
        if (type != EnumDemonWillType.DEFAULT) {
            if (value >= 100) {
                double nextProgress = getCrystalGrowthPerSecond(value);
                progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate;
            } else {
                value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT);
                if (value > 0.5) {
                    double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill;
                    progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate;
                }
            }
        } else {
            if (value > 0.5) {
                double nextProgress = getCrystalGrowthPerSecond(value);
                progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate;
            }
        }
        checkAndGrowCrystal();
    }
// if (getWorld().getWorldTime() % 200 == 0)
// {
// crystalCount = Math.min(crystalCount + 1, 7);
// getWorld().markBlockForUpdate(pos);
// }
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 38 with EnumDemonWillType

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

the class ItemRitualReader method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        EnumRitualReaderState state = this.getState(stack);
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof IMasterRitualStone) {
            IMasterRitualStone master = (IMasterRitualStone) tile;
            this.setMasterBlockPos(stack, pos);
            this.setBlockPos(stack, BlockPos.ORIGIN);
            switch(state) {
                case INFORMATION:
                    master.provideInformationOfRitualToPlayer(player);
                    break;
                case SET_AREA:
                    String range = this.getCurrentBlockRange(stack);
                    if (player.isSneaking()) {
                        String newRange = master.getNextBlockRange(range);
                        range = newRange;
                        this.setCurrentBlockRange(stack, newRange);
                    }
                    master.provideInformationOfRangeToPlayer(player, range);
                    break;
                case SET_WILL_TYPES:
                    List<EnumDemonWillType> typeList = new ArrayList<>();
                    NonNullList<ItemStack> inv = player.inventory.mainInventory;
                    for (int i = 0; i < 9; i++) {
                        ItemStack testStack = inv.get(i);
                        if (testStack.isEmpty()) {
                            continue;
                        }
                        if (testStack.getItem() instanceof IDiscreteDemonWill) {
                            EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack);
                            if (!typeList.contains(type)) {
                                typeList.add(type);
                            }
                        }
                    }
                    master.setActiveWillConfig(player, typeList);
                    master.provideInformationOfWillConfigToPlayer(player, typeList);
                    break;
            }
            return EnumActionResult.FAIL;
        } else {
            if (state == EnumRitualReaderState.SET_AREA) {
                BlockPos masterPos = this.getMasterBlockPos(stack);
                if (!masterPos.equals(BlockPos.ORIGIN)) {
                    BlockPos containedPos = getBlockPos(stack);
                    if (containedPos.equals(BlockPos.ORIGIN)) {
                        this.setBlockPos(stack, pos.subtract(masterPos));
                        player.sendStatusMessage(new TextComponentTranslation("ritual.bloodmagic.blockRange.firstBlock"), true);
                    // TODO: Notify player.
                    } else {
                        tile = world.getTileEntity(masterPos);
                        if (tile instanceof IMasterRitualStone) {
                            IMasterRitualStone master = (IMasterRitualStone) tile;
                            master.setBlockRangeByBounds(player, this.getCurrentBlockRange(stack), containedPos, pos.subtract(masterPos));
                        }
                        this.setBlockPos(stack, BlockPos.ORIGIN);
                    }
                }
            }
        }
    }
    return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IDiscreteDemonWill(WayofTime.bloodmagic.soul.IDiscreteDemonWill) EnumRitualReaderState(WayofTime.bloodmagic.ritual.EnumRitualReaderState) ArrayList(java.util.ArrayList) TileEntity(net.minecraft.tileentity.TileEntity) IMasterRitualStone(WayofTime.bloodmagic.ritual.IMasterRitualStone) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 39 with EnumDemonWillType

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

the class ItemSentientAxe method getRandomDemonWillDrop.

@Override
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
    List<ItemStack> soulList = new ArrayList<>();
    if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
        return soulList;
    }
    double willModifier = killedEntity instanceof EntitySlime ? 0.67 : 1;
    IDemonWill soul = ((IDemonWill) RegistrarBloodMagicItems.MONSTER_SOUL);
    EnumDemonWillType type = this.getCurrentType(stack);
    for (int i = 0; i <= looting; i++) {
        if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
            ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
            soulList.add(soulStack);
        }
    }
    return soulList;
}
Also used : IMob(net.minecraft.entity.monster.IMob) EntitySlime(net.minecraft.entity.monster.EntitySlime) IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 40 with EnumDemonWillType

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

the class ItemSentientAxe method onLeftClickEntity.

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    recalculatePowers(stack, player.getEntityWorld(), player);
    double drain = this.getDrainOfActivatedSword(stack);
    if (drain > 0) {
        EnumDemonWillType type = getCurrentType(stack);
        double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
        if (drain > soulsRemaining) {
            return false;
        } else {
            PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
        }
    }
    return super.onLeftClickEntity(stack, player, entity);
}
Also used : 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