Search in sources :

Example 1 with EnumRarity

use of net.minecraft.item.EnumRarity in project ImmersiveEngineering by BluSunrize.

the class EventHandler method onLivingDrops.

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    if (!event.isCanceled() && !event.getEntityLiving().isNonBoss()) {
        EnumRarity r = EnumRarity.EPIC;
        for (Class<? extends EntityLiving> boring : listOfBoringBosses) if (boring.isAssignableFrom(event.getEntityLiving().getClass()))
            return;
        ItemStack bag = new ItemStack(IEContent.itemShaderBag);
        ItemNBTHelper.setString(bag, "rarity", r.toString());
        event.getDrops().add(new EntityItem(event.getEntityLiving().worldObj, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, bag));
    }
}
Also used : EnumRarity(net.minecraft.item.EnumRarity) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EnumRarity

use of net.minecraft.item.EnumRarity in project Railcraft by Railcraft.

the class StandardTank method getFluidNameToolTip.

protected ToolTipLine getFluidNameToolTip(Fluid fluid) {
    EnumRarity rarity = fluid.getRarity();
    if (rarity == null)
        rarity = EnumRarity.COMMON;
    ToolTipLine fluidName = new ToolTipLine(fluid.getLocalizedName(getFluid()), rarity.rarityColor);
    fluidName.setSpacing(2);
    return fluidName;
}
Also used : EnumRarity(net.minecraft.item.EnumRarity) ToolTipLine(mods.railcraft.common.gui.tooltips.ToolTipLine)

Example 3 with EnumRarity

use of net.minecraft.item.EnumRarity in project ImmersiveEngineering by BluSunrize.

the class ItemShaderBag method getSubItems.

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
    for (int i = ShaderRegistry.sortedRarityMap.size() - 1; i >= 0; i--) {
        EnumRarity rarity = ShaderRegistry.sortedRarityMap.get(i);
        ItemStack s = new ItemStack(item);
        ItemNBTHelper.setString(s, "rarity", rarity.toString());
        list.add(s);
    }
}
Also used : EnumRarity(net.minecraft.item.EnumRarity) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with EnumRarity

use of net.minecraft.item.EnumRarity in project ImmersiveEngineering by BluSunrize.

the class ShaderRegistry method compileWeight.

