net.minecraft.item.EnumRarity Java Examples

The following examples show how to use net.minecraft.item.EnumRarity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LabParts.java    From bartworks with MIT License 6 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack itemStack) {

    if (itemStack == null || itemStack.getTagCompound() == null)
        return EnumRarity.common;

    switch (itemStack.getItemDamage()) {
        case 0:
            return BW_Util.getRarityFromByte(itemStack.getTagCompound().getCompoundTag("DNA").getByte("Rarity"));
        case 1:
        case 2:
            return BW_Util.getRarityFromByte(itemStack.getTagCompound().getByte("Rarity"));
        default:
            return EnumRarity.common;
    }
}
 
Example #2
Source File: MultiblockInfoRecipeWrapper.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY) {
    if (tooltipBlockStack != null && !tooltipBlockStack.isEmpty() && !Mouse.isButtonDown(0)) {
        Minecraft minecraft = Minecraft.getMinecraft();
        ITooltipFlag flag = minecraft.gameSettings.advancedItemTooltips ? TooltipFlags.ADVANCED : TooltipFlags.NORMAL;
        List<String> tooltip = tooltipBlockStack.getTooltip(minecraft.player, flag);
        EnumRarity rarity = tooltipBlockStack.getRarity();
        for (int k = 0; k < tooltip.size(); ++k) {
            if (k == 0) {
                tooltip.set(k, rarity.rarityColor + tooltip.get(k));
            } else {
                tooltip.set(k, TextFormatting.GRAY + tooltip.get(k));
            }
        }
        return tooltip;
    }
    return Collections.emptyList();
}
 
Example #3
Source File: ExtendedFluidCollection.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
private static void populateAmmonia()
{
    Fluid tAmmoniaFluid = ModFluidManager.GetNewFluid("Ammonia");
    tAmmoniaFluid.setGaseous(true);
    tAmmoniaFluid.setViscosity(-500);
    tAmmoniaFluid.setDensity(0);
    tAmmoniaFluid.setLuminosity(8);
    tAmmoniaFluid.setTemperature(300);
    tAmmoniaFluid.setRarity(EnumRarity.epic); // The rarity of the fluid. Used primarily in tool tips.
    
    _mAmmonia = new ModSimpleBaseFluid(tAmmoniaFluid, Material.water);

    
    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after 
    // the player has left the pool.
    //_mAmmonia.addPotionEffect(new PotionEffect(Potion.blindness.id, 2, 0));
    
    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mAmmonia.addStackingPotionEffect(new PotionEffect(bop_loaded?24:Potion.poison.id, 20, 0));
    
    _mAmmonia.setRegisterBucket(false); // don't register a bucket
}
 
Example #4
Source File: BW_Util.java    From bartworks with MIT License 5 votes vote down vote up
public static byte getByteFromRarity(EnumRarity rarity) {
    if (rarity.equals(EnumRarity.uncommon))
        return 1;
    else if (rarity.equals(EnumRarity.epic))
        return 2;
    else if (rarity.equals(EnumRarity.rare))
        return 3;
    return 0;
}
 
Example #5
Source File: BioCulture.java    From bartworks with MIT License 5 votes vote down vote up
protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA, EnumRarity rarity, boolean bBreedable) {
    super(name, ID, rarity);
    this.color = color;
    this.plasmid = plasmid;
    this.dDNA = dDNA;
    this.bBreedable = bBreedable;
}
 
Example #6
Source File: BW_Util.java    From bartworks with MIT License 5 votes vote down vote up
public static EnumRarity getRarityFromByte(byte b) {
    switch (b) {
        case 1:
            return EnumRarity.uncommon;
        case 2:
            return EnumRarity.rare;
        case 3:
            return EnumRarity.epic;
        default:
            return EnumRarity.common;
    }
}
 
Example #7
Source File: ExtendedFluidCollection.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
private static void populatePollution()
{
    Fluid tPollution = ModFluidManager.GetNewFluid("Pollution");
    tPollution.setGaseous(false);
    tPollution.setViscosity(1);
    tPollution.setDensity(1);
    tPollution.setLuminosity(0);
    tPollution.setTemperature(295);
    tPollution.setRarity(EnumRarity.epic); // The rarity of the fluid. Used primarily in tool tips.

    _mPollution = new ModSimpleBaseFluid(tPollution, Material.water);


    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after
    // the player has left the pool.
    _mPollution.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3));

    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mPollution.addStackingPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3));
    _mPollution.addStackingPotionEffect(new PotionEffect(Potion.poison.id, 10, 0));

    _mPollution.setRegisterBucket(true); // don't register a bucket
}
 
