Search in sources :

Example 1 with Binding

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

the class SubCommandBind method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    if (commandSender.getEntityWorld().isRemote)
        return;
    try {
        EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender);
        ItemStack held = player.getHeldItemMainhand();
        boolean bind = true;
        if (held.getItem() instanceof IBindable) {
            if (args.length > 0) {
                if (args[0].equalsIgnoreCase("help"))
                    return;
                if (isBoolean(args[0])) {
                    bind = Boolean.parseBoolean(args[0]);
                    if (args.length > 2)
                        player = CommandBase.getPlayer(server, commandSender, args[1]);
                } else {
                    player = CommandBase.getPlayer(server, commandSender, args[0]);
                }
            }
            if (bind) {
                Binding binding = new Binding(player.getGameProfile().getId(), player.getGameProfile().getName());
                BindableHelper.applyBinding(held, binding);
                commandSender.sendMessage(new TextComponentTranslation("commands.bind.success"));
            } else {
                Binding binding = ((IBindable) held.getItem()).getBinding(held);
                if (binding != null) {
                    held.getTagCompound().removeTag("binding");
                    commandSender.sendMessage(new TextComponentTranslation("commands.bind.remove.success"));
                }
            }
        }
    } catch (PlayerNotFoundException e) {
        commandSender.sendMessage(new TextComponentTranslation(TextHelper.localizeEffect("commands.error.404")));
    }
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBindable(WayofTime.bloodmagic.iface.IBindable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException) ItemStack(net.minecraft.item.ItemStack)

Example 2 with Binding

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

the class ItemBloodOrb method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    BloodOrb orb = getOrb(stack);
    if (orb == null)
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    if (world == null)
        return super.onItemRightClick(world, player, hand);
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
    if (PlayerHelper.isFakePlayer(player))
        return super.onItemRightClick(world, player, hand);
    if (!stack.hasTagCompound())
        return super.onItemRightClick(world, player, hand);
    Binding binding = getBinding(stack);
    if (binding == null)
        return super.onItemRightClick(world, player, hand);
    if (world.isRemote)
        return super.onItemRightClick(world, player, hand);
    SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
    if (binding.getOwnerId().equals(player.getGameProfile().getId()))
        ownerNetwork.setOrbTier(orb.getTier());
    // Add LP to owner's network
    ownerNetwork.add(200, orb.getCapacity());
    // Hurt whoever is using it
    ownerNetwork.hurtPlayer(player, 200);
    return super.onItemRightClick(world, player, hand);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) ItemStack(net.minecraft.item.ItemStack)

Example 3 with Binding

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

the class ItemBoundTool method addInformation.

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

Example 4 with Binding

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

the class ItemBoundTool method onUpdate.

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
    Binding binding = getBinding(stack);
    if (binding == null) {
        setActivatedState(stack, false);
        return;
    }
    if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack()) {
        EntityPlayer player = (EntityPlayer) entity;
        setHeldDownCount(stack, Math.min(player.getItemInUseCount(), chargeTime));
    } else if (!isSelected) {
        setBeingHeldDown(stack, false);
    }
    if (entity instanceof EntityPlayer && getActivated(stack) && world.getTotalWorldTime() % 80 == 0)
        NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entity, 20);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 5 with Binding

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

the class ItemInscriptionTool method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.inscriber.desc"))));
    if (!stack.hasTagCompound())
        return;
    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