New Localization System Implemented :D
This commit is contained in:
parent
7816fb82b8
commit
3363c4561f
41 changed files with 468 additions and 428 deletions
35
common/MysticStones/Util/Config.java
Normal file
35
common/MysticStones/Util/Config.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package MysticStones.Util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public static Configuration config;
|
||||
|
||||
public static int PlanksID;
|
||||
public static int StonesID;
|
||||
public static int StoneBricksID;
|
||||
public static int ReinforcedBricksID;
|
||||
|
||||
public static boolean Rare;
|
||||
|
||||
public static void initialize(File file)
|
||||
{
|
||||
config = new Configuration(file);
|
||||
|
||||
PlanksID = config.getBlock("Plank IDs", 509).getInt();
|
||||
StonesID = config.getBlock("Stone IDs", 510).getInt();
|
||||
StoneBricksID = config.getBlock("Stone Brick IDs", 511).getInt();
|
||||
ReinforcedBricksID = config.getBlock("Reinforced Brick IDs", 512).getInt();
|
||||
Rare = config.get("General", "Increase the Rarity of Stones?", false).getBoolean(Rare);
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
112
common/MysticStones/Util/Localizations.java
Normal file
112
common/MysticStones/Util/Localizations.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
package MysticStones.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
import MysticStones.MysticStones;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
/*
|
||||
*
|
||||
* All credits go to copygirl (or copy....boy) for this one
|
||||
* Couldn't have done any of this without your
|
||||
* repository, many thanks friend c:
|
||||
*
|
||||
*/
|
||||
|
||||
public class Localizations
|
||||
{
|
||||
private Localizations(){}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
File source = Loader.instance().getReversedModObjectList().get(MysticStones.instance).getSource();
|
||||
Pattern pattern = Pattern.compile(".*(assets/" + "mysticmods/lang/(.+)\\.(.+))");
|
||||
for(String file : getResources(source, pattern))
|
||||
{
|
||||
Matcher matcher = pattern.matcher(file);
|
||||
matcher.find();
|
||||
String resource = "/" + matcher.group(1);
|
||||
String lang = matcher.group(2);
|
||||
boolean isXML = matcher.group(3).equalsIgnoreCase("XML");
|
||||
LanguageRegistry.instance().loadLocalization(resource, lang, isXML);
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<String> getResources(File file, Pattern pattern)
|
||||
{
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
if(file.isDirectory())
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
else retval.addAll(getResourcesFromJarFile(file, pattern));
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern)
|
||||
{
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
ZipFile Zip;
|
||||
try
|
||||
{
|
||||
Zip = new ZipFile(file);
|
||||
}
|
||||
catch (ZipException Ex)
|
||||
{
|
||||
throw new Error(Ex);
|
||||
}
|
||||
catch(IOException Ex)
|
||||
{
|
||||
throw new Error(Ex);
|
||||
}
|
||||
Enumeration<? extends ZipEntry> entries = Zip.entries();
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
ZipEntry ZipE = entries.nextElement();
|
||||
String FileName = ZipE.getName();
|
||||
boolean accept = pattern.matcher(FileName).matches();
|
||||
if(accept)
|
||||
retval.add(FileName);
|
||||
}
|
||||
try
|
||||
{
|
||||
Zip.close();
|
||||
}
|
||||
catch(IOException Ex)
|
||||
{
|
||||
throw new Error(Ex);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromDirectory(File directory, Pattern pattern)
|
||||
{
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
File[] FileList = directory.listFiles();
|
||||
for (File file : FileList)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
}
|
||||
else try
|
||||
{
|
||||
String fileName = file.getCanonicalPath().replace('\\', '/');
|
||||
boolean accept = pattern.matcher(fileName).matches();
|
||||
if (accept) retval.add(fileName);
|
||||
}
|
||||
catch(final IOException e)
|
||||
{
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
180
common/MysticStones/Util/RecipeHandler.java
Normal file
180
common/MysticStones/Util/RecipeHandler.java
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
package MysticStones.Util;
|
||||
|
||||
import MysticStones.MysticStones;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class RecipeHandler
|
||||
{
|
||||
public static void CraftPlanks()
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 0),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 0)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 0),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 1)}));
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 1),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 2)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 1),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 3)}));
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 2),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 4)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 2),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 5)}));
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 3),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 6)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 3),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 7)}));
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 4),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 8)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 4),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 9)}));
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 5),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 10)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 5),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 11)}));
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 6),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 12)}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(MysticStones.Planks, 1, 6),
|
||||
new Object[]{"plankWood", new ItemStack(MysticStones.Stones, 1, 13)}));
|
||||
}
|
||||
|
||||
public static void CraftReinforced()
|
||||
{
|
||||
if(Loader.isModLoaded("MysticOres"))
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 0), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "ingotMithril", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 1), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "ingotVerdite", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 2), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "ingotIridium", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 3), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "ingotAdamantine", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 4), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "gemTourmaline", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 5), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "gemTopaz", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 6), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "gemAmethyst", Character.valueOf('X'), Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 7), new Object[] {
|
||||
"X#X", "###", "X#X", Character.valueOf('#'), "gemAgate", Character.valueOf('X'), Block.stone}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void CraftStoneBricks()
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 0), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 0)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 1), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 2)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 2), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 4)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 3), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 6)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 4), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 8)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 5), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 10)
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(MysticStones.StoneBricks, 4, 6), new Object[] {
|
||||
"##", "##", '#', new ItemStack(MysticStones.Stones, 1, 12)
|
||||
});
|
||||
}
|
||||
|
||||
public static void CraftElse()
|
||||
{
|
||||
|
||||
if(Loader.isModLoaded("Mystic Ores") == true)
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 0),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "ingotMithril", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 1),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "ingotVerdite", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 2),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "ingotIridium", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 3),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "ingotAdamantine", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 4),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "gemTourmaline", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 5),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "gemTopaz", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 6),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "gemAmethyst", '#', Block.stone}));
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MysticStones.ReinforcedBricks, 1, 7),
|
||||
true, new Object[]{"#$#", "$$$", "#$#", '$', "gemAgate", '#', Block.stone}));
|
||||
}
|
||||
|
||||
//smelting
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 1, new ItemStack(MysticStones.Stones, 1, 0), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 3, new ItemStack(MysticStones.Stones, 1, 2), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 5, new ItemStack(MysticStones.Stones, 1, 4), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 7, new ItemStack(MysticStones.Stones, 1, 6), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 9, new ItemStack(MysticStones.Stones, 1, 8), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 11, new ItemStack(MysticStones.Stones, 1, 10), 0.1F);
|
||||
FurnaceRecipes.smelting().addSmelting(MysticStones.Stones.blockID, 13, new ItemStack(MysticStones.Stones, 1, 12), 0.1F);
|
||||
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
OreDictionary.registerOre("plankWood", new ItemStack(MysticStones.Planks, 1, i));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
20
common/MysticStones/Util/TabMysticStones.java
Normal file
20
common/MysticStones/Util/TabMysticStones.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package MysticStones.Util;
|
||||
|
||||
import MysticStones.MysticStones;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TabMysticStones extends CreativeTabs {
|
||||
|
||||
public TabMysticStones(int par1, String par2Str) {
|
||||
super(par1, par2Str);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(MysticStones.ReinforcedBricks, 1, 4);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue