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

Java IRecipeTransferError类代码示例

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

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



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

示例1: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer,
		boolean doTransfer) {
	if (doTransfer) {
		Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs = recipeLayout.getItemStacks().getGuiIngredients();
		NBTTagCompound recipe = new NBTTagCompound();
		for (Slot slot : (List<Slot>) container.inventorySlots) {
			if (slot.inventory instanceof InventoryCrafting) {
				IGuiIngredient<ItemStack> ingredient = inputs.get(slot.getSlotIndex()+1);
				if (ingredient != null) {
					List<ItemStack> possibleItems = ingredient.getAllIngredients();
					NBTTagList tags = new NBTTagList();
					for (ItemStack is : possibleItems) {
						NBTTagCompound tag = new NBTTagCompound();
						is.writeToNBT(tag);
						tags.appendTag(tag);
					}
					recipe.setTag("#" + slot.getSlotIndex(), tags);
				}
			}
		}
		EZStorage.instance.networkWrapper.sendToServer(new RecipeMessage(recipe));
	}
	return null;
}
 
开发者ID:zerofall,项目名称:EZStorage,代码行数:26,代码来源:RecipeTransferHandler.java


示例2: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Nullable
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer,
		boolean doTransfer) {

	if (!(container instanceof ContainerFabricationTable))
		return registry.getJeiHelpers().recipeTransferHandlerHelper().createInternalError();

	final ContainerFabricationTable containerFabTable = (ContainerFabricationTable) container;
	if (doTransfer) containerFabTable.clearCraftingGrid();

	List<Integer> missingItemSlots = new ArrayList<Integer>();
	ItemStack[][] ingredients = new ItemStack[9][];
	IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
	Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = itemStacks.getGuiIngredients();

	// final int limitTransfer = maxTransfer ? 0x40 : 1;

	for (int i = 0; i < 9; i++) {
		final int slotOffset = i + 1;

		if (guiIngredients.containsKey(slotOffset)) {
			final List<ItemStack> allIngredients = guiIngredients.get(slotOffset).getAllIngredients();
			if (!allIngredients.isEmpty()) {
				if (containerContainsIngredient(containerFabTable, allIngredients))
					ingredients[i] = allIngredients.toArray(new ItemStack[allIngredients.size()]);

				else missingItemSlots.add(slotOffset);
			}
		}
	}

	if (missingItemSlots.isEmpty()) {
		if (doTransfer) containerFabTable.fillCraftingGrid(ingredients, maxTransfer ? 0x40 : 1);
		return null;
	}

	return registry.getJeiHelpers().recipeTransferHandlerHelper().createUserErrorForSlots("Recipe transfer error!", missingItemSlots);
}
 
开发者ID:hockeyhurd,项目名称:Project-Zed,代码行数:40,代码来源:FabricationTableRecipeTransferHandler.java


示例3: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Nullable
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer,
		boolean doTransfer) {

	if (!(container instanceof ContainerPatternEncoder))
		return registry.getJeiHelpers().recipeTransferHandlerHelper().createInternalError();

	final ContainerPatternEncoder containerPatternEncoder = (ContainerPatternEncoder) container;
	ItemStack[][] ingredients = new ItemStack[9][];
	IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
	Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = itemStacks.getGuiIngredients();

	for (int i = 0; i < 9; i++) {
		final int slotOffset = i + 1;

		if (guiIngredients.containsKey(slotOffset)) {
			final List<ItemStack> allIngredients = guiIngredients.get(slotOffset).getAllIngredients();

			if (!allIngredients.isEmpty())
				ingredients[i] = allIngredients.toArray(new ItemStack[allIngredients.size()]);
		}
	}

	if (doTransfer) {
		containerPatternEncoder.clearSlots();
		containerPatternEncoder.fillCraftingGrid(ingredients);
	}

	return null;
}
 
开发者ID:hockeyhurd,项目名称:Project-Zed,代码行数:32,代码来源:PatternEncoderRecipeTransferHandler.java


