Search in sources :

Example 1 with TileDemonCrystal

use of WayofTime.bloodmagic.tile.TileDemonCrystal in project BloodMagic by WayofTime.

the class BlockDemonCrystal method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileDemonCrystal) {
        EnumDemonWillType type = state.getValue(TYPE);
        int number = ((TileDemonCrystal) tile).getCrystalCount();
        spawnAsEntity(world, pos, getItemStackDropped(type, number));
        world.removeTileEntity(pos);
    }
    super.breakBlock(world, pos, state);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) TileDemonCrystal(WayofTime.bloodmagic.tile.TileDemonCrystal)

Example 2 with TileDemonCrystal

use of WayofTime.bloodmagic.tile.TileDemonCrystal in project BloodMagic by WayofTime.

the class RitualCrystalHarvest method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    BlockPos pos = masterRitualStone.getBlockPos();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    int maxEffects = 1;
    int totalEffects = 0;
    AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE);
    crystalRange.resetIterator();
    while (crystalRange.hasNext()) {
        BlockPos nextPos = crystalRange.next().add(pos);
        TileEntity tile = world.getTileEntity(nextPos);
        if (tile instanceof TileDemonCrystal) {
            TileDemonCrystal demonCrystal = (TileDemonCrystal) tile;
            if (demonCrystal.dropSingleCrystal()) {
                IBlockState state = world.getBlockState(nextPos);
                world.notifyBlockUpdate(nextPos, state, state, 3);
                totalEffects++;
                if (totalEffects >= maxEffects) {
                    break;
                }
            }
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileDemonCrystal(WayofTime.bloodmagic.tile.TileDemonCrystal)

Example 3 with TileDemonCrystal

use of WayofTime.bloodmagic.tile.TileDemonCrystal in project BloodMagic by WayofTime.

the class RitualForsakenSoul method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    BlockPos pos = masterRitualStone.getBlockPos();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    int maxEffects = 100;
    int totalEffects = 0;
    List<TileDemonCrystal> crystalList = new ArrayList<>();
    AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE);
    crystalRange.resetIterator();
    while (crystalRange.hasNext()) {
        BlockPos nextPos = crystalRange.next().add(pos);
        TileEntity tile = world.getTileEntity(nextPos);
        if (tile instanceof TileDemonCrystal) {
            crystalList.add((TileDemonCrystal) tile);
        }
    }
    AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE);
    AxisAlignedBB range = damageRange.getAABB(pos);
    List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range);
    for (EntityLivingBase entity : entities) {
        EntityEntry entityEntry = EntityRegistry.getEntry(entity.getClass());
        if (entityEntry == null || BloodMagicAPI.INSTANCE.getBlacklist().getSacrifice().contains(entityEntry.getRegistryName()))
            continue;
        if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) {
            if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) {
                if (!entity.isEntityAlive()) {
                    int uniqueness = calculateUniqueness(entity);
                    double modifier = 1;
                    if (entity instanceof EntityAnimal && !((EntityAnimal) entity).collided) {
                        modifier = 4;
                    }
                    willBuffer += modifier * getWillForUniqueness(uniqueness) / HEALTH_THRESHOLD * entity.getMaxHealth();
                    crystalBuffer += modifier * entity.getMaxHealth() / HEALTH_THRESHOLD;
                    totalEffects++;
                    if (totalEffects >= maxEffects) {
                        break;
                    }
                }
            }
        }
    }
    if (crystalList.size() > 0 && crystalBuffer > 0) {
        double growth = Math.min(crystalBuffer, 1);
        double willSyphonAmount = growth * willBuffer / crystalBuffer;
        TileDemonCrystal chosenCrystal = crystalList.get(world.rand.nextInt(crystalList.size()));
        double percentageGrowth = chosenCrystal.growCrystalWithWillAmount(growth * willBuffer / crystalBuffer, growth);
        if (percentageGrowth > 0) {
            crystalBuffer -= percentageGrowth;
            willBuffer -= percentageGrowth * willSyphonAmount;
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ArrayList(java.util.ArrayList) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) EntityEntry(net.minecraftforge.fml.common.registry.EntityEntry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) TileDemonCrystal(WayofTime.bloodmagic.tile.TileDemonCrystal)

Example 4 with TileDemonCrystal

use of WayofTime.bloodmagic.tile.TileDemonCrystal in project BloodMagic by WayofTime.

the class BlockDemonCrystal method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    }
    TileDemonCrystal crystal = (TileDemonCrystal) world.getTileEntity(pos);
    if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024) {
        crystal.dropSingleCrystal();
        world.notifyBlockUpdate(pos, state, state, 3);
    }
    return true;
}
Also used : TileDemonCrystal(WayofTime.bloodmagic.tile.TileDemonCrystal)

Example 5 with TileDemonCrystal

use of WayofTime.bloodmagic.tile.TileDemonCrystal in project BloodMagic by WayofTime.

the class BlockDemonCrystal method neighborChanged.

@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
    TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos);
    EnumFacing placement = tile.getPlacement();
    BlockPos offsetPos = pos.offset(placement.getOpposite());
    IBlockState offsetState = world.getBlockState(offsetPos);
    Block offsetBlock = offsetState.getBlock();
    if (!offsetBlock.isSideSolid(offsetState, world, offsetPos, placement)) {
        world.setBlockToAir(pos);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) TileDemonCrystal(WayofTime.bloodmagic.tile.TileDemonCrystal)

Aggregations

TileDemonCrystal (WayofTime.bloodmagic.tile.TileDemonCrystal)5 TileEntity (net.minecraft.tileentity.TileEntity)3 BlockPos (net.minecraft.util.math.BlockPos)3 IBlockState (net.minecraft.block.state.IBlockState)2 World (net.minecraft.world.World)2 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 ArrayList (java.util.ArrayList)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 EntityEntry (net.minecraftforge.fml.common.registry.EntityEntry)1