Merge branch 'master' of github.com:SirSengir/BuildCraft
This commit is contained in:
commit
604fa62374
12 changed files with 88 additions and 38 deletions
|
@ -32,6 +32,7 @@ import net.minecraft.src.buildcraft.core.RenderEntityBlock;
|
|||
import net.minecraft.src.buildcraft.core.RenderLaser;
|
||||
import net.minecraft.src.buildcraft.core.RenderRobot;
|
||||
import net.minecraft.src.buildcraft.core.Utils;
|
||||
import net.minecraft.src.buildcraft.core.utils.Localization;
|
||||
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||
import net.minecraft.src.forge.NetworkMod;
|
||||
|
@ -87,6 +88,9 @@ public class mod_BuildCraftCore extends NetworkMod {
|
|||
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_BLOCKS);
|
||||
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_ITEMS);
|
||||
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_EXTERNAL);
|
||||
|
||||
//Initialize localization
|
||||
Localization.addLocalization("/lang/buildcraft/", DefaultProps.DEFAULT_LANGUAGE);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,15 @@ public class LiquidManager {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getLiquidIDForFilledItem(ItemStack filledItem) {
|
||||
LiquidStack liquidForFilledItem = getLiquidForFilledItem(filledItem);
|
||||
|
||||
if (liquidForFilledItem == null)
|
||||
return 0;
|
||||
|
||||
return liquidForFilledItem.itemID;
|
||||
}
|
||||
|
||||
public static ItemStack getFilledItemForLiquid(LiquidStack liquid) {
|
||||
for (LiquidData data : liquids)
|
||||
|
|
|
@ -26,6 +26,8 @@ public class DefaultProps {
|
|||
public static String TEXTURE_ITEMS = "/gfx/buildcraft/items/items.png";
|
||||
public static String TEXTURE_ICONS = TEXTURE_PATH_GUI + "/icons.png";
|
||||
public static String TEXTURE_TRIGGERS = TEXTURE_PATH_GUI + "/triggers.png";
|
||||
|
||||
public static final String DEFAULT_LANGUAGE = "en_US";
|
||||
|
||||
public static int WOODEN_GEAR_ID = 3800;
|
||||
public static int STONE_GEAR_ID = 3801;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TriggerLiquidContainer extends Trigger {
|
|||
int seachedLiquidId = 0;
|
||||
|
||||
if (parameter != null && parameter.getItem() != null)
|
||||
seachedLiquidId = LiquidManager.getLiquidForFilledItem(parameter.getItem()).itemID;
|
||||
seachedLiquidId = LiquidManager.getLiquidIDForFilledItem(parameter.getItem());
|
||||
|
||||
LiquidSlot[] liquids = container.getLiquidSlots();
|
||||
|
||||
|
|
|
@ -1,74 +1,102 @@
|
|||
|
||||
package net.minecraft.src.buildcraft.core.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||
|
||||
/**
|
||||
* Simple mod localization class.
|
||||
*
|
||||
*
|
||||
* @author Jimeo Wan
|
||||
* @license Public domain
|
||||
*/
|
||||
public class Localization {
|
||||
|
||||
public static Localization instance = new Localization();
|
||||
private static class modInfo {
|
||||
|
||||
private static final String DEFAULT_LANGUAGE = "en_US";
|
||||
final String modName, defaultLanguage;
|
||||
|
||||
private String loadedLanguage = null;
|
||||
private Properties defaultMappings = new Properties();
|
||||
private Properties mappings = new Properties();
|
||||
public modInfo(String modName, String defaultLanguage) {
|
||||
this.modName = modName;
|
||||
this.defaultLanguage = defaultLanguage;
|
||||
}
|
||||
}
|
||||
private static String loadedLanguage = getCurrentLanguage();
|
||||
private static Properties defaultMappings = new Properties();
|
||||
private static Properties mappings = new Properties();
|
||||
private static LinkedList<modInfo> mods = new LinkedList<modInfo>();
|
||||
|
||||
/**
|
||||
* Loads the mod's localization files. All language files must be stored in
|
||||
* "[modname]/lang/", in .properties files. (ex: for the mod 'invtweaks',
|
||||
* the french translation is in: "invtweaks/lang/fr_FR.properties")
|
||||
*
|
||||
* @param modName
|
||||
* The mod name
|
||||
* Adds localization from a given directory. The files must have the same
|
||||
* name as the corresponding language file in minecraft and a ".properties"
|
||||
* file extention e.g "en_US.properties"
|
||||
*
|
||||
* @param path The path to the localization files
|
||||
* @param defaultLanguage The default localization to be used when there is
|
||||
* no localization for the selected language or if a string is missing (e.g.
|
||||
* "en_US")
|
||||
*/
|
||||
public Localization() {
|
||||
load(getCurrentLanguage());
|
||||
public static void addLocalization(String path, String defaultLanguage) {
|
||||
mods.add(new modInfo(path, defaultLanguage));
|
||||
load(path, defaultLanguage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string for the given key, in the currently active translation.
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public synchronized String get(String key) {
|
||||
String currentLanguage = getCurrentLanguage();
|
||||
if (!currentLanguage.equals(loadedLanguage))
|
||||
load(currentLanguage);
|
||||
public static synchronized String get(String key) {
|
||||
if (!getCurrentLanguage().equals(loadedLanguage)) {
|
||||
defaultMappings.clear();
|
||||
mappings.clear();
|
||||
for (modInfo mInfo : mods) {
|
||||
load(mInfo.modName, mInfo.defaultLanguage);
|
||||
}
|
||||
loadedLanguage = getCurrentLanguage();
|
||||
}
|
||||
|
||||
return mappings.getProperty(key, defaultMappings.getProperty(key, key));
|
||||
}
|
||||
|
||||
private void load(String newLanguage) {
|
||||
defaultMappings.clear();
|
||||
mappings.clear();
|
||||
try {
|
||||
InputStream langStream = Localization.class.getResourceAsStream("/lang/buildcraft/" + newLanguage + ".properties");
|
||||
InputStream defaultLangStream = Localization.class.getResourceAsStream("/lang/buildcraft/" + DEFAULT_LANGUAGE
|
||||
+ ".properties");
|
||||
mappings.load((langStream == null) ? defaultLangStream : langStream);
|
||||
defaultMappings.load(defaultLangStream);
|
||||
private static void load(String path, String default_language) {
|
||||
InputStream langStream = null;
|
||||
Properties modMappings = new Properties();
|
||||
|
||||
try {
|
||||
//Load the default language mappings
|
||||
langStream = Localization.class.getResourceAsStream(path + default_language + ".properties");
|
||||
modMappings.load(langStream);
|
||||
defaultMappings.putAll(modMappings);
|
||||
langStream.close();
|
||||
|
||||
//Try to load the current language mappings.
|
||||
//If the file doesn't exist use the default mappings.
|
||||
langStream = Localization.class.getResourceAsStream(path + getCurrentLanguage() + ".properties");
|
||||
if (langStream != null) {
|
||||
langStream.close();
|
||||
modMappings.clear();
|
||||
modMappings.load(langStream);
|
||||
}
|
||||
defaultLangStream.close();
|
||||
mappings.putAll(modMappings);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (langStream != null)
|
||||
langStream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
loadedLanguage = newLanguage;
|
||||
}
|
||||
|
||||
private static String getCurrentLanguage() {
|
||||
return CoreProxy.getCurrentLanguage();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ package net.minecraft.src.buildcraft.core.utils;
|
|||
public class StringUtil {
|
||||
|
||||
public static String localize(String key) {
|
||||
return Localization.instance.get(key);
|
||||
return Localization.get(key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class EngineIron extends Engine {
|
|||
super.update();
|
||||
|
||||
if (itemInInventory != null) {
|
||||
int liquidId = LiquidManager.getLiquidForFilledItem(itemInInventory).itemID;
|
||||
int liquidId = LiquidManager.getLiquidIDForFilledItem(itemInInventory);
|
||||
|
||||
if (liquidId != 0) {
|
||||
if (fill(Orientations.Unknown, BuildCraftAPI.BUCKET_VOLUME, liquidId, false) == BuildCraftAPI.BUCKET_VOLUME) {
|
||||
|
|
|
@ -102,7 +102,7 @@ public class BlockRefinery extends BlockContainer {
|
|||
return true;
|
||||
} else {
|
||||
|
||||
int liquidId = LiquidManager.getLiquidForFilledItem(entityplayer.getCurrentEquippedItem()).itemID;
|
||||
int liquidId = LiquidManager.getLiquidIDForFilledItem(entityplayer.getCurrentEquippedItem());
|
||||
|
||||
if (liquidId != 0) {
|
||||
int qty = ((TileRefinery) world.getBlockTileEntity(i, j, k)).fill(Orientations.Unknown,
|
||||
|
|
|
@ -92,7 +92,7 @@ public class BlockTank extends BlockContainer implements ITextureProvider {
|
|||
ItemStack current = entityplayer.inventory.getCurrentItem();
|
||||
if (current != null) {
|
||||
|
||||
int liquidId = LiquidManager.getLiquidForFilledItem(current).itemID;
|
||||
int liquidId = LiquidManager.getLiquidIDForFilledItem(current);
|
||||
|
||||
TileTank tank = (TileTank) world.getBlockTileEntity(i, j, k);
|
||||
|
||||
|
|
|
@ -352,8 +352,12 @@ public class PipeTransportItems extends PipeTransport {
|
|||
int i;
|
||||
|
||||
if (APIProxy.isClient(worldObj) || APIProxy.isServerSide())
|
||||
{
|
||||
i = Math.abs(data.item.entityId + xCoord + yCoord + zCoord + data.item.deterministicRandomization)
|
||||
% listOfPossibleMovements.size();
|
||||
data.item.deterministicRandomization*=11;
|
||||
|
||||
}
|
||||
else
|
||||
i = worldObj.rand.nextInt(listOfPossibleMovements.size());
|
||||
|
||||
|
|
|
@ -141,6 +141,9 @@ public class PipeTransportPower extends PipeTransport {
|
|||
if (entity instanceof TileGenericPipe) {
|
||||
TileGenericPipe nearbyTile = (TileGenericPipe) entity;
|
||||
|
||||
if (nearbyTile.pipe == null)
|
||||
continue;
|
||||
|
||||
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyTile.pipe.transport;
|
||||
|
||||
nearbyTransport.requestEnergy(Orientations.values()[i].reverse(), transferQuery[i]);
|
||||
|
|
|
@ -93,7 +93,7 @@ public class TriggerPipeContents extends Trigger implements ITriggerPipe {
|
|||
int seachedLiquidId = 0;
|
||||
|
||||
if (parameter != null && parameter.getItem() != null)
|
||||
seachedLiquidId = LiquidManager.getLiquidForFilledItem(parameter.getItem()).itemID;
|
||||
seachedLiquidId = LiquidManager.getLiquidIDForFilledItem(parameter.getItem());
|
||||
|
||||
if (kind == Kind.Empty) {
|
||||
for (LiquidBuffer b : transportLiquids.side)
|
||||
|
|
Loading…
Reference in a new issue