Example #8
Source File: GTItemEnergyPack.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GTItemEnergyPack(int index, String tex, int max, String reg, String unl, int lvl, int limit) {
	super(index, EntityEquipmentSlot.CHEST);
	this.indexitem = index;
	this.setMaxDamage(0);
	this.texture = tex;
	this.maxEnergy = max;
	this.setRegistryName(reg);
	this.setUnlocalizedName(GTMod.MODID + unl);
	this.setCreativeTab(GTMod.creativeTabGT);
	this.tier = lvl; // 1;
	this.transferlimit = limit;
	this.rare = EnumRarity.COMMON;
}
 
Example #9
Source File: BioData.java    From bartworks with MIT License 5 votes vote down vote up
protected BioData(String name, int ID, EnumRarity rarity) {
    this.name = name;
    this.ID = ID;
    this.rarity = rarity;
    this.chance = 7500;
    this.tier = 0;
}
 
Example #10
Source File: ItemMeta.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack itemStack) {
    MetaItem metaItem = this.getMetaItem(itemStack);
    if (metaItem != null) {
        return metaItem.rarity;
    }
    return super.getRarity(itemStack);
}
 
Example #11
Source File: ItemMeta.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
public MetaItem(String name, String tooltipKey, EnumRarity rarity, boolean glow, boolean hidden) {
    this.name = name;
    this.tooltipKey = tooltipKey;
    this.rarity = rarity;
    this.glow = glow;
    this.hidden = hidden;
}
 
Example #12
Source File: ExtendedFluidCollection.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
private static void populateNitricAcid()
{
    Fluid tNitricAcidFluid = ModFluidManager.GetNewFluid("NitricAcid");
    tNitricAcidFluid.setGaseous(false);
    tNitricAcidFluid.setViscosity(1000);
    tNitricAcidFluid.setDensity(1);
    tNitricAcidFluid.setLuminosity(0);
    tNitricAcidFluid.setTemperature(300);
    tNitricAcidFluid.setRarity(EnumRarity.epic); // The rarity of the fluid. Used primarily in tool tips.

    _mNitricAcid = new ModSimpleBaseFluid(tNitricAcidFluid, Material.water);


    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after
    // the player has left the pool.
    _mNitricAcid.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1));

    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mNitricAcid.addStackingPotionEffect(new PotionEffect(Potion.poison.id, 10, 0));

    _mNitricAcid.setRegisterBucket(true); // don't register a bucket
}
 
Example #13
Source File: ItemPack.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack stack) {
    T pack = this.getPack(stack);
    if (pack != null) {
        return pack.rarity;
    }
    return super.getRarity(stack);
}
 
Example #14
Source File: BlockWisdomSapling.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getBlockRarity(@NotNull ItemStack stack) {
	return EnumRarity.UNCOMMON;
}
 
Example #15
Source File: CraftingHelper.java    From malmo with MIT License 4 votes vote down vote up
/**
 * Little utility method for dumping out a list of all the Minecraft items, plus as many useful attributes as
 * we can find for them. This is primarily used by decision_tree_test.py but might be useful for real-world applications too.
 *
 * @param filename location to save the dumped list.
 * @throws IOException
 */
