本文整理汇总了Java中net.minecraft.inventory.InventoryCrafting.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryCrafting.getWidth方法的具体用法?Java InventoryCrafting.getWidth怎么用?Java InventoryCrafting.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.InventoryCrafting
的用法示例。
在下文中一共展示了InventoryCrafting.getWidth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int slots = inv.getHeight() * inv.getWidth();
int center = (int) ((float)slots / 2F);
ItemStack checked = inv.getStackInSlot(center);
if(checked.isEmpty() || !checked.hasTagCompound()) return false;
int amount = 0;
for(int j = 0; j < slots; j++) {
ItemStack stack = inv.getStackInSlot(j);
if(!stack.isEmpty() && (!hasTag(stack) || stack.getItem() != checked.getItem())) return false;
if(!stack.isEmpty() && j != center) {
amount++;
}
}
return amount > 0;
}
示例2: getCraftingResult
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
int slots = inv.getHeight() * inv.getWidth();
int center = (int) ((float)slots / 2F);
ItemStack checked = inv.getStackInSlot(center);
if(checked.isEmpty() || !checked.hasTagCompound()) return ItemStack.EMPTY;
int amount = 0;
for(int j = 0; j < slots; j++) {
ItemStack stack = inv.getStackInSlot(j);
if(!stack.isEmpty() && (!hasTag(stack) || stack.getItem() != checked.getItem())) return ItemStack.EMPTY;
if(!stack.isEmpty() && j != center) {
amount++;
}
}
if(amount > 0) {
ItemStack entanglement = new ItemStack(checked.getItem(), amount);
getKey(checked).ifPresent(uuid -> setKey(entanglement, uuid));
return entanglement;
}
return ItemStack.EMPTY;
}
示例3: matchesShaped
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
protected boolean matchesShaped(InventoryCrafting inv) {
for (int iy = 0; iy <= inv.getHeight() - 2; iy++) {
for (int ix = 0; ix <= inv.getWidth() - 3; ix++) {
boolean foundMistake = false;
innerLoop: for (int y = 0; y < 2; y++) {
for (int x = 0; x < 3; x++) {
Ingredient ingredient = ingredients.get(y*3 + x);
if (!ingredient.apply(inv.getStackInRowAndColumn(ix+x, iy+y))) {
foundMistake = true;
break innerLoop;
}
}
}
if (!foundMistake) {
return true;
}
}
}
return false;
}
示例4: extractReduceMirror
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
public List<ItemStack[][]> extractReduceMirror(InventoryCrafting inv) {
ItemStack[][] grid = new ItemStack[inv.getHeight()][inv.getWidth()];
for (int y = 0; y < inv.getHeight(); y++) {
for (int x = 0; x < inv.getWidth(); x++) {
grid[y][x] = inv.getStackInRowAndColumn(x, y);
}
}
return mirror(reduceBlank(grid));
}
示例5: matches
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
List<ItemStack> list = Lists.newArrayList(this.recipeItems);
for (int i = 0; i < inv.getHeight(); ++i)
{
for (int j = 0; j < inv.getWidth(); ++j)
{
ItemStack itemstack = inv.getStackInRowAndColumn(j, i);
if (itemstack != null)
{
boolean flag = false;
for (ItemStack itemstack1 : list)
{
if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))
{
flag = true;
list.remove(itemstack1);
break;
}
}
if (!flag)
{
return false;
}
}
}
}
return list.isEmpty();
}
示例6: getRemainingItems
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
int slots = inv.getHeight() * inv.getWidth();
NonNullList<ItemStack> nonNullList = NonNullList.<ItemStack>withSize(slots, ItemStack.EMPTY);
int center = (int) ((float) slots / 2);
ItemStack stack = inv.getStackInSlot(center);
nonNullList.set(center, stack.copy());
return nonNullList;
}
示例7: getRemainingItems
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
NonNullList<ItemStack> items = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
getMatch(inv);
int[] amounts = getAmounts(wasMirrored);
for (int col = 0; col < getWidth(); col++)
{
for (int row = 0; row < getHeight(); row++)
{
int amountIndex = col + row * getWidth();
int invIndex = matchX + col + (row + matchY) * inv.getWidth();
int amount = amounts[amountIndex];
if (amount > 0)
{
ItemStack stack = inv.getStackInSlot(invIndex).copy();
stack.setItemDamage(stack.getItemDamage() + amount);
if (stack.getItemDamage() > stack.getMaxDamage())
{
stack = ForgeHooks.getContainerItem(stack);
}
items.set(invIndex, stack);
} else
{
items.set(invIndex, ForgeHooks.getContainerItem(inv.getStackInSlot(invIndex)));
}
}
}
return items;
}
示例8: matches
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
if (inv.getWidth() == 3 && inv.getHeight() == 3)
{
for (int i = 0; i < inv.getWidth(); ++i)
{
for (int j = 0; j < inv.getHeight(); ++j)
{
ItemStack itemstack = inv.getStackInRowAndColumn(i, j);
if (itemstack.func_190926_b())
{
return false;
}
Item item = itemstack.getItem();
if (i == 1 && j == 1)
{
if (item != Items.LINGERING_POTION)
{
return false;
}
}
else if (item != Items.ARROW)
{
return false;
}
}
}
return true;
}
else
{
return false;
}
}
示例9: matches
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
List<ItemStack> list = Lists.newArrayList(this.recipeItems);
for (int i = 0; i < inv.getHeight(); ++i)
{
for (int j = 0; j < inv.getWidth(); ++j)
{
ItemStack itemstack = inv.getStackInRowAndColumn(j, i);
if (!itemstack.func_190926_b())
{
boolean flag = false;
for (ItemStack itemstack1 : list)
{
if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))
{
flag = true;
list.remove(itemstack1);
break;
}
}
if (!flag)
{
return false;
}
}
}
}
return list.isEmpty();
}
示例10: matches
import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
if (inv.getWidth() == 3 && inv.getHeight() == 3)
{
for (int i = 0; i < inv.getWidth(); ++i)
{
for (int j = 0; j < inv.getHeight(); ++j)
{
ItemStack itemstack = inv.getStackInRowAndColumn(i, j);
if (itemstack == null)
{
return false;
}
Item item = itemstack.getItem();
if (i == 1 && j == 1)
{
if (item != Items.LINGERING_POTION)
{
return false;
}
}
else if (item != Items.ARROW)
{
return false;
}
}
}
return true;
}
else
{
return false;
}
}