|
|
@@ -1,17 +1,12 @@
|
|
|
package com.hexdragon.util.item;
|
|
|
|
|
|
-import net.minecraft.entity.player.PlayerEntity;
|
|
|
-import net.minecraft.inventory.IInventory;
|
|
|
-import net.minecraft.inventory.IRecipeHolder;
|
|
|
+import net.minecraft.inventory.CraftResultInventory;
|
|
|
import net.minecraft.inventory.ItemStackHelper;
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
-import net.minecraft.item.crafting.IRecipe;
|
|
|
import net.minecraft.util.NonNullList;
|
|
|
|
|
|
-import javax.annotation.Nullable;
|
|
|
-
|
|
|
// 支持多个物品栏的 CraftResultInventory
|
|
|
-public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
|
|
|
+public class CraftResultInventoryRe extends CraftResultInventory {
|
|
|
|
|
|
// 构造函数
|
|
|
private final int slotsCount;
|
|
|
@@ -25,29 +20,18 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
|
|
|
this.inventoryContents = NonNullList.from(ItemStack.EMPTY, stacksIn);
|
|
|
}
|
|
|
|
|
|
- // 各种简单的方法
|
|
|
- public int getSizeInventory() {return slotsCount;}
|
|
|
+ // 对物品格子的各种操作
|
|
|
public boolean isEmpty() {
|
|
|
for (ItemStack itemstack : this.inventoryContents) {
|
|
|
- if (!itemstack.isEmpty()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!itemstack.isEmpty()) return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+ public int getSizeInventory() {return slotsCount;}
|
|
|
public void clear() {this.inventoryContents.clear();}
|
|
|
- public void markDirty() {}
|
|
|
- public boolean isUsableByPlayer(PlayerEntity player) {return true;}
|
|
|
-
|
|
|
- // 对物品格子的输入输出
|
|
|
public ItemStack getStackInSlot(int index) {return this.inventoryContents.get(index);}
|
|
|
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 decrStackSize(int index, int count) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
|
|
|
|
|
|
- // 不知道有啥用的 Recipe 支持
|
|
|
- @Nullable private IRecipe<?> recipeUsed;
|
|
|
- public void setRecipeUsed(@Nullable IRecipe<?> recipe) {this.recipeUsed = recipe;}
|
|
|
- @Nullable public IRecipe<?> getRecipeUsed() {return this.recipeUsed;}
|
|
|
-
|
|
|
}
|