Search in sources :

Example 11 with SoulNetwork

use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.

the class BlockAltar method getComparatorInputOverride.

@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
    if (world.isRemote)
        return 0;
    TileEntity tile = world.getTileEntity(pos);
    if (tile != null && tile instanceof TileAltar) {
        TileAltar altar = (TileAltar) tile;
        ItemStack orbStack = altar.getStackInSlot(0);
        if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) {
            if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) {
                BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
                Binding binding = ((IBindable) orbStack.getItem()).getBinding(orbStack);
                if (orb != null && binding != null) {
                    SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(binding);
                    int maxEssence = orb.getCapacity();
                    int currentEssence = soulNetwork.getCurrentEssence();
                    int level = currentEssence * 15 / maxEssence;
                    return Math.min(15, level) % 16;
                }
            }
        } else {
            int maxEssence = altar.getCapacity();
            int currentEssence = altar.getCurrentBlood();
            int level = currentEssence * 15 / maxEssence;
            return Math.min(15, level) % 16;
        }
    }
    return 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Binding(WayofTime.bloodmagic.core.data.Binding) IBindable(WayofTime.bloodmagic.iface.IBindable) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) ItemStack(net.minecraft.item.ItemStack) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Aggregations

SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)11 Binding (WayofTime.bloodmagic.core.data.Binding)6 ItemStack (net.minecraft.item.ItemStack)6 IBindable (WayofTime.bloodmagic.iface.IBindable)5 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)4 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 EntityBloodLight (WayofTime.bloodmagic.entity.projectile.EntityBloodLight)1 ItemBindEvent (WayofTime.bloodmagic.event.ItemBindEvent)1 RitualEvent (WayofTime.bloodmagic.event.RitualEvent)1 SoulNetworkEvent (WayofTime.bloodmagic.event.SoulNetworkEvent)1 ItemActivationCrystal (WayofTime.bloodmagic.item.ItemActivationCrystal)1 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)1 TileAltar (WayofTime.bloodmagic.tile.TileAltar)1 PlayerNotFoundException (net.minecraft.command.PlayerNotFoundException)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TextComponentString (net.minecraft.util.text.TextComponentString)1