當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryCrafting.setInventorySlotContents方法代碼示例

本文整理匯總了Java中net.minecraft.inventory.InventoryCrafting.setInventorySlotContents方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryCrafting.setInventorySlotContents方法的具體用法?Java InventoryCrafting.setInventorySlotContents怎麽用?Java InventoryCrafting.setInventorySlotContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.inventory.InventoryCrafting的用法示例。


在下文中一共展示了InventoryCrafting.setInventorySlotContents方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCraftingGrid

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
@Override
public InventoryCrafting getCraftingGrid() {
    InventoryCrafting invCrafting = new InventoryCrafting(new Container() {
        @Override
        public boolean canInteractWith(EntityPlayer p_75145_1_) {
            return false;
        }

    }, 3, 3);
    for (int y = 0; y < 3; y++) {
        ProgWidgetItemFilter itemFilter = (ProgWidgetItemFilter) getConnectedParameters()[y];
        for (int x = 0; x < 3 && itemFilter != null; x++) {
            invCrafting.setInventorySlotContents(y * 3 + x, itemFilter.getFilter());
            itemFilter = (ProgWidgetItemFilter) itemFilter.getConnectedParameters()[0];
        }
    }
    return invCrafting;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:19,代碼來源:ProgWidgetCrafting.java

示例2: test_useUpItem

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
@Test
public void test_useUpItem()
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD));

    assertTrue(recipe.matches(inv, null));
    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(3).isEmpty());
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:20,代碼來源:DamageableShapelessOreRecipeTest.java

示例3: doTest

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
private void doTest(boolean inOrder, boolean enoughDamage)
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {enoughDamage ? 5 : 5000, 0},
                                                                           new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem());
        assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage());
    }
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:26,代碼來源:DamageableShapelessOreRecipeTest.java

示例4: test_useUpItem

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
@Test
public void test_useUpItem()
{
    ShapedOreRecipe recipe = new DamageableShapedOreRecipe(new ResourceLocation("group"),
                                                           new int[] {60}, new ItemStack(Blocks.DIRT),
                                                           "A",
                                                           'A', new ItemStack(Items.WOODEN_SWORD));

    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);

    inv.setInventorySlotContents(0, new ItemStack(Items.WOODEN_SWORD));
    assertTrue(recipe.matches(inv, null));

    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(0).isEmpty());
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:24,代碼來源:DamageableShapedOreRecipeTest.java

示例5: canCraft

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
public boolean canCraft() {
	if(currentEnergy <= 0) {
		FMLLog.log(Level.INFO, "Ba");
		currentEnergy = 0;
		return false;
	} else {
		FMLLog.log(Level.INFO, "Bb");
		InventoryCrafting inv = new InventoryCrafting(new ContainerAutoWorkBench(new InventoryPlayer(null), this), 3, 3);
		for(int i = 1; i < machineItemStacks.length - 1; i++) {
			inv.setInventorySlotContents(i - 1, machineItemStacks[i - 1]);
			FMLLog.log(Level.INFO, "Bc" + (i - 1));
		}
		ItemStack stack = AutoWorkBenchRecipes.smelting().getSmeltingResult(inv, worldObj, Tier.normal)[0];
		FMLLog.log(Level.INFO, "Bd" + (stack != null));
		return stack != null;
	}
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:18,代碼來源:TileEntityAutoWorkBench.java

示例6: getCraftingGrid

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
@Override
public InventoryCrafting getCraftingGrid() {
    InventoryCrafting invCrafting = new InventoryCrafting(new Container() {
        @Override
        public boolean canInteractWith(EntityPlayer p_75145_1_) {
            return false;
        }
    }, 3, 3);
    for (int i = 0; i < 9; i++)
        invCrafting.setInventorySlotContents(i, craftingGrid[i]);
    return invCrafting;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:13,代碼來源:ProgWidgetCC.java

示例7: findOutput

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
public static ItemStack findOutput(int size, ItemStack input, World world) {
    InventoryCrafting inventoryCrafting = new InventoryCrafting(new Container() {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn) {
            return false;
        }
    }, size, size);
    for (int i = 0; i < size * size; ++i) {
        inventoryCrafting.setInventorySlotContents(i, input.copy());
    }
    return CraftingManager.findMatchingResult(inventoryCrafting, world);
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:13,代碼來源:CraftingUtils.java

示例8: genCraftingInventory

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
public static InventoryCrafting genCraftingInventory(World world, ItemStack... inputs) {
    InventoryCrafting inventoryCrafting = new InventoryCrafting(new Container() {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn) {
            return false;
        }
    }, 3, 3);
    for (int i = 0; i < 9; ++i) {
        inventoryCrafting.setInventorySlotContents(i, inputs[i]);
    }
    return inventoryCrafting;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:13,代碼來源:CraftingUtils.java

示例9: doTest

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
private void doTest(boolean mirror, boolean enoughDamage)
{
    ShapedOreRecipe recipe = new DamageableShapedOreRecipe(new ResourceLocation("group"),
                                                           new int[] {0, 0, enoughDamage ? 5 : 5000, 0}, new ItemStack(Blocks.DIRT),
                                                           "AA", "BA",
                                                           'A', new ItemStack(Blocks.DIRT),
                                                           'B', new ItemStack(Items.WOODEN_SWORD))
            .setMirrored(mirror);

    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(4, new ItemStack(Blocks.DIRT));
    inv.setInventorySlotContents(5, new ItemStack(Blocks.DIRT));
    inv.setInventorySlotContents(mirror ? 8 : 7, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(mirror ? 7 : 8, new ItemStack(Blocks.DIRT));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(mirror ? 8 : 7).getItem());
        assertEquals(5, remaining.get(mirror ? 8 : 7).getItemDamage());
    }
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:32,代碼來源:DamageableShapedOreRecipeTest.java

示例10: craftItem

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的package包/類
public boolean craftItem() {
	InventoryCrafting inv = new InventoryCrafting(new ContainerAutoWorkBench(null, this), 3, 3);
	for(int i = 1; i < machineItemStacks.length - 1; i++) {
		inv.setInventorySlotContents(i - 1, machineItemStacks[i - 1]);
		FMLLog.log(Level.INFO, "E" + (i - 1));
	}
	ItemStack result = AutoWorkBenchRecipes.smelting().getSmeltingResult(inv, worldObj, Tier.normal)[0];
	if(canCraft() && result != null && (machineItemStacks[10] == null || result.isItemEqual(machineItemStacks[10]))) {
		FMLLog.log(Level.INFO, "F");
		if(machineItemStacks[10] == null) {
			FMLLog.log(Level.INFO, "G");
			machineItemStacks[10] = result;
		} else {
			FMLLog.log(Level.INFO, "H");
			machineItemStacks[10].stackSize++;
		}
		for(int i = 1; i < machineItemStacks.length; i++) {
			FMLLog.log(Level.INFO, "I" + 1);
			if(machineItemStacks[i] != null) {
				FMLLog.log(Level.INFO, "J");
				machineItemStacks[i].stackSize--;
				if(machineItemStacks[i].stackSize <= 0) {
					FMLLog.log(Level.INFO, "K");
					machineItemStacks[i] = null;
				}
			}
		}
		FMLLog.log(Level.INFO, "L");
		return true;	
	}
	FMLLog.log(Level.INFO, "M");
	return false;
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:34,代碼來源:TileEntityAutoWorkBench.java

示例11: shouldExecute

import net.minecraft.inventory.InventoryCrafting; //導入方法依賴的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;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:50,代碼來源:ProgWidgetCrafting.java


注:本文中的net.minecraft.inventory.InventoryCrafting.setInventorySlotContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。