public static void compileWeight() {
    totalWeight.clear();
    chestLootShaders.clear();
    for (ShaderRegistryEntry entry : shaderRegistry.values()) {
        if (entry.getIsBagLoot()) {
            int entryRarityWeight = rarityWeightMap.get(entry.getRarity());
            for (Map.Entry<EnumRarity, Integer> weightedRarity : rarityWeightMap.entrySet()) if (entry.getIsInLowerBags() ? (weightedRarity.getValue() >= entryRarityWeight) : (weightedRarity.getValue() == entryRarityWeight)) {
                int i = totalWeight.containsKey(weightedRarity.getKey()) ? totalWeight.get(weightedRarity.getKey()) : 0;
                totalWeight.put(weightedRarity.getKey(), i + entry.getWeight());
            }
        }
        if (entry.getIsCrateLoot())
            for (int i = 0; i < entry.getWeight(); i++) chestLootShaders.add(entry.getName());
    }
    sortedRarityMap.clear();
    sortedRarityMap.addAll(ShaderRegistry.rarityWeightMap.keySet());
    Collections.sort(sortedRarityMap, new Comparator<EnumRarity>() {

        @Override
        public int compare(EnumRarity enum0, EnumRarity enum1) {
            return Integer.compare(ShaderRegistry.rarityWeightMap.get(enum0), ShaderRegistry.rarityWeightMap.get(enum1));
        }
    });
    if (manualEntry != null) {
        ArrayList<PositionedItemStack[]> recipes = new ArrayList();
        ItemStack[] shaderBags = new ItemStack[ShaderRegistry.sortedRarityMap.size()];
        recipes = new ArrayList();
        for (int i = 0; i < ShaderRegistry.sortedRarityMap.size(); i++) {
            EnumRarity outputRarity = ShaderRegistry.sortedRarityMap.get(i);
            shaderBags[i] = new ItemStack(itemShaderBag);
            shaderBags[i].setTagCompound(new NBTTagCompound());
            shaderBags[i].getTagCompound().setString("rarity", outputRarity.toString());
            ArrayList<EnumRarity> upperRarities = ShaderRegistry.getHigherRarities(outputRarity);
            if (!upperRarities.isEmpty()) {
                ArrayList<ItemStack> inputList = new ArrayList();
                for (EnumRarity r : upperRarities) {
                    ItemStack bag = new ItemStack(itemShaderBag);
                    bag.setTagCompound(new NBTTagCompound());
                    bag.getTagCompound().setString("rarity", r.toString());
                    inputList.add(bag);
                }
                ItemStack s0 = new ItemStack(itemShaderBag, 2);
                s0.setTagCompound(new NBTTagCompound());
                s0.getTagCompound().setString("rarity", outputRarity.toString());
                if (!inputList.isEmpty())
                    recipes.add(new PositionedItemStack[] { new PositionedItemStack(inputList, 33, 0), new PositionedItemStack(s0, 69, 0) });
            //					inputList = new ArrayList();
            //					for(ShaderRegistryEntry entry : ShaderRegistry.shaderRegistry.values())
            //						if(upperRarities.contains(entry.getRarity()))
            //						{
            //							ItemStack shader = new ItemStack(itemShader);
            //							shader.setTagCompound(new NBTTagCompound());
            //							shader.getTagCompound().setString("shader_name",  entry.getName());
            //							inputList.add(shader);
            //						}
            //					ItemStack s1 = new ItemStack(itemShaderBag);
            //					s1.setTagCompound(new NBTTagCompound());
            //					s1.getTagCompound().setString("rarity", outputRarity.toString());
            //					if(!inputList.isEmpty())
            //						recipes.add(new PositionedItemStack[]{ new PositionedItemStack(inputList, 33, 0), new PositionedItemStack(s1, 69, 0)});
            }
        }
        manualEntry.getPages()[2] = new ManualPages.ItemDisplay(ManualHelper.getManual(), "shader2", shaderBags);
        manualEntry.getPages()[3] = new ManualPages.CraftingMulti(ManualHelper.getManual(), "shader3", (Object[]) recipes.toArray(new PositionedItemStack[recipes.size()][3]));
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumRarity(net.minecraft.item.EnumRarity) PositionedItemStack(blusunrize.lib.manual.ManualPages.PositionedItemStack) ManualPages(blusunrize.lib.manual.ManualPages) PositionedItemStack(blusunrize.lib.manual.ManualPages.PositionedItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EnumRarity

use of net.minecraft.item.EnumRarity in project ImmersiveEngineering by BluSunrize.

the class ShaderRegistry method getAllHigherRarities.

public static ArrayList<EnumRarity> getAllHigherRarities(EnumRarity rarity) {
    ArrayList<EnumRarity> list = new ArrayList<EnumRarity>();
    int idx = sortedRarityMap.indexOf(rarity);
    if (idx <= 0)
        return list;
    int next = idx - 1;
    int weight = rarityWeightMap.get(rarity);
    for (; next >= 0; next--) {
        EnumRarity r = sortedRarityMap.get(next);
        int rWeight = rarityWeightMap.get(r);
        if (rWeight < weight)
            list.add(r);
    }
    return list;
}
Also used : EnumRarity(net.minecraft.item.EnumRarity)

Aggregations

EnumRarity (net.minecraft.item.EnumRarity)7 ItemStack (net.minecraft.item.ItemStack)4 ManualPages (blusunrize.lib.manual.ManualPages)1 PositionedItemStack (blusunrize.lib.manual.ManualPages.PositionedItemStack)1 ToolTipLine (mods.railcraft.common.gui.tooltips.ToolTipLine)1 EntityItem (net.minecraft.entity.item.EntityItem)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1