|
@@ -16,12 +16,10 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
|
|
|
// 构造函数
|
|
// 构造函数
|
|
|
private final int slotsCount;
|
|
private final int slotsCount;
|
|
|
private final NonNullList<ItemStack> inventoryContents;
|
|
private final NonNullList<ItemStack> inventoryContents;
|
|
|
-
|
|
|
|
|
public CraftResultInventoryRe(int numSlots) {
|
|
public CraftResultInventoryRe(int numSlots) {
|
|
|
this.slotsCount = numSlots;
|
|
this.slotsCount = numSlots;
|
|
|
this.inventoryContents = NonNullList.withSize(numSlots, ItemStack.EMPTY);
|
|
this.inventoryContents = NonNullList.withSize(numSlots, ItemStack.EMPTY);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
public CraftResultInventoryRe(ItemStack... stacksIn) {
|
|
public CraftResultInventoryRe(ItemStack... stacksIn) {
|
|
|
this.slotsCount = stacksIn.length;
|
|
this.slotsCount = stacksIn.length;
|
|
|
this.inventoryContents = NonNullList.from(ItemStack.EMPTY, stacksIn);
|
|
this.inventoryContents = NonNullList.from(ItemStack.EMPTY, stacksIn);
|
|
@@ -29,7 +27,6 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
|
|
|
|
|
|
|
|
// 各种简单的方法
|
|
// 各种简单的方法
|
|
|
public int getSizeInventory() {return slotsCount;}
|
|
public int getSizeInventory() {return slotsCount;}
|
|
|
-
|
|
|
|
|
public boolean isEmpty() {
|
|
public boolean isEmpty() {
|
|
|
for (ItemStack itemstack : this.inventoryContents) {
|
|
for (ItemStack itemstack : this.inventoryContents) {
|
|
|
if (!itemstack.isEmpty()) {
|
|
if (!itemstack.isEmpty()) {
|
|
@@ -38,27 +35,19 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
public void clear() {this.inventoryContents.clear();}
|
|
public void clear() {this.inventoryContents.clear();}
|
|
|
-
|
|
|
|
|
public void markDirty() {}
|
|
public void markDirty() {}
|
|
|
-
|
|
|
|
|
public boolean isUsableByPlayer(PlayerEntity player) {return true;}
|
|
public boolean isUsableByPlayer(PlayerEntity player) {return true;}
|
|
|
|
|
|
|
|
// 对物品格子的输入输出
|
|
// 对物品格子的输入输出
|
|
|
public ItemStack getStackInSlot(int index) {return this.inventoryContents.get(index);}
|
|
public ItemStack getStackInSlot(int index) {return this.inventoryContents.get(index);}
|
|
|
-
|
|
|
|
|
public void setInventorySlotContents(int index, ItemStack stack) {this.inventoryContents.set(index, stack);}
|
|
public void setInventorySlotContents(int index, ItemStack stack) {this.inventoryContents.set(index, stack);}
|
|
|
-
|
|
|
|
|
public ItemStack removeStackFromSlot(int index) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
|
|
public ItemStack removeStackFromSlot(int index) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
|
|
|
-
|
|
|
|
|
public ItemStack decrStackSize(int index, int count) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
|
|
public ItemStack decrStackSize(int index, int count) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
|
|
|
|
|
|
|
|
// 不知道有啥用的 Recipe 支持
|
|
// 不知道有啥用的 Recipe 支持
|
|
|
@Nullable private IRecipe<?> recipeUsed;
|
|
@Nullable private IRecipe<?> recipeUsed;
|
|
|
-
|
|
|
|
|
public void setRecipeUsed(@Nullable IRecipe<?> recipe) {this.recipeUsed = recipe;}
|
|
public void setRecipeUsed(@Nullable IRecipe<?> recipe) {this.recipeUsed = recipe;}
|
|
|
-
|
|
|
|
|
@Nullable public IRecipe<?> getRecipeUsed() {return this.recipeUsed;}
|
|
@Nullable public IRecipe<?> getRecipeUsed() {return this.recipeUsed;}
|
|
|
|
|
|
|
|
}
|
|
}
|