A whole lot of formatting cleanup

Also changes NBTHolder to a standard Constants class with subclasses for each category
This commit is contained in:
Nick 2015-11-28 18:25:46 -08:00
parent f9802900db
commit 34dee6447b
74 changed files with 861 additions and 662 deletions

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.util.helper;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
@ -14,15 +14,15 @@ import net.minecraftforge.client.model.ModelLoader;
/**
* @author <a href="https://github.com/TehNut">TehNut</a>
*
* The goal of this class is to make registering the inventory renders
* for your Items/Blocks a much simpler and easier process.
*
* You must call this at the post initialization stage on
* the clientside only.
*
* If you pass a Block through here that uses the default
* ItemBlock, you should specify a custom name.
* <p/>
* The goal of this class is to make registering the inventory renders
* for your Items/Blocks a much simpler and easier process.
* <p/>
* You must call this at the post initialization stage on
* the clientside only.
* <p/>
* If you pass a Block through here that uses the default
* ItemBlock, you should specify a custom name.
*/
public class InventoryRenderHelper {
@ -31,7 +31,7 @@ public class InventoryRenderHelper {
* your modid in all lowercase with a colon at the end.
*/
private final String domain;
public InventoryRenderHelper(String domain) {
this.domain = domain;
}
@ -102,7 +102,7 @@ public class InventoryRenderHelper {
ModelLoader.setCustomMeshDefinition(InventoryRenderHelper.getItemFromBlock(block), new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(BloodMagic.DOMAIN + toRender.getClass().getSimpleName(), "fluid");
return new ModelResourceLocation(Constants.Mod.DOMAIN + toRender.getClass().getSimpleName(), "fluid");
}
});
ModelLoader.setCustomStateMapper(block, new StateMapperBase() {
@ -114,14 +114,20 @@ public class InventoryRenderHelper {
}
/**
*
* @param block - Block to get Item of
* @return - The ItemBlock that corresponds to the Block.
*
* @return - The ItemBlock that corresponds to the Block.
*/
public static Item getItemFromBlock(Block block) {
return Item.getItemFromBlock(block);
}
/**
* Finds the class name of the given Item. If handed an ItemBlock, it will
* use the class name of the contained Block.
*
* @return The class name of the given Item
*/
private static String getClassName(Item item) {
return item instanceof ItemBlock ? Block.getBlockFromItem(item).getClass().getSimpleName() : item.getClass().getSimpleName();
}

View file

@ -1,8 +1,9 @@
package WayofTime.bloodmagic.util.helper;
import com.google.common.collect.Lists;
import net.minecraft.util.StatCollector;
import org.apache.commons.lang3.text.WordUtils;
import java.util.ArrayList;
import java.util.List;
public class TextHelper {
@ -11,30 +12,51 @@ public class TextHelper {
return string.replaceAll("&", "\u00A7");
}
public static String localize(String key, Object ... format) {
return getFormattedText(StatCollector.translateToLocalFormatted(key, format));
public static String localize(String input, Object... format) {
return StatCollector.translateToLocalFormatted(input, format);
}
/**
* Localizes all strings in a list, using the prefix.
*
* @param unloc
* The list of unlocalized strings.
* @return A list of localized versions of the passed strings.
*/
public static List<String> localizeAll(List<String> unloc) {
List<String> ret = Lists.newArrayList();
for (String s : unloc)
ret.add(localize(s));
public static String localizeEffect(String input, Object... format) {
return localize(input.replaceAll("&", "\u00A7"), format);
}
public static String[] localizeAll(String[] input) {
String[] ret = new String[input.length];
for (int i = 0; i < input.length; i++)
ret[i] = localize(input[i]);
return ret;
}
public static String[] localizeAll(String... unloc) {
String[] ret = new String[unloc.length];
for (int i = 0; i < ret.length; i++)
ret[i] = localize(unloc[i]);
public static String[] localizeAllEffect(String[] input) {
String[] ret = new String[input.length];
for (int i = 0; i < input.length; i++)
ret[i] = localizeEffect(input[i]);
return ret;
}
public static ArrayList<String> localizeAll(List<String> input) {
ArrayList<String> ret = new ArrayList<String>(input.size());
for (int i = 0; i < input.size(); i++)
ret.add(i, localize(input.get(i)));
return ret;
}
public static ArrayList<String> localizeAllEffect(List<String> input) {
ArrayList<String> ret = new ArrayList<String>(input.size());
for (int i = 0; i < input.size(); i++)
ret.add(i, localizeEffect(input.get(i)));
return ret;
}
public static String[] cutLongString(String string, int characters) {
return WordUtils.wrap(string, characters, "/cut", false).split("/cut");
}
public static String[] cutLongString(String string) {
return cutLongString(string, 30);
}
}