@Override @Optional.Method(modid = "baubles") public Iterable<ItemStack> get(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(); } }
@Override @Method(modid = "Baubles|API") public BaubleType getBaubleType(ItemStack itemstack) { BaubleType t = null; try { t = BaubleType.valueOf(ItemConfig.magnetBaublesType.get()); } catch (Exception e) { // NOP } return t != null ? t : BaubleType.AMULET; }
@Nullable @Optional.Method(modid = Baubles.MODID) public static TinySlot getBauble(@Nonnull EntityPlayer player) { IBaublesItemHandler handler = BaublesApi.getBaublesHandler(player); for (int slot : getBaubleType().getValidSlots()) { ItemStack stack = handler.getStackInSlot(slot); if (stack.getItem() == Registry.itemNeuralInterface) { return new TinySlot.BaublesSlot(stack, handler, slot); } } return null; }
@Override @Optional.Method(modid = "baubles") public baubles.api.BaubleType getBaubleType(ItemStack arg0) { try { if (baubles.api.BaubleType.values().length >= 4) { //length is 4 if trinket return baubles.api.BaubleType.TRINKET; } else { return baubles.api.BaubleType.RING; } } catch (Exception e) { return baubles.api.BaubleType.RING; } }
/** * Returns true if automation is allowed to insert the given stack (ignoring * stack size) into the given slot. */ @Override public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) { if (stack==null || stack.isEmpty() || !stack.hasCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null)) return false; IBauble bauble = stack.getCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null); return bauble.canEquip(stack, player) && bauble.getBaubleType(stack).hasSlot(slot); }
@Override @Optional.Method(modid = Baubles.MODID) public void onWornTick(ItemStack stack, EntityLivingBase player) { if (!(player instanceof EntityPlayer)) return; IBaublesItemHandler handler = BaublesApi.getBaublesHandler((EntityPlayer) player); for (int slot : NeuralHelpers.getBaubleType().getValidSlots()) { ItemStack slotStack = handler.getStackInSlot(slot); if (slotStack == stack) { onUpdate(stack, new TinySlot.BaublesSlot(stack, handler, slot), player, true); } } }
@Override @Nonnull public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { // Check if the entity we've just hit has a stack in the first slot. If so, use that instead. ItemStack stack = player.getHeldItem(hand); RayTraceResult hit = PlayerHelpers.findHitGuess(player); Entity entity = hit.entityHit; if (hit.typeOfHit == RayTraceResult.Type.ENTITY && !(entity instanceof EntityPlayer) && entity instanceof EntityLivingBase) { if (((EntityLivingBase) entity).getItemStackFromSlot(NeuralHelpers.ARMOR_SLOT).isEmpty() && stack.getCount() == 1) { return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } if (LoadedCache.hasBaubles()) { IBaublesItemHandler handler = BaublesApi.getBaublesHandler(player); for (int slot : NeuralHelpers.getBaubleType().getValidSlots()) { if (handler.getStackInSlot(slot).isEmpty()) { if (!world.isRemote) { handler.setStackInSlot(slot, stack.copy()); if (!player.capabilities.isCreativeMode) stack.grow(-1); } return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } } return super.onItemRightClick(world, player, hand); }
for (int baubleSlot : bauble.getBaubleType(itemstack).getValidSlots()) { if ( bauble.canEquip(itemstack1, thePlayer) && !((Slot)this.inventorySlots.get(baubleSlot+9)).getHasStack() && !this.mergeItemStack(itemstack1, baubleSlot+9, baubleSlot + 10, false))