Use a wrapper instead of ItemStacks for Altar recipes

This commit is contained in:
Nick 2015-11-03 10:00:40 -08:00
parent e12c78877e
commit 798d4b926c
5 changed files with 66 additions and 17 deletions

View file

@ -0,0 +1,53 @@
package WayofTime.bloodmagic.api;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@RequiredArgsConstructor
@EqualsAndHashCode
public class ItemStackWrapper {
public final Item item;
public final int stackSize;
public final int meta;
public ItemStackWrapper(Item item, int stackSize) {
this(item, stackSize, 0);
}
public ItemStackWrapper(Item item) {
this(item, 1, 0);
}
public ItemStackWrapper(Block block, int stackSize, int meta) {
this(Item.getItemFromBlock(block), stackSize, meta);
}
public ItemStackWrapper(Block block, int stackSize) {
this(block, stackSize, 0);
}
public ItemStackWrapper(Block block) {
this(block, 1, 0);
}
public ItemStack toStack() {
return new ItemStack(item, stackSize, meta);
}
public String getDisplayName() {
return toStack().getDisplayName();
}
@Override
public String toString() {
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
}
public static ItemStackWrapper getHolder(ItemStack stack) {
return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage());
}
}