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")));
}
}
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);
}
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);
}
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);
}
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()));
}
Aggregations