Search in sources :

Example 1 with ItemStackWrapper

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

the class ExplosiveRegistryClient method getCornerIconFor.

/**
     * Gets the corner icon for the explosive item. Defaults
     * to using {@link ITexturedExplosiveHandler} if the explosive
     * handler implements the interface. If it doesn't then
     * the map will be searched for the item.
     *
     * @param stack
     * @return item or missing icon
     */
public static IIcon getCornerIconFor(final ItemStack stack, int pass) {
    ItemStack item = stack;
    if (item.getItem() instanceof IExplosiveContainerItem) {
        item = ((IExplosiveContainerItem) item.getItem()).getExplosiveStack(stack);
    }
    if (item != null) {
        IExplosiveHandler handler = ExplosiveRegistry.get(item);
        if (handler instanceof ITexturedExplosiveHandler) {
            IIcon icon = ((ITexturedExplosiveHandler) handler).getBottomLeftCornerIcon(item, pass);
            if (icon != null) {
                return icon;
            }
        }
        ItemStackWrapper wrapper = new ItemStackWrapper(item);
        if (EX_CORNER_ICONS.containsKey(wrapper)) {
            return EX_CORNER_ICONS.get(wrapper);
        }
    }
    return missing_corner_icon;
}
Also used : IIcon(net.minecraft.util.IIcon) IExplosiveContainerItem(com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem) ItemStack(net.minecraft.item.ItemStack) IExplosiveHandler(com.builtbroken.mc.api.explosive.IExplosiveHandler) ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper) ITexturedExplosiveHandler(com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)

Example 2 with ItemStackWrapper

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

the class MassRegistry method setMass.

@Override
public void setMass(ItemStack stack, double mass) {
    if (stack != null) {
        ItemStackWrapper wrapper = new ItemStackWrapper(stack);
        if (mass < 0) {
            Engine.logger().error("Mass is negative, setting to positive", new RuntimeException());
        }
        stackMass.put(wrapper, Math.abs(mass));
    } else {
        Engine.logger().error("Item can not be null", new RuntimeException());
    }
}
Also used : ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper)

Example 3 with ItemStackWrapper

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

the class MRItemStack method addInputOption.

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

Example 4 with ItemStackWrapper

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

the class MRItemStack method addInputOption.

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

Example 5 with ItemStackWrapper

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

the class InventoryUtility method mapRecipes.

/**
 * Called to map recipes to items and
 * itemstacks. Used for varies purposes,
 * such as, quicker filter checks, crafting,
 * guis, and commands.
 */
public static void mapRecipes() {
    ITEMSTACK_TO_RECIPES.clear();
    ITEM_TO_RECIPES.clear();
    Engine.logger().info("Mapping basic recipe data...");
    Engine.logger().info("   " + CraftingManager.getInstance().getRecipeList().size() + " recipes detected.");
    long time = System.nanoTime();
    for (Object r : CraftingManager.getInstance().getRecipeList()) {
        if (r instanceof IRecipe && ((IRecipe) r).getRecipeOutput() != null) {
            ItemStackWrapper wrapper = new ItemStackWrapper(((IRecipe) r).getRecipeOutput());
            List<IRecipe> list = ITEMSTACK_TO_RECIPES.get(wrapper);
            if (list == null) {
                list = new ArrayList();
            }
            list.add((IRecipe) r);
            ITEMSTACK_TO_RECIPES.put(wrapper, list);
            ITEM_TO_RECIPES.put(((IRecipe) r).getRecipeOutput().getItem(), list);
        }
    }
    Engine.logger().info(" Done in.. " + StringHelpers.formatNanoTime(System.nanoTime() - time));
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) ArrayList(java.util.ArrayList) ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper)

Aggregations

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