@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 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 @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))