use of baubles.api.cap.IBaublesItemHandler in project SilentGems by SilentChaos512.
the class ItemChaosOrb method onWornTick.
@Override
@Optional.Method(modid = BaublesCompat.MOD_ID)
public void onWornTick(ItemStack stack, EntityLivingBase player) {
onUpdate(stack, player.world, player, 0, false);
// If broken, remove from bauble slot as the normal onUpdate doesn't check that.
int currentDamageLevel = (stack.getItemDamage() & 0xF0) >> 4;
if (currentDamageLevel >= getType(stack).crackStages) {
int[] slots = getBaubleType(stack).getValidSlots();
IBaublesItemHandler inventory = BaublesApi.getBaublesHandler((EntityPlayer) player);
for (int i = 0; i < slots.length; ++i) {
ItemStack inSlot = inventory.getStackInSlot(slots[i]);
if (inSlot == stack) {
inventory.extractItem(slots[i], 1, false);
break;
}
}
}
}
use of baubles.api.cap.IBaublesItemHandler in project Bookshelf by Darkhax-Minecraft.
the class BaubleUtils method equipBauble.
/**
* Equips a bauble in the desired slot if one does not already exist.
*
* @param player The player to give the ring to.
* @param item The item to set in the slot.
* @param slot The slot to place the bauble in. 0 is amulet, 1 and 2 are rings. 3 is belt.
* @return Whether or not the bauble was equipped.
*/
@Optional.Method(modid = "baubles")
public static boolean equipBauble(EntityPlayer player, ItemStack item, int slot) {
final IBaublesItemHandler inv = BaublesApi.getBaublesHandler(player);
if (inv != null) {
final ItemStack existing = inv.getStackInSlot(slot);
if (existing == null) {
inv.setStackInSlot(slot, item.copy());
item.shrink(1);
return true;
}
}
return false;
}
use of baubles.api.cap.IBaublesItemHandler in project Bookshelf by Darkhax-Minecraft.
the class BaubleUtils method getBaublesFromPlayer.
/**
* Gets all stacks of a specific type from the baubles inventory. Automatically called by
* PlayerUtils#getStacksFromPlayer.
*
* @param player The player to search.
* @param item The item to search for.
* @param meta The desired metadata for the item. If less than 0, any meta will work.
* @return The list of found items.
*/
@Optional.Method(modid = "baubles")
public static List<ItemStack> getBaublesFromPlayer(EntityPlayer player, Item item, int meta) {
final List<ItemStack> items = new ArrayList<>();
final IBaublesItemHandler inv = BaublesApi.getBaublesHandler(player);
for (int slot = 0; slot < BaubleType.TRINKET.getValidSlots().length; slot++) {
final ItemStack stack = inv.getStackInSlot(slot);
if (stack != null && stack.getItem() == item && (meta < 0 || stack.getMetadata() == meta)) {
items.add(stack);
}
}
return items;
}
use of baubles.api.cap.IBaublesItemHandler in project Pearcel-Mod by MiningMark48.
the class BaublesApi method getBaubles.
/**
* Retrieves the baubles capability handler wrapped as a IInventory for the supplied player
*/
@Deprecated
public static IInventory getBaubles(EntityPlayer player) {
IBaublesItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
handler.setPlayer(player);
return new BaublesInventoryWrapper(handler, player);
}
use of baubles.api.cap.IBaublesItemHandler in project Pearcel-Mod by MiningMark48.
the class BaublesApi method getBaublesHandler.
/**
* Retrieves the baubles inventory capability handler for the supplied player
*/
public static IBaublesItemHandler getBaublesHandler(EntityPlayer player) {
IBaublesItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
handler.setPlayer(player);
return handler;
}
Aggregations