本文整理汇总了Java中net.minecraft.item.crafting.IRecipe.matches方法的典型用法代码示例。如果您正苦于以下问题:Java IRecipe.matches方法的具体用法?Java IRecipe.matches怎么用?Java IRecipe.matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.crafting.IRecipe
的用法示例。
在下文中一共展示了IRecipe.matches方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecipe
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
public static IRecipe getRecipe(World world, ICraftingWidget widget) {
InventoryCrafting craftingGrid = widget.getCraftingGrid();
for (IRecipe recipe : CraftingManager.REGISTRY) {
if (recipe.matches(craftingGrid, world)) {
return recipe;
}
}
return null;
}
示例2: findMatchingRecipe
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
public static ItemStack findMatchingRecipe(Iterable<IRecipe> recipes, InventoryCrafting craftMatrix, World worldIn)
{
for (IRecipe irecipe : recipes)
{
if (irecipe.matches(craftMatrix, worldIn))
{
return irecipe.getCraftingResult(craftMatrix);
}
}
return ItemStack.EMPTY;
}
示例3: findMatchingRecipe
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
/**
* Retrieves an ItemStack that has multiple recipes for it.
*/
@Nullable
public ItemStack findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) {
for (IRecipe irecipe : this.recipes)
if (irecipe.matches(craftMatrix, worldIn))
return irecipe.getCraftingResult(craftMatrix);
return ItemStack.EMPTY;
}
示例4: getRemainingItems
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting craftMatrix, World worldIn) {
for (IRecipe irecipe : this.recipes)
if (irecipe.matches(craftMatrix, worldIn))
return irecipe.getRemainingItems(craftMatrix);
NonNullList<ItemStack> aitemstack = NonNullList.withSize(craftMatrix.getSizeInventory(),ItemStack.EMPTY);
for (int i = 0; i < aitemstack.size(); ++i)
aitemstack.set(i,craftMatrix.getStackInSlot(i));
return aitemstack;
}
示例5: matches
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int countSocks = 0;
int countDyes = 0;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack s = inv.getStackInSlot(i);
if (!s.isEmpty()) {
if (s.getItem() instanceof ItemSock && PonySocks.sock.isColorable(s)) {
countSocks++;
} else if (hasColor(s)) {
countDyes++;
} else {
return false;
}
}
}
if (countSocks == 1 && countDyes > 0) {
for (IRecipe recipe : PonySocks.specialDyeRecipes) {
if (recipe.matches(inv, worldIn)) {
return false;
}
}
return true;
} else {
return false;
}
}
示例6: shouldExecute
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
@Override
public boolean shouldExecute() {
IRecipe recipe = ProgWidgetCrafting.getRecipe(drone.world(), widget);
if (recipe == null) return false;
InventoryCrafting craftingGrid = widget.getCraftingGrid();
for (int crafted = 0; !((ICountWidget) widget).useCount() || crafted < ((ICountWidget) widget).getCount(); crafted++) {
List<ItemStack>[] equivalentsList = new List[9];
for (int i = 0; i < equivalentsList.length; i++) {
ItemStack originalStack = craftingGrid.getStackInSlot(i);
if (!originalStack.isEmpty()) {
List<ItemStack> equivalents = new ArrayList<>();
for (int j = 0; j < drone.getInv().getSlots(); j++) {
ItemStack droneStack = drone.getInv().getStackInSlot(j);
if (!droneStack.isEmpty() && (droneStack.getItem() == originalStack.getItem() || PneumaticCraftUtils.isSameOreDictStack(droneStack, originalStack))) {
equivalents.add(droneStack);
}
}
if (equivalents.isEmpty()) return false;
equivalentsList[i] = equivalents;
}
}
int[] curIndexes = new int[9];
boolean first = true;
boolean hasCrafted = false;
while (first || count(curIndexes, equivalentsList)) {
first = false;
InventoryCrafting craftMatrix = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return false;
}
}, 3, 3);
for (int i = 0; i < 9; i++) {
ItemStack stack = equivalentsList[i] == null ? ItemStack.EMPTY : equivalentsList[i].get(curIndexes[i]);
craftMatrix.setInventorySlotContents(i, stack);
}
if (recipe.matches(craftMatrix, drone.world())) {
if (craft(recipe.getCraftingResult(craftMatrix), craftMatrix)) {
hasCrafted = true;
break;
}
}
}
if (!hasCrafted) return false;
}
return false;
}
示例7: isRecipeMatch
import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
public static boolean isRecipeMatch(IRecipe recipe, InventoryCrafting grid) {
return recipe.matches(grid, getWorld());
}