Search in sources :

Example 1 with ChaosBuff

use of net.silentchaos512.gems.lib.ChaosBuff in project SilentGems by SilentChaos512.

the class SilentGemsPlugin method registerItemSubtypes.

@Override
public void registerItemSubtypes(ISubtypeRegistry reg) {
    // Tools
    // for (Item item : new Item[] { ModItems.sword, ModItems.katana, ModItems.scepter,
    // ModItems.tomahawk, ModItems.pickaxe, ModItems.shovel, ModItems.axe, ModItems.paxel,
    // ModItems.hoe, ModItems.sickle, ModItems.bow, ModItems.shield }) {
    // reg.registerSubtypeInterpreter(item, new ISubtypeInterpreter() {
    // 
    // @Override
    // public String getSubtypeInfo(ItemStack stack) {
    // 
    // ToolPart[] parts = ToolHelper.getConstructionParts(stack);
    // if (parts.length == 0)
    // return "unknown";
    // return parts[0].getKey();
    // }
    // });
    // }
    // Enchantment tokens
    reg.registerSubtypeInterpreter(ModItems.enchantmentToken, new ISubtypeInterpreter() {

        @Override
        public String getSubtypeInfo(ItemStack stack) {
            Enchantment ench = ModItems.enchantmentToken.getSingleEnchantment(stack);
            if (ench == null)
                return "none";
            return ench.getName();
        }
    });
    // Chaos Runes
    reg.registerSubtypeInterpreter(ModItems.chaosRune, new ISubtypeInterpreter() {

        @Override
        public String getSubtypeInfo(ItemStack stack) {
            ChaosBuff buff = ModItems.chaosRune.getBuff(stack);
            if (buff == null)
                return "none";
            return buff.getKey();
        }
    });
}
Also used : ISubtypeInterpreter(mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter) ItemStack(net.minecraft.item.ItemStack) Enchantment(net.minecraft.enchantment.Enchantment) ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff)

Example 2 with ChaosBuff

use of net.silentchaos512.gems.lib.ChaosBuff in project SilentGems by SilentChaos512.

the class ItemChaosGem method getBuffs.

public Map<ChaosBuff, Integer> getBuffs(ItemStack stack) {
    if (StackHelper.isEmpty(stack) || !stack.hasTagCompound() || !stack.getTagCompound().hasKey(NBT_BUFF_LIST))
        return Maps.newHashMap();
    NBTTagList tagList = stack.getTagCompound().getTagList(NBT_BUFF_LIST, 10);
    Map<ChaosBuff, Integer> map = Maps.newLinkedHashMap();
    if (tagList != null) {
        for (int i = 0; i < tagList.tagCount(); ++i) {
            String key = tagList.getCompoundTagAt(i).getString(NBT_BUFF_KEY);
            int level = tagList.getCompoundTagAt(i).getShort(NBT_BUFF_LEVEL);
            map.put(ChaosBuff.byKey(key), level);
        }
    }
    return map;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff)

Example 3 with ChaosBuff

use of net.silentchaos512.gems.lib.ChaosBuff in project SilentGems by SilentChaos512.

the class ItemChaosGem method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    for (Entry<ChaosBuff, Integer> entry : getBuffs(stack).entrySet()) list.add(TextFormatting.GOLD + entry.getKey().getLocalizedName(entry.getValue()));
    int slotsUsed = getSlotsUsed(stack);
    int totalDrain = getTotalChargeDrain(stack, SilentGems.proxy.getClientPlayer());
    list.add(loc.getItemSubText(itemName, "charge", getCharge(stack), getMaxCharge(stack)));
    list.add(loc.getItemSubText(itemName, "slots", slotsUsed, MAX_SLOTS));
    list.add(loc.getItemSubText(itemName, "drain", totalDrain));
}
Also used : LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff)

Example 4 with ChaosBuff

use of net.silentchaos512.gems.lib.ChaosBuff in project SilentGems by SilentChaos512.

the class ItemChaosGem method setBuffs.

