• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IFocus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中mezz.jei.api.recipe.IFocus的典型用法代码示例。如果您正苦于以下问题:Java IFocus类的具体用法?Java IFocus怎么用?Java IFocus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IFocus类属于mezz.jei.api.recipe包,在下文中一共展示了IFocus类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: CraftingControl

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
public <T extends IRecipeWrapper> CraftingControl(IRecipeCategory<T> category, T wrapper, ResourceLocation border, int borderSize)
{
    super(border, 2);
    this.title = category.getTitle();
    off = DrawingTools.getStringHeight(title) + 2;
    IRecipeRegistry reg = PMJeiPlugin.RUNTIME.getRecipeRegistry();
    IRecipeLayoutDrawable draw = reg.createRecipeLayoutDrawable(category, wrapper, reg.createFocus(IFocus.Mode.OUTPUT, new ItemStack(Items.STICK /*hack*/)));
    setWidth(category.getBackground().getWidth() + size * 2);
    setHeight(category.getBackground().getHeight() + size * 2);
    draw.setPosition(size, size);
    this.draw = draw;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:13,代码来源:CraftingControl.java


示例2: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(IRecipeLayout recipeLayout, IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
    List<ItemStack> outputs = ingredients.getOutputs(ItemStack.class).get(0);

    IFocus<?> iFocus = recipeLayout.getFocus();
    Object focusObject = iFocus.getValue();

    if (focusObject instanceof ItemStack) {
        ItemStack focus = ((ItemStack) focusObject);
        Mode mode = iFocus.getMode();

        if (mode == Mode.INPUT) {
            EnumColour woolColour = EnumColour.fromWoolStack(focus);
            if (woolColour != null) {
                Frequency freq = new Frequency(woolColour, woolColour, woolColour);
                ItemStack newStack = freq.writeToStack(recipe.getRecipeOutput().copy());
                outputs = Collections.singletonList(newStack);
            }
        } else {
            Frequency frequency = Frequency.readFromStack(focus);
            EnumColour colour = frequency.getLeft();
            inputs.set(woolIndex, woolOres.get(colour));

        }
    }
    EnderStorageJEIPlugin.gridHelper.setInputs(guiItemStacks, inputs, 3, 3);
    guiItemStacks.set(0, outputs);
}
 
开发者ID:TheCBProject,项目名称:EnderStorage,代码行数:31,代码来源:ESCraftingRecipeWrapper.java


示例3: getDrawableFromItem

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
public static IRecipeLayoutDrawable getDrawableFromItem(ItemStack stack) {
	if (stack != null) {
		IRecipeRegistry registry = JEIRefractionPlugin.jeiRuntime.getRecipeRegistry();
		IFocus<ItemStack> focus = registry.createFocus(IFocus.Mode.OUTPUT, stack);
		for (IRecipeCategory<?> category : registry.getRecipeCategories(focus)) {
			if (category.getUid().equals(Constants.MOD_ID + ".assembly_table")
					|| category.getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
				List<IRecipeLayoutDrawable> layouts = getLayouts(registry, category, focus);
				if (!layouts.isEmpty())
					return layouts.get(0);
			}
		}
	}
	return null;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:16,代码来源:JEIRefractionPlugin.java


示例4: getLayouts

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
private static <T extends IRecipeWrapper> List<IRecipeLayoutDrawable> getLayouts(IRecipeRegistry registry, IRecipeCategory<T> category, IFocus<ItemStack> focus) {
	List<IRecipeLayoutDrawable> layouts = new ArrayList<>();
	List<T> wrappers = registry.getRecipeWrappers(category, focus);
	for (T wrapper : wrappers) {
		IRecipeLayoutDrawable layout = registry.createRecipeLayoutDrawable(category, wrapper, focus);
		layouts.add(layout);
	}
	return layouts;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:10,代码来源:JEIRefractionPlugin.java


示例5: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(IRecipeLayout recipeLayout, HammerRecipe recipeWrapper)
{
    // Block
    recipeLayout.getItemStacks().init(0, true, 74, 9);
    recipeLayout.getItemStacks().set(0, (ItemStack) recipeWrapper.getInputs().get(0));
    
    IFocus<?> focus = recipeLayout.getFocus();
    hasHighlight = focus.getMode() == IFocus.Mode.OUTPUT;
    
    int slotIndex = 1;
    
    for (int i = 0; i < recipeWrapper.getOutputs().size(); i++)
    {
        final int slotX = 2 + (i % 9 * 18);
        final int slotY = 36 + (i / 9 * 18);
        
        ItemStack outputStack = (ItemStack) recipeWrapper.getOutputs().get(i);
        
        recipeLayout.getItemStacks().init(slotIndex + i, false, slotX, slotY);
        recipeLayout.getItemStacks().set(slotIndex + i, outputStack);
        
        ItemStack focusStack = (ItemStack) focus.getValue();
        
        if (focus.getMode() == IFocus.Mode.OUTPUT && focusStack != null && focusStack.getItem() == outputStack.getItem() && focusStack.getItemDamage() == outputStack.getItemDamage())
        {
            highlightX = slotX;
            highlightY = slotY;
        }
    }
    
    recipeLayout.getItemStacks().addTooltipCallback(new HammerTooltipCallback(recipeWrapper));
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:34,代码来源:HammerRecipeCategory.java


示例6: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(IRecipeLayout recipeLayout, FluidTransformRecipe recipeWrapper)
{
    recipeLayout.getItemStacks().init(0, true, 74, 9);
    recipeLayout.getItemStacks().init(1, true, 47, 9);
    recipeLayout.getItemStacks().init(2, true, 74, 36);
    recipeLayout.getItemStacks().init(3, false, 101, 9);
    
    boolean noCycle = false;
    List<ItemStack> focusStack = null;
    
    IFocus<?> focus = recipeLayout.getFocus();
    
    if(focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack)
    {
        ItemStack stack = (ItemStack) focus.getValue();
        
        for(ItemStack inputStack : recipeWrapper.getInputs().subList(1, recipeWrapper.getInputs().size()))
        {
            if(stack.isItemEqual(inputStack))
            {
                noCycle = true;
                focusStack = ImmutableList.of(inputStack);
            }
        }
    }
    
    recipeLayout.getItemStacks().set(0, new ItemStack(ENBlocks.barrelStone, 1, 0));
    recipeLayout.getItemStacks().set(1, recipeWrapper.getInputs().get(0));
    recipeLayout.getItemStacks().set(2, noCycle ? focusStack : ImmutableList.copyOf(recipeWrapper.getInputs().subList(1, recipeWrapper.getInputs().size())));
    recipeLayout.getItemStacks().set(3, recipeWrapper.getOutputs().get(0));
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:33,代码来源:FluidTransformRecipeCategory.java


示例7: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(IRecipeLayout layout, CompostRecipe recipe)
{
    // Block
    layout.getItemStacks().init(0, false, 74, 9);
    layout.getItemStacks().set(0, (ItemStack) recipe.getOutputs().get(0));
    
    IFocus<?> focus = layout.getFocus();
    boolean mightHaveHighlight = focus.getMode() == IFocus.Mode.INPUT;
    hasHighlight = false;

    ItemStack focusStack = (ItemStack) focus.getValue();
    
    int slotIndex = 1;
    
    for (int i = 0; i < recipe.getInputs().size(); i++)
    {
        final int slotX = 2 + (i % 9 * 18);
        final int slotY = 36 + (i / 9 * 18);
        
        ItemStack inputStack = (ItemStack) recipe.getInputs().get(i);
        
        layout.getItemStacks().init(slotIndex + i, true, slotX, slotY);
        layout.getItemStacks().set(slotIndex + i, inputStack);
        
        if (mightHaveHighlight && ItemStack.areItemsEqual(focusStack, inputStack))
        {
            highlightX = slotX;
            highlightY = slotY;
            
            hasHighlight = true;
            mightHaveHighlight = false;
        }
    }
    
    layout.getItemStacks().addTooltipCallback(new CompostTooltipCallback());
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:38,代码来源:CompostRecipeCategory.java


示例8: openRecipeGui

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void openRecipeGui(ItemStack stack) {
    RecipeRegistry registry = Internal.getRuntime().getRecipeRegistry();
    IFocus<ItemStack> focus = registry.createFocus(Mode.OUTPUT, stack);
    if (registry.getRecipeCategories(focus).isEmpty()) {
        return;
    }
    Internal.getRuntime().getRecipesGui().show(focus);
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:10,代码来源:JEIProxy.java


示例9: openUsageGui

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void openUsageGui(ItemStack stack) {
    RecipeRegistry registry = Internal.getRuntime().getRecipeRegistry();
    IFocus<ItemStack> focus = registry.createFocus(Mode.INPUT, stack);
    if (registry.getRecipeCategories(focus).isEmpty()) {
        return;
    }
    Internal.getRuntime().getRecipesGui().show(focus);
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:10,代码来源:JEIProxy.java


示例10: showUses

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
public static void showUses(ItemStack stack) {
    if (recipesGui != null && recipeRegistry != null)
        recipesGui.show(recipeRegistry.createFocus(IFocus.Mode.INPUT, stack));
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:5,代码来源:JEICustomPlugin.java


示例11: setOverrideDisplayFocus

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setOverrideDisplayFocus(@Nullable IFocus<ItemStack> focus) {
  itemStacks.setOverrideDisplayFocus(focus);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:5,代码来源:SagMillGuiItemStackGroup.java


示例12: getFocus

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
@Nullable
public IFocus<?> getFocus() {
  return recipeLayout.getFocus();
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:6,代码来源:SagMillRecipeLayout.java


示例13: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull PainterRecipeCategory.PainterRecipeWrapper currentRecipe,
    @Nonnull IIngredients ingredients) {
  IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
  IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);

  guiItemStacks.init(0, true, 67 - xOff - 1, 34 - yOff - 1);
  guiItemStacks.init(1, true, 38 - xOff - 1, 34 - yOff - 1);
  guiItemStacks.init(2, false, 121 - xOff - 1, 34 - yOff - 1);
  group.init(3, true, EnergyIngredientRenderer.INSTANCE, 108 - xOff, 60 - yOff, 50, 10, 0, 0);

  IFocus<?> focus = recipeLayout.getFocus();
  if (focus != null) {
    Object focusValue = focus.getValue();
    if (focusValue instanceof ItemStack) {
      ItemStack focused = (ItemStack) focusValue;

      List<ItemStack> paints = new ArrayList<ItemStack>();
      List<ItemStack> results = new ArrayList<ItemStack>();

      if (focus.getMode() == IFocus.Mode.OUTPUT) {
        // JEI is focusing on the output item. Limit the recipe to the fixed input item, the focused output item and the matching paint.
        IBlockState paint = PaintUtil.getSourceBlock(focused);
        ItemStack paintAsStack = PaintUtil.getPaintAsStack(paint);
        paints.add(paintAsStack);
        results.add(focused);
      } else if (stackHelper.isEquivalent(focused, currentRecipe.target)) {
        // JEI is focusing on a paintable item. If that item also can be used as a paint source, it will display "item+item=anything", which is somewhere
        // between weird and wrong. So remove the recipe "item+item" from the list to get "anything+item=anything".
        for (int i = 0; i < currentRecipe.paints.size(); i++) {
          ItemStack resultStack = currentRecipe.results.get(i);
          ItemStack paintStack = currentRecipe.paints.get(i);
          if (!stackHelper.isEquivalent(focused, paintStack)) {
            paints.add(paintStack);
            results.add(resultStack);
          }
        }
      } else {
        // JEI is focusing on the paint. Limit the output items to things that are painted with this paint.
        for (ResultStack result : currentRecipe.recipe.getCompletedResult(focused, currentRecipe.target)) {
          paints.add(focused);
          results.add(result.item);
        }
      }
      if (!paints.isEmpty()) {
        guiItemStacks.set(1, paints);
        guiItemStacks.set(2, results);
        return;
      }
    }
  }

  guiItemStacks.set(0, currentRecipe.target);
  guiItemStacks.set(1, currentRecipe.paints);
  guiItemStacks.set(2, currentRecipe.results);
  group.set(ingredients);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:58,代码来源:PainterRecipeCategory.java


示例14: setRecipe

import mezz.jei.api.recipe.IFocus; //导入依赖的package包/类
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull SoulBinderRecipeCategory.SoulBinderRecipeWrapper recipeWrapper,
    @Nonnull IIngredients ingredients) {

  IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
  IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);

  guiItemStacks.init(0, true, 37 - xOff, 33 - yOff);
  guiItemStacks.init(1, true, 58 - xOff, 33 - yOff);
  guiItemStacks.init(2, false, 111 - xOff, 33 - yOff);
  guiItemStacks.init(3, false, 133 - xOff, 33 - yOff);
  group.init(xOff, true, EnergyIngredientRenderer.INSTANCE, 5, 35, 60, 10, 0, 0);

  guiItemStacks.set(ingredients);
  IFocus<?> focus = recipeLayout.getFocus();
  if (focus != null && focus.getMode() == Mode.INPUT && focus.getValue() instanceof ItemStack
      && ((ItemStack) focus.getValue()).getItem() == itemSoulVial.getItemNN() && CapturedMob.containsSoul(((ItemStack) focus.getValue()))
      && ingredients.getOutputs(ItemStack.class).get(1).size() > 1) {
    // we are focused on a filled soul vial on the input side and the output has a list
    final CapturedMob vialMob = CapturedMob.create(((ItemStack) focus.getValue()));
    if (vialMob != null) {
      List<ItemStack> newOutputs = new ArrayList<>();
      for (ItemStack output : ingredients.getOutputs(ItemStack.class).get(1)) {
        if (output != null && vialMob.isSameType(CapturedMob.create(output))) {
          newOutputs.add(output);
        }
      }
      guiItemStacks.set(3, newOutputs);
    }
  }

  if (focus != null && focus.getMode() == Mode.OUTPUT && focus.getValue() instanceof ItemStack && CapturedMob.containsSoul(((ItemStack) focus.getValue()))
      && ingredients.getInputs(ItemStack.class).get(0).size() > 1 && ingredients.getOutputs(ItemStack.class).get(1).size() > 1) {
    // we are focused on a output item and the both sides have a list
    final CapturedMob resultMob = CapturedMob.create(((ItemStack) focus.getValue()));
    if (resultMob != null) {
      List<ItemStack> newInputs = new ArrayList<>();
      for (ItemStack input : ingredients.getInputs(ItemStack.class).get(0)) {
        if (input != null && resultMob.isSameType(CapturedMob.create(input))) {
          newInputs.add(input);
        }
      }
      guiItemStacks.set(0, newInputs);
      guiItemStacks.set(3, ((ItemStack) focus.getValue()));
    }
  }

  group.set(ingredients);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:50,代码来源:SoulBinderRecipeCategory.java



注:本文中的mezz.jei.api.recipe.IFocus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebSocketFrame类代码示例发布时间:2022-05-23
下一篇:
Java IQuickAssistProcessor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap