Java Code Examples for baubles.api.BaublesApi#getBaubles()

The following examples show how to use baubles.api.BaublesApi#getBaubles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void equipTick(World world, EntityPlayer player, Aspect aspect) {
    if(world.isRemote) return;

    FamiliarData data = new FamiliarData(player.getCommandSenderName(), aspect.getTag());

    IInventory baublesInv = BaublesApi.getBaubles(player);
    if(baublesInv.getStackInSlot(0) == null) {
        handleUnequip(world, player, aspect);
        return;
    }

    if(familiarControllers.get(player) == null || !playersWithFamiliar.contains(data)) {
        handleEquip(world, player, aspect);
    }

    familiarControllers.get(player).tick();
}
 
Example 2
Source File: DataFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkPlayerEquipment(EntityPlayer p) {
    IInventory baublesInv = BaublesApi.getBaubles(p);
    if(baublesInv.getStackInSlot(0) != null) {
        ItemStack amulet = baublesInv.getStackInSlot(0);
        if(amulet.getItem() != null && amulet.getItem() instanceof ItemEtherealFamiliar) {
            Aspect a = ItemEtherealFamiliar.getFamiliarAspect(amulet);
            if(a != null) {
                handleEquip(p.worldObj, p, a);
            }
        }
    }
}
 
Example 3
Source File: ItemSubCollar.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof EntityPlayer)
    {
        EntityPlayer sub = (EntityPlayer)entity;
        IInventory baubles = BaublesApi.getBaubles(sub);
        if(baubles.getStackInSlot(0) == null) {
            if(!itemstack.hasTagCompound()){
                NBTTagCompound tag = new NBTTagCompound();
                itemstack.setTagCompound(tag);
            }
            itemstack.stackTagCompound.setString("owner", player.getDisplayName());
            baubles.setInventorySlotContents(0, itemstack.copy());
            itemstack.stackSize = 0;
            sub.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.placescollar").replace("%s", player.getDisplayName())));
            player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.youplacecollar").replace("%s", sub.getDisplayName())));
            return true;
        }
        else
            player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.alreadywearing").replace("%s", sub.getDisplayName())));
    }
    return false;
}
 
Example 4
Source File: FamiliarController.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void tick() {
    IInventory baubles = BaublesApi.getBaubles(owningPlayer);
    ItemStack stack = baubles.getStackInSlot(0);
    if (stack == null || !(stack.getItem() instanceof ItemEtherealFamiliar)) return;

    if (tickLastEffect > 0) {
        tickLastEffect--;
        return;
    }

    FamiliarAugment.FamiliarAugmentList augments = ItemEtherealFamiliar.getAugments(stack);
    if (augments == null) return;

    if (augments.isEmpty()) {
        doDefaultAttack();
        tickLastEffect = AS_DELAY_DEF;
    } else {
        FamiliarAugment.FamiliarAugmentPair effectElement = null;
        for (FamiliarAugment.FamiliarAugmentPair pair : augments) {
            FamiliarAugment augment = pair.augment;
            if (augment.equals(FamiliarAugment.SHOCK) || augment.equals(FamiliarAugment.FIRE)
                    || augment.equals(FamiliarAugment.POISON) || augment.equals(FamiliarAugment.WEAKNESS)) {
                effectElement = pair;
                break;
            }
        }

        AspectList costs = new AspectList();

        int dmgLevel = augments.getLevel(FamiliarAugment.DAMAGE_INCREASE);
        if (dmgLevel > 0) {
            for (int i = 0; i < dmgLevel; i++) {
                costs.add(FamiliarAugment.DAMAGE_INCREASE.getCostsPerLevel());
            }
        }

        int attackSpeedLevel = augments.getLevel(FamiliarAugment.ATTACK_SPEED);
        if (attackSpeedLevel > 0) {
            for (int i = 0; i < attackSpeedLevel; i++) {
                costs.add(FamiliarAugment.ATTACK_SPEED.getCostsPerLevel());
            }
        }

        int rangeLevel = augments.getLevel(FamiliarAugment.RANGE_INCREASE);
        if (rangeLevel > 0) {
            for (int i = 0; i < rangeLevel; i++) {
                costs.add(FamiliarAugment.RANGE_INCREASE.getCostsPerLevel());
            }
        }

        double damage = DMG_DEF + (dmgLevel != -1 ? DMG_INC * dmgLevel : 0);
        int ticksUntilNextAttack = AS_DELAY_DEF - (attackSpeedLevel != -1 ? AS_INC * attackSpeedLevel : 0);
        double range = RANGE_DEF + (rangeLevel != -1 ? RANGE_INC * rangeLevel : 0);
        
        if(effectElement != null) {
            for (int i = 0; i < effectElement.level; i++) {
                costs.add(effectElement.augment.getCostsPerLevel());
            }
        }

        if (!owningPlayer.capabilities.isCreativeMode && !consumeVisFromInventory(owningPlayer, costs, false)) {
            return;
        }

        if (effectElement == null) {
            if (doEnhancedDefaultAttack(damage, range)) {
                tickLastEffect = ticksUntilNextAttack;
                if(!owningPlayer.capabilities.isCreativeMode && RAND.nextInt(3) == 0) {
                    consumeVisFromInventory(owningPlayer, costs, true);
                }
            }
        } else {
            if (doAttack(effectElement, damage, range)) {
                tickLastEffect = ticksUntilNextAttack;
                if(!owningPlayer.capabilities.isCreativeMode && RAND.nextInt(3) == 0) {
                    consumeVisFromInventory(owningPlayer, costs, true);
                }
            }
        }
    }
}