public void setBuffs(ItemStack stack, Map<ChaosBuff, Integer> buffs) {
    if (StackHelper.isEmpty(stack))
        return;
    if (!stack.hasTagCompound())
        stack.setTagCompound(new NBTTagCompound());
    if (stack.getTagCompound().hasKey(NBT_BUFF_LIST))
        stack.getTagCompound().removeTag(NBT_BUFF_LIST);
    NBTTagList tagList = new NBTTagList();
    for (Entry<ChaosBuff, Integer> entry : buffs.entrySet()) {
        ChaosBuff buff = entry.getKey();
        int level = entry.getValue();
        NBTTagCompound compound = new NBTTagCompound();
        compound.setString(NBT_BUFF_KEY, buff.getKey());
        compound.setShort(NBT_BUFF_LEVEL, (short) level);
        tagList.appendTag(compound);
    }
    stack.getTagCompound().setTag(NBT_BUFF_LIST, tagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff)

Example 5 with ChaosBuff

use of net.silentchaos512.gems.lib.ChaosBuff in project SilentGems by SilentChaos512.

the class ColorHandlers method init.

public static void init() {
    ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
    // Tools
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            return ToolRenderHelper.getInstance().getColor(stack, ToolPartPosition.forRenderPass(tintIndex));
        }
    }, ModItems.tools.toArray(new Item[ModItems.tools.size()]));
    // Shields
    itemColors.registerItemColorHandler(new IItemColor() {

        int[] passes = { ToolRenderHelper.PASS_HEAD, ToolRenderHelper.PASS_ROD };

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            if (tintIndex < 0 || tintIndex >= passes.length)
                return 0xFFFFFF;
            return ToolRenderHelper.getInstance().getColor(stack, ToolPartPosition.forRenderPass(tintIndex));
        }
    }, ModItems.shield);
    // Armor (temp)
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            // FIXME: Multiple passes needed?
            return ArmorHelper.getRenderColor(stack, ArmorPartPosition.NORTH);
        }
    }, ModItems.gemHelmet, ModItems.gemChestplate, ModItems.gemLeggings, ModItems.gemBoots);
    // Enchantment Tokens
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            if (tintIndex == 1)
                return ModItems.enchantmentToken.getOutlineColor(stack);
            return 0xFFFFFF;
        }
    }, ModItems.enchantmentToken);
    // Return Home Charm
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            if (tintIndex == 0) {
                int meta = stack.getItemDamage();
                if (meta >= 0 && meta < EnumGem.values().length) {
                    EnumGem gem = EnumGem.values()[meta];
                    return gem.color;
                }
            }
            return 0xFFFFFF;
        }
    }, ModItems.returnHomeCharm);
    // Node Mover
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            return tintIndex != 1 ? 0xFFFFFF : ClientTickHandler.nodeMoverColor.getColor();
        }
    }, ModItems.nodeMover);
    // Drawing Compass
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            return tintIndex == 0 ? ModItems.drawingCompass.getColor(stack).getColor() : 0xFFFFFF;
        }
    }, ModItems.drawingCompass);
    // Chaos Runes
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            if (tintIndex == 1) {
                ChaosBuff buff = ModItems.chaosRune.getBuff(stack);
                if (buff != null) {
                    return buff.getColor();
                }
            }
            return 0xFFFFFF;
        }
    }, ModItems.chaosRune);
    // Holding Gem
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            if (tintIndex == 1) {
                if (stack.hasTagCompound()) {
                    int id = stack.getTagCompound().getShort(ItemHoldingGem.NBT_GEM_ID);
                    if (id >= 0 && id < EnumGem.values().length)
                        return EnumGem.values()[id].color;
                }
            } else if (tintIndex == 2) {
                IBlockState state = ModItems.holdingGem.getBlockPlaced(stack);
                if (state != null) {
                    return 0xFFFFFF;
                // return state.getMapColor().colorValue;
                }
            }
            return 0xFFFFFF;
        }
    }, ModItems.holdingGem);
    // Soul Gems
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            Soul soul = ModItems.soulGem.getSoul(stack);
            if (soul == null) {
                return 0xFFFFFF;
            } else if (tintIndex == 1) {
                return soul.colorSecondary;
            } else {
                return soul.colorPrimary;
            }
        }
    }, ModItems.soulGem);
    // Tool Soul
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            // TODO Auto-generated method stub
            ToolSoul soul = ModItems.toolSoul.getSoul(stack);
            if (soul == null)
                return tintIndex == 1 ? 0xFF00FF : tintIndex == 2 ? 0x0 : 0xFFFFFF;
            switch(tintIndex) {
                case 0:
                    float ratio = 0.5f + MathHelper.sin((float) ClientTickHandler.ticksInGame / 15) / 6;
                    return Color.blend(soul.getPrimaryElement().color, soul.getSecondaryElement().color, ratio);
                case 1:
                    return soul.getPrimaryElement().color;
                case 2:
                    return soul.getSecondaryElement().color;
                default:
                    return 0xFFFFFF;
            }
        }
    }, ModItems.toolSoul);
    // Arrows
    itemColors.registerItemColorHandler(new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            // TODO Auto-generated method stub
            return 0xFFFFFF;
        }
    }, ModItems.arrow);
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) IBlockState(net.minecraft.block.state.IBlockState) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) Soul(net.silentchaos512.gems.item.ItemSoulGem.Soul) ItemColors(net.minecraft.client.renderer.color.ItemColors) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ChaosBuff (net.silentchaos512.gems.lib.ChaosBuff)5 ItemStack (net.minecraft.item.ItemStack)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)2 ISubtypeInterpreter (mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter)1 IBlockState (net.minecraft.block.state.IBlockState)1 IItemColor (net.minecraft.client.renderer.color.IItemColor)1 ItemColors (net.minecraft.client.renderer.color.ItemColors)1 Enchantment (net.minecraft.enchantment.Enchantment)1 Item (net.minecraft.item.Item)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TextFormatting (net.minecraft.util.text.TextFormatting)1 Soul (net.silentchaos512.gems.item.ItemSoulGem.Soul)1 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)1