示例4: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Override
@Nullable
public IRecipeTransferError transferRecipe(@Nonnull ContainerSagMill.Normal container, @Nonnull IRecipeLayout recipeLayout, @Nonnull EntityPlayer player,
    boolean maxTransfer, boolean doTransfer) {

  return super.transferRecipe(container, new SagMillRecipeLayout(recipeLayout), player, maxTransfer, doTransfer);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:8,代码来源:SagMillRecipeTransferHandler.java


示例5: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Override
@Nullable
public IRecipeTransferError transferRecipe(@Nonnull ContainerSagMill.Simple container, @Nonnull IRecipeLayout recipeLayout, @Nonnull EntityPlayer player,
    boolean maxTransfer, boolean doTransfer) {

  return super.transferRecipe(container, new SagMillRecipeLayout(recipeLayout), player, maxTransfer, doTransfer);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:8,代码来源:SimpleSagMillRecipeTransferHandler.java


示例6: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
	if (container instanceof IJEIAutoFillTerminal) {
		if (doTransfer) {
			ItemStack[][] stacks = transferFunc.apply(recipeLayout);
			// ItemStack[] output = transferFunc.apply(recipeLayout, true);
			NBTTagCompound compound = new NBTTagCompound();
			NBTTagList list = new NBTTagList();
			for (int i = 0;i < stacks.length;++i) {
				if (stacks[i] != null) {
					NBTTagCompound nbttagcompound = new NBTTagCompound();
					nbttagcompound.setByte("s", (byte) i);
					for (int j = 0;j < stacks[i].length && j < 3;j++) {
						if (stacks[i][j] != null && !stacks[i][j].isEmpty()) {
							NBTTagCompound tag = new NBTTagCompound();
							stacks[i][j].writeToNBT(tag);
							nbttagcompound.setTag("i" + j, tag);
						}
					}
					nbttagcompound.setByte("l", (byte) Math.min(3, stacks[i].length));
					list.appendTag(nbttagcompound);
				}
			}
			compound.setTag("i", list);
			/*list = new NBTTagList();
			for (int i = 0; i < output.length; ++i)
			{
				if (output[i] != null)
				{
					NBTTagCompound nbttagcompound = new NBTTagCompound();
					nbttagcompound.setByte("s", (byte)i);
					output[i].writeToNBT(nbttagcompound);
					list.appendTag(nbttagcompound);
				}
			}
			compound.setTag("o", list);*/
			((IJEIAutoFillTerminal) container).sendMessage(compound);
			// ((IPatternTerminal)container).setRecipe(stacks, output);
		}
	} else {
		return RecipeTransferErrorInternal.INSTANCE;
	}
	return null;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:45,代码来源:CraftingTerminalTransferHandler.java


示例7: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Override
public IRecipeTransferError transferRecipe(C container,
        IRecipeLayout layout, EntityPlayer player,
        boolean maxTransfer, boolean doTransfer) {
    
    ItemStack input = layout.getItemStacks().getGuiIngredients().values()
            .stream().filter((i) -> i.isInput()).findAny()
            .get().getDisplayedIngredient();
    
    // Search for a valid input
    int foundInput = -1;
    
    for (int i = this.getInvStart(container);
            i <= this.getInvEnd(container); i++) {
        
        if (GeoJei.stackHelper.isEquivalent(container
                .getSlot(i).getStack(), input)) {
            
            foundInput = i;
            break;
        }
    }
    
    if (foundInput == -1) {
        
        return GeoJei.transferHelper.createUserErrorWithTooltip(I18n
                .format(Lang.JEIERR_MISSING));
    }
    
    // Search for an empty space to fill
    int foundSpace = -1;
    
    for (int i = this.getInputStart(container);
            i <= this.getInputEnd(container); i++) {
        
        
        if (container.getSlot(i).getStack().isEmpty()) {
            
            foundSpace = i;
            break;
        }
    }
    
    if (foundSpace == -1) {
        
        return GeoJei.transferHelper.createUserErrorWithTooltip(I18n
                .format(Lang.JEIERR_SPACE));
    }

    if (doTransfer) {
        
        Geomastery.NETWORK.sendToServer(new SGeoPacketSingle(foundSpace,
                foundInput, maxTransfer));
    }
    
    return null;
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:58,代码来源:GeoFillTransfer.java


示例8: transferRecipe

import mezz.jei.api.recipe.transfer.IRecipeTransferError; //导入依赖的package包/类
@Nullable
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer,
		boolean doTransfer) {

	if (!(container instanceof ContainerStoneCraftingTable))
		return registry.getJeiHelpers().recipeTransferHandlerHelper().createInternalError();

	final ContainerStoneCraftingTable containerStoneCraftingTable = (ContainerStoneCraftingTable) container;
	if (doTransfer) containerStoneCraftingTable.clearCraftingGrid();

	List<Integer> missingItemSlots = new ArrayList<Integer>();
	ItemStack[][] ingredients = new ItemStack[9][];
	IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
	Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = itemStacks.getGuiIngredients();

	for (int i = 0; i < 9; i++) {
		final int slotOffset = i + 1;

		if (guiIngredients.containsKey(slotOffset)) {
			final List<ItemStack> allIngredients = guiIngredients.get(slotOffset).getAllIngredients();
			if (!allIngredients.isEmpty()) {
				if (containerContainsIngredient(containerStoneCraftingTable, allIngredients))
					ingredients[i] = allIngredients.toArray(new ItemStack[allIngredients.size()]);
				else missingItemSlots.add(slotOffset);
			}
		}
	}

	if (missingItemSlots.isEmpty()) {
		if (doTransfer) {
			containerStoneCraftingTable.fillCraftingGrid(ingredients, maxTransfer ? 0x40 : 1);

			/*for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
				ItemStack stackInSlot = player.inventory.getStackInSlot(i);
				if (stackInSlot == null) continue;

				boolean canEscape = false;

				for (int index = 0; index < ingredients.length; index++) {
					if (ingredients[index] == null) continue;

					for (int type = 0; type < ingredients[index].length; type++) {
						if (stackInSlot.isItemEqual(ingredients[index][type])) {
							stackInSlot.stackSize -= ingredients[index][type].stackSize;

							if (stackInSlot.stackSize == 0) {
								player.inventory.setInventorySlotContents(i, null);
								canEscape = true;
								break;
							}

							player.inventory.setInventorySlotContents(i, stackInSlot);
						}
					}

					if (canEscape) break;
				}
			}

			player.inventory.markDirty();*/
		}
		return null;
	}

	return registry.getJeiHelpers().recipeTransferHandlerHelper().createUserErrorForSlots("Recipe transfer error!", missingItemSlots);
}
 
开发者ID:hockeyhurd,项目名称:Project-Zed,代码行数:68,代码来源:StoneCraftingTableRecipeTransferHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EdmString类代码示例发布时间:2022-05-23
下一篇:
Java Convert类代码示例发布时间: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