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.RenderLaser;
|
||||||
import net.minecraft.src.buildcraft.core.RenderRobot;
|
import net.minecraft.src.buildcraft.core.RenderRobot;
|
||||||
import net.minecraft.src.buildcraft.core.Utils;
|
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.buildcraft.transport.TileGenericPipe;
|
||||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||||
import net.minecraft.src.forge.NetworkMod;
|
import net.minecraft.src.forge.NetworkMod;
|
||||||
|
@ -88,6 +89,9 @@ public class mod_BuildCraftCore extends NetworkMod {
|
||||||
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_ITEMS);
|
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_ITEMS);
|
||||||
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_EXTERNAL);
|
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_EXTERNAL);
|
||||||
|
|
||||||
|
//Initialize localization
|
||||||
|
Localization.addLocalization("/lang/buildcraft/", DefaultProps.DEFAULT_LANGUAGE);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,15 @@ public class LiquidManager {
|
||||||
return null;
|
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) {
|
public static ItemStack getFilledItemForLiquid(LiquidStack liquid) {
|
||||||
for (LiquidData data : liquids)
|
for (LiquidData data : liquids)
|
||||||
if(data.stillLiquid.isLiquidEqual(liquid))
|
if(data.stillLiquid.isLiquidEqual(liquid))
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class DefaultProps {
|
||||||
public static String TEXTURE_ICONS = TEXTURE_PATH_GUI + "/icons.png";
|
public static String TEXTURE_ICONS = TEXTURE_PATH_GUI + "/icons.png";
|
||||||
public static String TEXTURE_TRIGGERS = TEXTURE_PATH_GUI + "/triggers.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 WOODEN_GEAR_ID = 3800;
|
||||||
public static int STONE_GEAR_ID = 3801;
|
public static int STONE_GEAR_ID = 3801;
|
||||||
public static int IRON_GEAR_ID = 3802;
|
public static int IRON_GEAR_ID = 3802;
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TriggerLiquidContainer extends Trigger {
|
||||||
int seachedLiquidId = 0;
|
int seachedLiquidId = 0;
|
||||||
|
|
||||||
if (parameter != null && parameter.getItem() != null)
|
if (parameter != null && parameter.getItem() != null)
|
||||||
seachedLiquidId = LiquidManager.getLiquidForFilledItem(parameter.getItem()).itemID;
|
seachedLiquidId = LiquidManager.getLiquidIDForFilledItem(parameter.getItem());
|
||||||
|
|
||||||
LiquidSlot[] liquids = container.getLiquidSlots();
|
LiquidSlot[] liquids = container.getLiquidSlots();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
package net.minecraft.src.buildcraft.core.utils;
|
package net.minecraft.src.buildcraft.core.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import net.minecraft.src.buildcraft.core.CoreProxy;
|
import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||||
|
@ -13,24 +16,33 @@ import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||||
*/
|
*/
|
||||||
public class Localization {
|
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;
|
public modInfo(String modName, String defaultLanguage) {
|
||||||
private Properties defaultMappings = new Properties();
|
this.modName = modName;
|
||||||
private Properties mappings = new Properties();
|
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
|
* Adds localization from a given directory. The files must have the same
|
||||||
* "[modname]/lang/", in .properties files. (ex: for the mod 'invtweaks',
|
* name as the corresponding language file in minecraft and a ".properties"
|
||||||
* the french translation is in: "invtweaks/lang/fr_FR.properties")
|
* file extention e.g "en_US.properties"
|
||||||
*
|
*
|
||||||
* @param modName
|
* @param path The path to the localization files
|
||||||
* The mod name
|
* @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() {
|
public static void addLocalization(String path, String defaultLanguage) {
|
||||||
load(getCurrentLanguage());
|
mods.add(new modInfo(path, defaultLanguage));
|
||||||
|
load(path, defaultLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,36 +51,52 @@ public class Localization {
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public synchronized String get(String key) {
|
public static synchronized String get(String key) {
|
||||||
String currentLanguage = getCurrentLanguage();
|
if (!getCurrentLanguage().equals(loadedLanguage)) {
|
||||||
if (!currentLanguage.equals(loadedLanguage))
|
defaultMappings.clear();
|
||||||
load(currentLanguage);
|
mappings.clear();
|
||||||
|
for (modInfo mInfo : mods) {
|
||||||
|
load(mInfo.modName, mInfo.defaultLanguage);
|
||||||
|
}
|
||||||
|
loadedLanguage = getCurrentLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
return mappings.getProperty(key, defaultMappings.getProperty(key, key));
|
return mappings.getProperty(key, defaultMappings.getProperty(key, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(String newLanguage) {
|
private static void load(String path, String default_language) {
|
||||||
defaultMappings.clear();
|
InputStream langStream = null;
|
||||||
mappings.clear();
|
Properties modMappings = new Properties();
|
||||||
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);
|
|
||||||
|
|
||||||
if (langStream != null) {
|
try {
|
||||||
|
//Load the default language mappings
|
||||||
|
langStream = Localization.class.getResourceAsStream(path + default_language + ".properties");
|
||||||
|
modMappings.load(langStream);
|
||||||
|
defaultMappings.putAll(modMappings);
|
||||||
langStream.close();
|
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) {
|
||||||
|
modMappings.clear();
|
||||||
|
modMappings.load(langStream);
|
||||||
}
|
}
|
||||||
defaultLangStream.close();
|
mappings.putAll(modMappings);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (langStream != null)
|
||||||
|
langStream.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
loadedLanguage = newLanguage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getCurrentLanguage() {
|
private static String getCurrentLanguage() {
|
||||||
return CoreProxy.getCurrentLanguage();
|
return CoreProxy.getCurrentLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ package net.minecraft.src.buildcraft.core.utils;
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
|
|
||||||
public static String localize(String key) {
|
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();
|
super.update();
|
||||||
|
|
||||||
if (itemInInventory != null) {
|
if (itemInInventory != null) {
|
||||||
int liquidId = LiquidManager.getLiquidForFilledItem(itemInInventory).itemID;
|
int liquidId = LiquidManager.getLiquidIDForFilledItem(itemInInventory);
|
||||||
|
|
||||||
if (liquidId != 0) {
|
if (liquidId != 0) {
|
||||||
if (fill(Orientations.Unknown, BuildCraftAPI.BUCKET_VOLUME, liquidId, false) == BuildCraftAPI.BUCKET_VOLUME) {
|
if (fill(Orientations.Unknown, BuildCraftAPI.BUCKET_VOLUME, liquidId, false) == BuildCraftAPI.BUCKET_VOLUME) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class BlockRefinery extends BlockContainer {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int liquidId = LiquidManager.getLiquidForFilledItem(entityplayer.getCurrentEquippedItem()).itemID;
|
int liquidId = LiquidManager.getLiquidIDForFilledItem(entityplayer.getCurrentEquippedItem());
|
||||||
|
|
||||||
if (liquidId != 0) {
|
if (liquidId != 0) {
|
||||||
int qty = ((TileRefinery) world.getBlockTileEntity(i, j, k)).fill(Orientations.Unknown,
|
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();
|
ItemStack current = entityplayer.inventory.getCurrentItem();
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
|
|
||||||
int liquidId = LiquidManager.getLiquidForFilledItem(current).itemID;
|
int liquidId = LiquidManager.getLiquidIDForFilledItem(current);
|
||||||
|
|
||||||
TileTank tank = (TileTank) world.getBlockTileEntity(i, j, k);
|
TileTank tank = (TileTank) world.getBlockTileEntity(i, j, k);
|
||||||
|
|
||||||
|
|
|
@ -352,8 +352,12 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (APIProxy.isClient(worldObj) || APIProxy.isServerSide())
|
if (APIProxy.isClient(worldObj) || APIProxy.isServerSide())
|
||||||
|
{
|
||||||
i = Math.abs(data.item.entityId + xCoord + yCoord + zCoord + data.item.deterministicRandomization)
|
i = Math.abs(data.item.entityId + xCoord + yCoord + zCoord + data.item.deterministicRandomization)
|
||||||
% listOfPossibleMovements.size();
|
% listOfPossibleMovements.size();
|
||||||
|
data.item.deterministicRandomization*=11;
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
i = worldObj.rand.nextInt(listOfPossibleMovements.size());
|
i = worldObj.rand.nextInt(listOfPossibleMovements.size());
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,9 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
if (entity instanceof TileGenericPipe) {
|
if (entity instanceof TileGenericPipe) {
|
||||||
TileGenericPipe nearbyTile = (TileGenericPipe) entity;
|
TileGenericPipe nearbyTile = (TileGenericPipe) entity;
|
||||||
|
|
||||||
|
if (nearbyTile.pipe == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyTile.pipe.transport;
|
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyTile.pipe.transport;
|
||||||
|
|
||||||
nearbyTransport.requestEnergy(Orientations.values()[i].reverse(), transferQuery[i]);
|
nearbyTransport.requestEnergy(Orientations.values()[i].reverse(), transferQuery[i]);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class TriggerPipeContents extends Trigger implements ITriggerPipe {
|
||||||
int seachedLiquidId = 0;
|
int seachedLiquidId = 0;
|
||||||
|
|
||||||
if (parameter != null && parameter.getItem() != null)
|
if (parameter != null && parameter.getItem() != null)
|
||||||
seachedLiquidId = LiquidManager.getLiquidForFilledItem(parameter.getItem()).itemID;
|
seachedLiquidId = LiquidManager.getLiquidIDForFilledItem(parameter.getItem());
|
||||||
|
|
||||||
if (kind == Kind.Empty) {
|
if (kind == Kind.Empty) {
|
||||||
for (LiquidBuffer b : transportLiquids.side)
|
for (LiquidBuffer b : transportLiquids.side)
|
||||||
|
|
Loading…
Reference in a new issue