2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("StringUtil.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.util;
|
2015-03-29 15:29:05 +02:00
|
|
|
|
2015-12-22 14:55:10 +01:00
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.text.translation.I18n;
|
2015-12-27 21:56:32 +01:00
|
|
|
import net.minecraftforge.fluids.FluidTank;
|
2015-08-01 00:40:29 +02:00
|
|
|
|
2015-12-22 14:55:10 +01:00
|
|
|
import java.util.List;
|
2015-08-24 17:57:11 +02:00
|
|
|
|
2015-03-29 15:29:05 +02:00
|
|
|
public class StringUtil{
|
|
|
|
|
|
|
|
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
2015-04-19 01:50:02 +02:00
|
|
|
public static final int DECIMAL_COLOR_GRAY_TEXT = 4210752;
|
2015-03-29 15:29:05 +02:00
|
|
|
|
2016-04-20 21:39:03 +02:00
|
|
|
public static final String BUGGED_ITEM_NAME = ModUtil.MOD_ID+".lolWutHowUDoDis";
|
2015-11-23 19:06:07 +01:00
|
|
|
|
2015-08-01 00:40:29 +02:00
|
|
|
/**
|
|
|
|
* Localizes a given String via StatCollector
|
|
|
|
*/
|
|
|
|
public static String localize(String text){
|
2016-03-18 23:47:22 +01:00
|
|
|
return I18n.translateToLocal(text);
|
2015-08-01 00:40:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Localizes a given formatted String with the given Replacements
|
|
|
|
*/
|
2015-10-02 16:48:01 +02:00
|
|
|
public static String localizeFormatted(String text, Object... replace){
|
2016-03-18 23:47:22 +01:00
|
|
|
return I18n.translateToLocalFormatted(text, replace);
|
2015-08-01 00:40:29 +02:00
|
|
|
}
|
2015-08-24 17:57:11 +02:00
|
|
|
|
2015-12-23 20:42:20 +01:00
|
|
|
public static void drawSplitString(FontRenderer renderer, String strg, int x, int y, int width, int color, boolean shadow){
|
2015-12-22 14:55:10 +01:00
|
|
|
List list = renderer.listFormattedStringToWidth(strg, width);
|
2015-12-23 20:42:20 +01:00
|
|
|
for(int i = 0; i < list.size(); i++){
|
|
|
|
String s1 = (String)list.get(i);
|
|
|
|
renderer.drawString(s1, x, y+(i*renderer.FONT_HEIGHT), color, shadow);
|
2015-12-22 14:55:10 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-27 21:56:32 +01:00
|
|
|
|
|
|
|
public static String getFluidInfo(FluidTank tank){
|
|
|
|
return tank.getFluid() == null || tank.getFluid().getFluid() == null ? "0/"+tank.getCapacity()+" mB" : tank.getFluidAmount()+"/"+tank.getCapacity()+" mB "+tank.getFluid().getLocalizedName();
|
|
|
|
}
|
2015-03-29 15:29:05 +02:00
|
|
|
}
|