Search in sources :

Example 21 with Binding

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

the class ItemSigilToggleable method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    Binding binding = getBinding(stack);
    if (// Make sure Sigils are bound before handling. Also ignores while toggling state
    binding == null || player.isSneaking())
        return EnumActionResult.PASS;
    return (NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) ItemStack(net.minecraft.item.ItemStack)

Example 22 with Binding

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

the class ItemSigilDivination method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    if (PlayerHelper.isFakePlayer(player))
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    if (!world.isRemote) {
        super.onItemRightClick(world, player, hand);
        Binding binding = getBinding(stack);
        if (binding != null) {
            int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
            List<ITextComponent> toSend = Lists.newArrayList();
            if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
                toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", binding.getOwnerName()));
            toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
            ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack)

Example 23 with Binding

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

the class ItemSigilToggleableBase method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    super.addInformation(stack, world, tooltip, flag);
    if (!stack.hasTagCompound())
        return;
    tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic." + (getActivated(stack) ? "activated" : "deactivated")));
    Binding binding = getBinding(stack);
    if (binding != null)
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Binding (WayofTime.bloodmagic.core.data.Binding)23 ItemStack (net.minecraft.item.ItemStack)11 IBindable (WayofTime.bloodmagic.iface.IBindable)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)6 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)4 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 BlockPos (net.minecraft.util.math.BlockPos)4 TileEntity (net.minecraft.tileentity.TileEntity)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 World (net.minecraft.world.World)3 TileAltar (WayofTime.bloodmagic.tile.TileAltar)2 BloodMagicCraftedEvent (WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent)1 RecipeBloodAltar (WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar)1 BlockTeleposer (WayofTime.bloodmagic.block.BlockTeleposer)1 ItemBindEvent (WayofTime.bloodmagic.event.ItemBindEvent)1 RitualEvent (WayofTime.bloodmagic.event.RitualEvent)1 SoulNetworkEvent (WayofTime.bloodmagic.event.SoulNetworkEvent)1 TeleposeEvent (WayofTime.bloodmagic.event.TeleposeEvent)1