use of gregtech.api.items.metaitem.MetaOreDictItem in project GregTech by GregTechCEu.
the class MetaItems method init.
public static void init() {
MetaItem1 first = new MetaItem1();
first.setRegistryName("meta_item_1");
MetaTool tool = new MetaTool();
tool.setRegistryName("meta_tool");
CT_OREDICT_ITEM = new MetaOreDictItem((short) 0);
CT_OREDICT_ITEM.setRegistryName("meta_oredict_item_ct");
MetaArmor armor = new MetaArmor();
armor.setRegistryName("gt_armor");
for (OrePrefix prefix : orePrefixes) {
String regName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, prefix.name());
MetaPrefixItem metaOrePrefix = new MetaPrefixItem(prefix);
metaOrePrefix.setRegistryName(String.format("meta_%s", regName));
}
}
use of gregtech.api.items.metaitem.MetaOreDictItem in project GregTech by GregTechCEu.
the class ClientProxy method addMaterialFormulaHandler.
@SubscribeEvent
public static void addMaterialFormulaHandler(@Nonnull ItemTooltipEvent event) {
ItemStack itemStack = event.getItemStack();
// Handles Item tooltips
List<String> tooltips = new ArrayList<>();
// Test for Items
UnificationEntry unificationEntry = OreDictUnifier.getUnificationEntry(itemStack);
if (itemStack.getItem() instanceof MetaOreDictItem) {
// Test for OreDictItems
MetaOreDictItem oreDictItem = (MetaOreDictItem) itemStack.getItem();
Optional<String> oreDictName = OreDictUnifier.getOreDictionaryNames(itemStack).stream().findFirst();
if (oreDictName.isPresent() && oreDictItem.OREDICT_TO_FORMULA.containsKey(oreDictName.get()) && !oreDictItem.OREDICT_TO_FORMULA.get(oreDictName.get()).isEmpty()) {
tooltips.add(TextFormatting.YELLOW + oreDictItem.OREDICT_TO_FORMULA.get(oreDictName.get()));
}
} else if (unificationEntry != null && unificationEntry.material != null) {
if (unificationEntry.material.getChemicalFormula() != null && !unificationEntry.material.getChemicalFormula().isEmpty())
tooltips.add(TextFormatting.YELLOW + unificationEntry.material.getChemicalFormula());
} else if (ItemNBTUtils.hasTag(itemStack)) {
// Test for Fluids
// Vanilla bucket
tooltips = FluidTooltipUtil.getFluidTooltip(ItemNBTUtils.getString(itemStack, "FluidName"));
// GTCE Cells, Forestry cans, some other containers
if (tooltips == null || tooltips.size() == 0) {
NBTTagCompound compound = itemStack.getTagCompound();
if (compound != null && compound.hasKey(FluidHandlerItemStack.FLUID_NBT_KEY, Constants.NBT.TAG_COMPOUND)) {
FluidStack fstack = FluidStack.loadFluidStackFromNBT(compound.getCompoundTag(FluidHandlerItemStack.FLUID_NBT_KEY));
tooltips = FluidTooltipUtil.getFluidTooltip(fstack);
}
}
} else if (itemStack.getItem().equals(Items.WATER_BUCKET)) {
// Water and Lava buckets have a separate registry name from other buckets
tooltips = FluidTooltipUtil.getWaterTooltip();
} else if (itemStack.getItem().equals(Items.LAVA_BUCKET)) {
tooltips = FluidTooltipUtil.getLavaTooltip();
}
if (tooltips != null) {
for (String s : tooltips) {
if (s == null || s.isEmpty())
continue;
event.getToolTip().add(s);
}
}
}
Aggregations