Search in sources :

Example 11 with ItemStackWrapper

use of com.builtbroken.mc.prefab.items.ItemStackWrapper in project Engine by VoltzEngine-Project.

the class ItemStackWrapperTest method testCompareItemStack.

//Check if Wrapper equals stack
public void testCompareItemStack() {
    ItemStack stack = new ItemStack(Blocks.diamond_block);
    ItemStack itemStack = new ItemStack(Blocks.diamond_block);
    ItemStackWrapper wrapper = new ItemStackWrapper(itemStack);
    assertTrue("MC compare check for items equal", stack.isItemEqual(itemStack));
    assertTrue("Compare failed for block equals", wrapper.equals(stack));
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper)

Example 12 with ItemStackWrapper

use of com.builtbroken.mc.prefab.items.ItemStackWrapper in project Engine by VoltzEngine-Project.

the class MRFluidStack method addInputOption.

public MRFluidStack addInputOption(Block input) {
    ItemStackWrapper wrapper = new ItemStackWrapper(new ItemStack(input));
    wrapper.meta_compare = false;
    wrapper.nbt_compare = false;
    return (MRFluidStack) super.addInputOption(wrapper);
}
Also used : ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper) ItemStack(net.minecraft.item.ItemStack)

Example 13 with ItemStackWrapper

use of com.builtbroken.mc.prefab.items.ItemStackWrapper in project Engine by VoltzEngine-Project.

the class MRFluidStack method addInputOption.

public MRFluidStack addInputOption(Item input) {
    ItemStackWrapper wrapper = new ItemStackWrapper(new ItemStack(input));
    wrapper.meta_compare = false;
    wrapper.nbt_compare = false;
    return (MRFluidStack) super.addInputOption(wrapper);
}
Also used : ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper) ItemStack(net.minecraft.item.ItemStack)

Example 14 with ItemStackWrapper

use of com.builtbroken.mc.prefab.items.ItemStackWrapper in project Engine by VoltzEngine-Project.

the class ExplosiveRegistry method registerExplosiveItem.

/**
     * Registers an item as an explosive for crafting recipes
     *
     * @param item - item to be used in crafting, must be an instance of {@link IExplosive}
     *             Uses {@link IExplosiveHolder} to get size
     * @return true if it was registered
     */
public static boolean registerExplosiveItem(ItemStack item, IExplosiveHandler ex) {
    if (item != null && ex != null) {
        ItemStackWrapper wrapper = new ItemStackWrapper(item);
        if (!itemToExplosive.containsKey(wrapper)) {
            itemToExplosive.put(wrapper, ex);
            //Get list or make new
            List<ItemStackWrapper> items;
            if (explosiveToItems.containsKey(ex)) {
                items = explosiveToItems.get(ex);
                if (items == null) {
                    items = new ArrayList();
                }
            } else {
                items = new ArrayList();
            }
            //Update entry
            if (!items.contains(wrapper)) {
                items.add(wrapper);
            }
            explosiveToItems.put(ex, items);
            return true;
        } else {
            Engine.error("ExplosiveRegistry: Attempt to register item[" + item + "] to " + ex + " when the item was already registered.");
        }
    } else if (item == null) {
        Engine.error("ExplosiveRegistry: Attempt to register null item to " + ex + ".");
    } else if (ex == null) {
        Engine.error("ExplosiveRegistry: Attempt to register item[" + item + "] to null explosive handler.");
    }
    return false;
}
Also used : ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper)

Example 15 with ItemStackWrapper

use of com.builtbroken.mc.prefab.items.ItemStackWrapper in project Engine by VoltzEngine-Project.

the class MassRegistry method getMass.

@Override
public double getMass(ItemStack stack) {
    if (stack != null) {
        double mass;
        Item item = stack.getItem();
        if (item instanceof IItemHasMass) {
            mass = ((IItemHasMass) item).getMass(stack);
            if (mass >= 0) {
                return mass;
            }
        }
        ItemStackWrapper wrapper = new ItemStackWrapper(stack);
        mass = stackMass.get(wrapper);
        return mass >= 0 ? mass : getMass(item);
    }
    return -1;
}
Also used : Item(net.minecraft.item.Item) IItemHasMass(com.builtbroken.mc.api.items.IItemHasMass) ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper)

Aggregations

ItemStackWrapper (com.builtbroken.mc.prefab.items.ItemStackWrapper)21 ItemStack (net.minecraft.item.ItemStack)17 IExplosiveHandler (com.builtbroken.mc.api.explosive.IExplosiveHandler)3 HashMap (java.util.HashMap)2 Block (net.minecraft.block.Block)2 Item (net.minecraft.item.Item)2 ITexturedExplosiveHandler (com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)1 IItemHasMass (com.builtbroken.mc.api.items.IItemHasMass)1 IExplosiveContainerItem (com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem)1 ExplosiveHandlerGeneric (com.builtbroken.mc.prefab.explosive.ExplosiveHandlerGeneric)1 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)1 ArrayList (java.util.ArrayList)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 IIcon (net.minecraft.util.IIcon)1 Test (org.junit.Test)1