public static void dumpItemProperties(String filename) throws IOException {
    FileOutputStream fos = new FileOutputStream("..//..//build//install//Python_Examples//item_database.json");
    OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
    BufferedWriter writer = new BufferedWriter(osw);
    JsonArray itemTypes = new JsonArray();
    for (ResourceLocation i : Item.REGISTRY.getKeys()) {
        Item item = Item.REGISTRY.getObject(i);
        if (item != null) {
            JsonObject json = new JsonObject();
            json.addProperty("type", Item.REGISTRY.getNameForObject(item).toString().replace("minecraft:", ""));
            json.addProperty("damageable", item.isDamageable());
            json.addProperty("rendersIn3D", item.isFull3D());
            json.addProperty("repairable", item.isRepairable());
            CreativeTabs tab = item.getCreativeTab();
            json.addProperty("tab", ((tab != null) ? item.getCreativeTab().getTabLabel() : "none"));
            ItemStack is = item.getDefaultInstance();
            json.addProperty("stackable", is.isStackable());
            json.addProperty("enchantable", is.isItemEnchantable());
            json.addProperty("rare", (is.getRarity() == EnumRarity.RARE));    // Enum has four types, but only two (COMMON and RARE) appear to be used.
            json.addProperty("action", is.getItemUseAction().toString());
            json.addProperty("hasSubtypes", item.getHasSubtypes());
            json.addProperty("maxDamage", is.getMaxDamage());
            json.addProperty("maxUseDuration", is.getMaxItemUseDuration());
            json.addProperty("block", item instanceof ItemBlock);
            json.addProperty("hasContainerItem", item.hasContainerItem());
            if (item instanceof ItemBlock) {
                ItemBlock ib = (ItemBlock) item;
                Block b = ib.getBlock();
                IBlockState bs = b.getDefaultState();
                json.addProperty("slipperiness", b.slipperiness);
                json.addProperty("hardness", bs.getBlockHardness(null, null));
                json.addProperty("causesSuffocation", bs.causesSuffocation());
                json.addProperty("canProvidePower", bs.canProvidePower());
                json.addProperty("translucent", bs.isTranslucent());
                Material mat = bs.getMaterial();
                if (mat != null) {
                    json.addProperty("canBurn", mat.getCanBurn());
                    json.addProperty("isLiquid", mat.isLiquid());
                    json.addProperty("blocksMovement", mat.blocksMovement());
                    json.addProperty("needsNoTool", mat.isToolNotRequired());
                    json.addProperty("isReplaceable", mat.isReplaceable());
                    json.addProperty("pistonPushable", mat.getMobilityFlag() == EnumPushReaction.NORMAL);
                    json.addProperty("woodenMaterial", mat == Material.WOOD);
                    json.addProperty("ironMaterial", mat == Material.IRON);
                    json.addProperty("glassyMaterial", mat == Material.GLASS);
                    json.addProperty("clothMaterial", mat == Material.CLOTH);
                }

                boolean hasDirection = false;
                boolean hasColour = false;
                boolean hasVariant = false;
                for (IProperty prop : bs.getProperties().keySet()) {
                    System.out.println(Item.REGISTRY.getNameForObject(item).toString() + " -- " + prop);
                    if (prop instanceof PropertyDirection)
                        hasDirection = true;
                    if (prop instanceof PropertyEnum && prop.getName().equals("color"))
                        hasColour = true;
                    if (prop instanceof PropertyEnum && prop.getName().equals("variant")) {
                        hasVariant = true;
                        json.addProperty("variant", bs.getValue(prop).toString());
                    }
                }
                json.addProperty("hasDirection", hasDirection);
                json.addProperty("hasColour", hasColour);
                json.addProperty("hasVariant", hasVariant);
            }
            itemTypes.add(json);
        }
    }
    writer.write(itemTypes.toString());
    writer.close();
}
 
Example #16
Source File: ItemBlockKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack p_77613_1_) {
    return RegisteredItems.raritySacred;
}
 
Example #17
Source File: ItemGolemCoreBreak.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack stack) {
    return EnumRarity.uncommon;
}
 
Example #18
Source File: ItemBlockRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack stack) {
    return EnumRarity.uncommon;
}
 
Example #19
Source File: ItemDiamondApple.java    From Production-Line with MIT License 4 votes vote down vote up
/**
 * Return an item rarity from EnumRarity
 */
@Nonnull
public EnumRarity getRarity(ItemStack itemStack) {
    return itemStack.getItemDamage() == 0 ? EnumRarity.RARE : EnumRarity.EPIC;
}
 
Example #20
Source File: ItemDivineOrb.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack itemstack) {
    return EnumRarity.epic;
}
 
Example #21
Source File: ItemStorageComponent.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public EnumRarity getRarity(ItemStack par1)
{
	return EnumRarity.epic;
}
 
Example #22
Source File: ItemBook.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.UNCOMMON;
}
 
Example #23
Source File: ItemFocusBasic.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack focusstack)
   {
       return EnumRarity.rare;
   }
 
Example #24
Source File: ItemFairyImbuedApple.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.UNCOMMON;
}
 
Example #25
Source File: ItemCreativeHaloHead.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.EPIC;
}
 
Example #26
Source File: ItemMorphPickaxe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
@Override
public EnumRarity getRarity(ItemStack itemstack) {
    return EnumRarity.epic;
}
 
Example #27
Source File: ItemRealHaloBauble.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.RARE;
}
 
Example #28
Source File: ItemRealHaloHead.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.RARE;
}
 
Example #29
Source File: ItemFakeHaloBauble.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.UNCOMMON;
}
 
Example #30
Source File: ItemStaff.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public EnumRarity getRarity(ItemStack stack) {
	return EnumRarity.UNCOMMON;
}