Java Code Examples for net.minecraftforge.fluids.Fluid#getLocalizedName()

The following examples show how to use net.minecraftforge.fluids.Fluid#getLocalizedName() . 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: MiscUtils.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static String getTranslatedFluidName(FluidStack fluidStack) {
	if (fluidStack == null) return "";
	final Fluid fluid = fluidStack.getFluid();
	String localizedName = fluid.getLocalizedName(fluidStack);
	if (!Strings.isNullOrEmpty(localizedName) && !localizedName.equals(fluid.getUnlocalizedName())) {
		return fluid.getRarity(fluidStack).rarityColor.toString() + localizedName;
	} else {
		return TextFormatting.OBFUSCATED + "LOLNOPE" + TextFormatting.RESET;
	}
}
 
Example 2
Source File: WailaDataProvider.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
	List<String> list = currenttip;
	Class clazz = accessor.getClass();
	TileEntity tileEntity = accessor.getTileEntity();
	if (tileEntity instanceof TileEntityMonitorStorageFluid)
	{
		TileEntityMonitorStorageFluid fluidMonitor = (TileEntityMonitorStorageFluid) tileEntity;
		Fluid fluid = fluidMonitor.getFluid();
		String fluidName = fluid != null ? fluid.getLocalizedName() : "-";
		long fluidAmount = fluid != null ? fluidMonitor.getAmount() : 0;

		String amountToText = Long.toString(fluidAmount) + "mB";
		if (Extracells.shortenedBuckets)
		{
			if (fluidAmount > 1000000000L)
				amountToText = Long.toString(fluidAmount / 1000000000L) + "MegaB";
			else if (fluidAmount > 1000000L)
				amountToText = Long.toString(fluidAmount / 1000000L) + "KiloB";
			else if (fluidAmount > 9999L)
			{
				amountToText = Long.toString(fluidAmount / 1000L) + "B";
			}
		}

		list.add(StatCollector.translateToLocal("tooltip.fluid") + ": " + fluidName);
		list.add(StatCollector.translateToLocal("tooltip.amount") + ": " + amountToText);
	}
	return list;
}
 
Example 3
Source File: ItemFluidDisplay.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public String getUnlocalizedName(ItemStack aStack)
{
	if (aStack != null)
	{
		Fluid tFluid = FluidRegistry.getFluid(aStack.getItemDamage());
		if (tFluid != null)
		{
			return tFluid.getLocalizedName();
		}
	}

	return "FluidDisplay - this item is just used to mime fluids!";
}
 
Example 4
Source File: ConfigurationHandler.java    From Moo-Fluids with GNU General Public License v3.0 4 votes vote down vote up
public static void updateFluidConfiguration() {
  try {
    configuration.load();

    for (final Fluid containableFluid : EntityHelper.getContainableFluids().values()) {
      final String containableFluidLocalizedName =
          containableFluid.getLocalizedName(new FluidStack(containableFluid, 0));
      final String entityName = containableFluidLocalizedName + " " + "Cow";
      final EntityTypeData entityTypeData = new EntityTypeData();

      /* Configurable entity data */
      entityTypeData.setSpawnable(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_IS_SPAWNABLE_KEY,
                            ConfigurationData.ENTITY_IS_SPAWNABLE_DEFAULT_VALUE).getBoolean());
      entityTypeData.setSpawnRate(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_SPAWN_RATE_KEY,
                            ConfigurationData.ENTITY_SPAWN_RATE_DEFAULT_VALUE).getInt());
      entityTypeData.setNormalDamageAmount(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_NORMAL_DAMAGE_AMOUNT_KEY,
                            ConfigurationData.ENTITY_NORMAL_DAMAGE_AMOUNT_DEFAULT_VALUE)
              .getInt());
      entityTypeData.setFireDamageAmount(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_FIRE_DAMAGE_AMOUNT_KEY,
                            ConfigurationData.ENTITY_FIRE_DAMAGE_AMOUNT_DEFAULT_VALUE).getInt());
      entityTypeData.setNormalDamageAmount(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_NORMAL_DAMAGE_AMOUNT_KEY,
                            ConfigurationData.ENTITY_NORMAL_DAMAGE_AMOUNT_DEFAULT_VALUE)
              .getInt());
      entityTypeData.setGrowUpTime(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_GROW_UP_TIME_KEY,
                            ConfigurationData.ENTITY_GROW_UP_TIME_DEFAULT_VALUE).getInt());
      entityTypeData.setMaxUseCooldown(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_MAX_USE_COOLDOWN_KEY,
                            ConfigurationData.ENTITY_MAX_USE_COOLDOWN_DEFAULT_VALUE).getInt());
      entityTypeData.setDamagePlayers(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_CAN_DAMAGE_PLAYER_KEY,
                            ConfigurationData.ENTITY_CAN_DAMAGE_PLAYER_DEFAULT_VALUE)
              .getBoolean());
      entityTypeData.setDamageEntities(
          configuration.get(entityName,
                            ConfigurationData.ENTITY_CAN_DAMAGE_OTHER_ENTITIES_KEY,
                            ConfigurationData.ENTITY_CAN_DAMAGE_OTHER_ENTITIES_DEFAULT_VALUE)
              .getBoolean());

      /* Non-configurable entity data */
      entityTypeData.setCauseFireDamage(entityTypeData.getFireDamageAmount() > 0);
      entityTypeData.setCauseNormalDamage(entityTypeData.getNormalDamageAmount() > 0);

      EntityHelper.setEntityData(containableFluid.getName(), entityTypeData);
    }
  } catch (Exception exception) {
    LogHelper.error("Unable to read configuration for " + ModInformation.MOD_NAME);
    LogHelper.error(exception);
  } finally {
    if (configuration.hasChanged()) {
      configuration.save();
    }
  }
}