baubles.api.BaublesApi Java Examples

The following examples show how to use baubles.api.BaublesApi. 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: FamiliarAIController_Old.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void scheduleTick() {
    reduceRunningCooldowns();
    if(runningTask == null) {
        selectNewTask();
    } else {
        ItemStack famStack = BaublesApi.getBaubles(owningPlayer).getStackInSlot(0);
        runningTask.tick(ticksInTask, owningPlayer.worldObj, owningPlayer, famStack);
        ticksInTask++;
        if(ticksInTask >= runningTask.getDuration()) {
            if(runningTask.getCooldownDuration(famStack) > 0) cooldownProcesses.put(runningTask, runningTask.getCooldownDuration(famStack));
            if(runningTask.tryLoop() && !requestedLoop.contains(runningTask)) requestedLoop.addLast(runningTask);
            runningTask = null;
            ticksInTask = 0;
        }
    }
}
 
Example #2
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 #3
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@SubscribeEvent
public void onEat(PlayerUseItemEvent.Finish event){
    if(event.entityPlayer.worldObj.isRemote)
        return;
    if(event.item.getItem() instanceof ItemFood){
        if(event.entityPlayer.worldObj.provider.dimensionId == -1 && event.item.getItem() != ForbiddenItems.gluttonyShard
                && randy.nextInt(10) < 2){
            EntityItem ent = event.entityPlayer.entityDropItem(new ItemStack(ForbiddenItems.gluttonyShard, 1), 1.0F);
            ent.motionY += randy.nextFloat() * 0.05F;
            ent.motionX += (randy.nextFloat() - randy.nextFloat()) * 0.1F;
            ent.motionZ += (randy.nextFloat() - randy.nextFloat()) * 0.1F;
        }
        ItemStack ring = BaublesApi.getBaubles(event.entityPlayer).getStackInSlot(1);
        ItemStack ring2 = BaublesApi.getBaubles(event.entityPlayer).getStackInSlot(2);
        if((ring != null && ring.getItem() == ForbiddenItems.ringFood) || (ring2 != null && ring2.getItem() == ForbiddenItems.ringFood)){
            event.entityPlayer.getFoodStats().addStats(2, 2.0F);
        }
    }
}
 
Example #4
Source File: BaublesSupport.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public Iterable<ItemStack> getBaublesFallbackArmor(EntityLivingBase entity) {
	if (!(entity instanceof EntityPlayer)) return entity.getArmorInventoryList();
	if (BaublesApi.getBaublesHandler((EntityPlayer) entity) == null) return entity.getArmorInventoryList();

	ImmutableList.Builder<ItemStack> stacks = ImmutableList.builder();
	IBaublesItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) entity);
	for (BaubleType type : BaubleType.values())
		for (int slot : type.getValidSlots()) {
			stacks.add(inv.getStackInSlot(slot));
		}
	return stacks.build();
}
 
Example #5
Source File: BaublesSupport.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public List<ItemStack> getBaublesOnly(EntityLivingBase entity) {
	if (!(entity instanceof EntityPlayer)) return new ArrayList<>();
	if (BaublesApi.getBaublesHandler((EntityPlayer) entity) == null) return new ArrayList<>();

	ImmutableList.Builder<ItemStack> stacks = ImmutableList.builder();
	IBaublesItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) entity);
	for (BaubleType type : BaubleType.values())
		for (int slot : type.getValidSlots()) {
			stacks.add(inv.getStackInSlot(slot));
		}
	return stacks.build();
}
 
Example #6
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 #7
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onFeelPain(LivingHurtEvent event){
    if(!Config.noLust && event.ammount > 0 && event.entityLiving instanceof EntityPlayer){
        EntityPlayer player = (EntityPlayer)event.entityLiving;
        ItemStack amulet = BaublesApi.getBaubles(player).getStackInSlot(0);
        if(amulet != null && amulet.getItem() == ForbiddenItems.subCollar){
            int doses = 3 * (int)event.ammount;
            if(event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
                EntityPlayer dom = (EntityPlayer)event.source.getEntity();
                int chance = 1;
                if(dom.getHeldItem() != null && dom.getHeldItem().getItem() instanceof ItemRidingCrop) {
                    doses += 3;
                    chance += 3;
                }
                if(player.worldObj.provider.dimensionId == -1 && randy.nextInt(30) < chance){
                    EntityItem ent = player.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
                    ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
                    ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
                    ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
                }
            }
            for(int x = 0;x < doses; x++){
                ((ItemSubCollar)ForbiddenItems.subCollar).addVis(amulet, primals[randy.nextInt(6)], 1, true);
            }
        }
    }
}
 
Example #8
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 #9
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);
                }
            }
        }
    }
}
 
Example #10
Source File: BaublesCompat.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public IItemHandler getBaublesInventory(EntityPlayer player)
{
    return BaublesApi.getBaublesHandler(player);
}