Merge branch 'master' into FacadesRefactor

This commit is contained in:
SirSengir 2012-07-13 22:23:36 +02:00
commit 7dbd03e34c
18 changed files with 306 additions and 124 deletions

View file

@ -28,6 +28,7 @@ import net.minecraft.src.buildcraft.core.network.BuildCraftPacket;
import net.minecraft.src.forge.MinecraftForgeClient;
import net.minecraft.src.forge.NetworkMod;
import cpw.mods.fml.client.SpriteHelper;
import cpw.mods.fml.common.FMLCommonHandler;
public class CoreProxy {
@ -85,10 +86,6 @@ public class CoreProxy {
}
public static int addFuel(int id, int dmg) {
return ModLoader.addAllFuel(id, dmg);
}
/**
* Adds an override to the buildcraft texture file, mainly to provide pipes
* with icons.
@ -104,11 +101,6 @@ public class CoreProxy {
return ModLoader.addOverride(DefaultProps.TEXTURE_EXTERNAL, pathToTexture) + 256;
}
public static long getHash(IBlockAccess iBlockAccess) {
// return iBlockAccess.func_48454_a(x, z).hashCode();
return 0;
}
public static void TakenFromCrafting(EntityPlayer entityplayer, ItemStack itemstack, IInventory iinventory) {
ModLoader.takenFromCrafting(entityplayer, itemstack, iinventory);
}

View file

@ -12,8 +12,9 @@ package net.minecraft.src.buildcraft.factory;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.RefineryRecipe;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.recipes.RefineryRecipe;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.GuiAdvancedInterface;
import net.minecraft.src.buildcraft.core.utils.StringUtil;
@ -100,11 +101,11 @@ public class GuiRefinery extends GuiAdvancedInterface {
if (filter1 != null)
liquid1Id = filter1.itemID;
RefineryRecipe recipe = BuildCraftAPI.findRefineryRecipe(liquid0Id, BuildCraftAPI.BUCKET_VOLUME, liquid1Id,
BuildCraftAPI.BUCKET_VOLUME);
RefineryRecipe recipe = RefineryRecipe.findRefineryRecipe(new LiquidStack(liquid0Id, BuildCraftAPI.BUCKET_VOLUME, 0),
new LiquidStack(liquid1Id, BuildCraftAPI.BUCKET_VOLUME, 0));
if (recipe != null)
((ItemSlot) slots[2]).stack = new ItemStack(recipe.resultId, 1, 0);
((ItemSlot) slots[2]).stack = recipe.result.asItemStack();
else
((ItemSlot) slots[2]).stack = null;
}

View file

@ -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;
}

View file

@ -81,24 +81,12 @@ public class CoreProxy {
return new File("buildcraft/");
}
public static void addLocalization(String s1, String string) {
// TODO Auto-generated method stub
}
public static int addFuel(int id, int dmg) {
return ModLoader.addAllFuel(id, dmg);
}
public static void addLocalization(String s1, String string) {}
public static int addCustomTexture(String pathToTexture) {
return 0;
}
public static long getHash(IBlockAccess iBlockAccess) {
// return iBlockAccess.hashCode();
return 0;
}
public static void TakenFromCrafting(EntityPlayer thePlayer, ItemStack itemstack, IInventory craftMatrix) {
ModLoader.takenFromCrafting(thePlayer, itemstack, craftMatrix);

View file

@ -12,10 +12,12 @@ import java.util.Random;
import java.util.TreeMap;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IronEngineFuel;
import net.minecraft.src.buildcraft.api.LiquidData;
import net.minecraft.src.buildcraft.api.RefineryRecipe;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.fuels.IronEngineFuel;
import net.minecraft.src.buildcraft.api.liquids.LiquidData;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.recipes.RefineryRecipe;
import net.minecraft.src.buildcraft.core.BlockIndex;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
@ -126,14 +128,14 @@ public class BuildCraftEnergy {
.setMaxStackSize(1).setContainerItem(Item.bucketEmpty);
CoreProxy.addName(bucketFuel, "Fuel Bucket");
BuildCraftAPI.registerRefineryRecipe(new RefineryRecipe(oilStill.blockID, 1, 0, 0, 10, fuel.shiftedIndex, 1, 1));
RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 10, 1));
BuildCraftAPI.ironEngineFuel.put(Block.lavaStill.blockID, new IronEngineFuel(oilStill.blockID, 1, 20000));
BuildCraftAPI.ironEngineFuel.put(oilStill.blockID, new IronEngineFuel(oilStill.blockID, 2, 10000));
BuildCraftAPI.ironEngineFuel.put(fuel.shiftedIndex, new IronEngineFuel(fuel.shiftedIndex, 5, 50000));
IronEngineFuel.fuels.add(new IronEngineFuel(oilStill.blockID, 1, 20000));
IronEngineFuel.fuels.add(new IronEngineFuel(oilStill.blockID, 2, 10000));
IronEngineFuel.fuels.add(new IronEngineFuel(fuel.shiftedIndex, 5, 50000));
BuildCraftAPI.liquids.add(new LiquidData(oilStill.blockID, oilMoving.blockID, bucketOil));
BuildCraftAPI.liquids.add(new LiquidData(fuel.shiftedIndex, 0, bucketFuel));
LiquidManager.liquids.add(new LiquidData(oilStill.blockID, oilMoving.blockID, bucketOil));
LiquidManager.liquids.add(new LiquidData(fuel.shiftedIndex, 0, bucketFuel));
BuildCraftAPI.softBlocks[oilMoving.blockID] = true;
BuildCraftAPI.softBlocks[oilStill.blockID] = true;

View file

@ -32,17 +32,28 @@ public class BuildCraftAPI {
// Other BuildCraft global data
@Deprecated
public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
public static HashMap<Integer, IronEngineFuel> ironEngineFuel = new HashMap<Integer, IronEngineFuel>();
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
*/
@Deprecated public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
/**
* This does not do anything anymore. Use buildcraft.api.fuels.IronEngineFuel!
*/
@Deprecated public static HashMap<Integer, IronEngineFuel> ironEngineFuel = new HashMap<Integer, IronEngineFuel>();
public static Trigger[] triggers = new Trigger[1024];
public static Action[] actions = new Action[1024];
private static EntityPlayer buildCraftPlayer;
private static LinkedList<RefineryRecipe> refineryRecipe = new LinkedList<RefineryRecipe>();
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
*/
@Deprecated private static LinkedList<RefineryRecipe> refineryRecipe = new LinkedList<RefineryRecipe>();
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
*/
@Deprecated
public static int getLiquidForFilledItem(ItemStack filledItem) {
if (filledItem == null) {
@ -58,6 +69,9 @@ public class BuildCraftAPI {
return 0;
}
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
*/
@Deprecated
public static ItemStack getFilledItemForLiquid(int liquidId) {
for (LiquidData d : liquids) {
@ -69,6 +83,9 @@ public class BuildCraftAPI {
return null;
}
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
*/
@Deprecated
public static boolean isLiquid(int blockId) {
if (blockId == 0) {
@ -119,12 +136,20 @@ public class BuildCraftAPI {
return buildCraftPlayer;
}
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
*/
@Deprecated
public static void registerRefineryRecipe(RefineryRecipe recipe) {
if (!refineryRecipe.contains(recipe)) {
refineryRecipe.add(recipe);
}
}
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
*/
@Deprecated
public static RefineryRecipe findRefineryRecipe(int liquid1, int qty1, int liquid2, int qty2) {
int l1 = qty1 > 0 ? liquid1 : 0;
int l2 = qty2 > 0 ? liquid2 : 0;

View file

@ -9,6 +9,10 @@
package net.minecraft.src.buildcraft.api;
/**
* This does not do anything anymore. Use buildcraft.api.fuels.IronEngineFuel!
*/
@Deprecated
public class IronEngineFuel {
public final int fuelId;

View file

@ -9,6 +9,7 @@
package net.minecraft.src.buildcraft.api;
@Deprecated
public class RefineryRecipe {
public final int sourceId1;

View file

@ -0,0 +1,45 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api.fuels;
import java.util.HashMap;
import java.util.LinkedList;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
public class IronEngineFuel {
public static LinkedList<IronEngineFuel> fuels = new LinkedList<IronEngineFuel>();
public static IronEngineFuel getFuelForLiquid(LiquidStack liquid) {
if(liquid == null)
return null;
for(IronEngineFuel fuel : fuels)
if(fuel.liquid.isLiquidEqual(liquid))
return fuel;
return null;
}
public final LiquidStack liquid;
public final int powerPerCycle;
public final int totalBurningTime;
public IronEngineFuel(int liquidId, int powerPerCycle, int totalBurningTime) {
this(new LiquidStack(liquidId, BuildCraftAPI.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime);
}
public IronEngineFuel(LiquidStack liquid, int powerPerCycle, int totalBurningTime) {
this.liquid = liquid;
this.powerPerCycle = powerPerCycle;
this.totalBurningTime = totalBurningTime;
}
}

View file

@ -6,9 +6,7 @@ import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
/**
*
* Forestry internal ItemStack substitute for liquids
*
* ItemStack substitute for liquids
* @author SirSengir
*/
public class LiquidStack {
@ -21,16 +19,16 @@ public class LiquidStack {
private LiquidStack() {
}
public LiquidStack(int itemID, int liquidAmount) {
this(itemID, liquidAmount, 0);
public LiquidStack(int itemID, int amount) {
this(itemID, amount, 0);
}
public LiquidStack(Item item, int liquidAmount) {
this(item.shiftedIndex, liquidAmount, 0);
public LiquidStack(Item item, int amount) {
this(item.shiftedIndex, amount, 0);
}
public LiquidStack(Block block, int liquidAmount) {
this(block.blockID, liquidAmount, 0);
public LiquidStack(Block block, int amount) {
this(block.blockID, amount, 0);
}
public LiquidStack(int itemID, int amount, int itemDamage) {
@ -56,6 +54,9 @@ public class LiquidStack {
stackTagCompound = nbttagcompound.getCompoundTag("tag");
}
/**
* @return A copy of this LiquidStack
*/
public LiquidStack copy() {
LiquidStack copy = new LiquidStack(itemID, amount, itemMeta);
if (stackTagCompound != null) {
@ -66,24 +67,44 @@ public class LiquidStack {
return copy;
}
/**
* @return NBTTagCompound associated with this LiquidStack
*/
public NBTTagCompound getTagCompound() {
return stackTagCompound;
}
/**
* @param nbttagcompound Sets the NBTTagCompound on this LiquidStack
*/
public void setTagCompound(NBTTagCompound nbttagcompound) {
stackTagCompound = nbttagcompound;
}
/**
* @param other
* @return true if this LiquidStack contains the same liquid as the one passed in.
*/
public boolean isLiquidEqual(LiquidStack other) {
if(other == null)
return false;
return itemID == other.itemID && itemMeta == other.itemMeta;
}
/**
* @param other ItemStack containing liquids.
* @return true if this LiquidStack contains the same liquid as the one passed in.
*/
public boolean isLiquidEqual(ItemStack other) {
if(other == null)
return false;
return itemID == other.itemID && itemMeta == other.getItemDamage();
}
/**
* @return An ItemStack representation of this LiquidStack
* @return ItemStack representation of this LiquidStack
*/
public ItemStack asItemStack() {
return new ItemStack(itemID, 1, itemMeta);

View file

@ -0,0 +1,73 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api.recipes;
import java.util.LinkedList;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
public class RefineryRecipe {
private static LinkedList<RefineryRecipe> recipes = new LinkedList<RefineryRecipe>();
public static void registerRefineryRecipe(RefineryRecipe recipe) {
if (!recipes.contains(recipe)) {
recipes.add(recipe);
}
}
public static RefineryRecipe findRefineryRecipe(LiquidStack liquid1, LiquidStack liquid2) {
for(RefineryRecipe recipe : recipes)
if(recipe.matches(liquid1, liquid2))
return recipe;
return null;
}
public final LiquidStack ingredient1;
public final LiquidStack ingredient2;
public final LiquidStack result;
public final int energy;
public final int delay;
public RefineryRecipe(int ingredientId1, int ingredientQty1, int ingredientId2, int ingredientQty2, int resultId, int resultQty,
int energy, int delay) {
this(new LiquidStack(ingredientId1, ingredientQty1, 0), new LiquidStack(ingredientId2, ingredientQty2, 0), new LiquidStack(resultId, resultQty, 0), energy, delay);
}
public RefineryRecipe(LiquidStack ingredient1, LiquidStack ingredient2, LiquidStack result, int energy, int delay) {
this.ingredient1 = ingredient1;
this.ingredient2 = ingredient2;
this.result = result;
this.energy = energy;
this.delay = delay;
}
public boolean matches(LiquidStack liquid1, LiquidStack liquid2) {
if(liquid1 == null && liquid2 == null)
return false;
if((ingredient1 != null && ingredient2 != null)
&& (liquid1 == null || liquid2 == null))
return false;
if(liquid1 != null) {
if(liquid2 == null)
return liquid1.isLiquidEqual(ingredient1) || liquid1.isLiquidEqual(ingredient2);
else
return (liquid1.isLiquidEqual(ingredient1) && liquid2.isLiquidEqual(ingredient2))
|| (liquid2.isLiquidEqual(ingredient1) && liquid1.isLiquidEqual(ingredient2));
} else
return liquid2.isLiquidEqual(ingredient1) || liquid2.isLiquidEqual(ingredient2);
}
}

View file

@ -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;

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -14,10 +14,11 @@ import net.minecraft.src.ICrafting;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IronEngineFuel;
import net.minecraft.src.buildcraft.api.LiquidSlot;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.fuels.IronEngineFuel;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
@ -75,9 +76,9 @@ public class EngineIron extends Engine {
return 0.06F;
case Red:
return 0.07F;
default:
return 0.0f;
}
return 0;
}
@Override
@ -88,7 +89,7 @@ public class EngineIron extends Engine {
@Override
public void burn() {
currentOutput = 0;
IronEngineFuel currentFuel = BuildCraftAPI.ironEngineFuel.get(liquidId);
IronEngineFuel currentFuel = IronEngineFuel.getFuelForLiquid(new LiquidStack(liquidId, liquidQty, 0));
if (currentFuel == null) {
return;
@ -188,9 +189,8 @@ public class EngineIron extends Engine {
return 0;
}
if (!BuildCraftAPI.ironEngineFuel.containsKey(id)) {
if (IronEngineFuel.getFuelForLiquid(new LiquidStack(id, quantity, 0)) == null)
return 0;
}
if (liquidQty + quantity <= MAX_LIQUID) {
if (doFill) {

View file

@ -9,6 +9,7 @@
package net.minecraft.src.buildcraft.energy;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.src.Block;
import net.minecraft.src.ICrafting;
import net.minecraft.src.Item;
@ -94,24 +95,10 @@ public class EngineStone extends Engine {
}
private int getItemBurnTime(ItemStack itemstack) {
if (itemstack == null) {
if (itemstack == null)
return 0;
}
int i = itemstack.getItem().shiftedIndex;
if (i < Block.blocksList.length && Block.blocksList[i] != null && Block.blocksList[i].blockMaterial == Material.wood) {
return 300;
}
if (i == Item.stick.shiftedIndex) {
return 100;
}
if (i == Item.coal.shiftedIndex) {
return 1600;
}
if (i == Item.bucketLava.shiftedIndex) {
return 20000;
} else {
return i == Block.sapling.blockID ? 100 : CoreProxy.addFuel(i, itemstack.getItemDamage());
}
return FMLCommonHandler.instance().fuelLookup(itemstack.getItem().shiftedIndex, itemstack.getItemDamage());
}
/* SAVING & LOADING */

View file

@ -24,9 +24,10 @@ import net.minecraft.src.buildcraft.api.LiquidSlot;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.PowerFramework;
import net.minecraft.src.buildcraft.api.PowerProvider;
import net.minecraft.src.buildcraft.api.RefineryRecipe;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.recipes.RefineryRecipe;
import net.minecraft.src.buildcraft.core.IMachine;
public class TileRefinery extends TileMachine implements ILiquidContainer, IPowerReceptor, IInventory, IMachine {
@ -234,19 +235,19 @@ public class TileRefinery extends TileMachine implements ILiquidContainer, IPowe
RefineryRecipe currentRecipe = null;
currentRecipe = BuildCraftAPI.findRefineryRecipe(slot1.liquidId, slot1.quantity, slot2.liquidId, slot2.quantity);
currentRecipe = RefineryRecipe.findRefineryRecipe(new LiquidStack(slot1.liquidId, slot1.quantity, 0), new LiquidStack(slot2.liquidId, slot2.quantity, 0));
if (currentRecipe == null) {
decreaseAnimation();
return;
}
if (result.quantity != 0 && result.liquidId != currentRecipe.resultId) {
if (result.quantity != 0 && result.liquidId != currentRecipe.result.itemID) {
decreaseAnimation();
return;
}
if (result.quantity + currentRecipe.resultQty > LIQUID_PER_SLOT) {
if (result.quantity + currentRecipe.result.amount > LIQUID_PER_SLOT) {
decreaseAnimation();
return;
}
@ -264,8 +265,8 @@ public class TileRefinery extends TileMachine implements ILiquidContainer, IPowe
return;
}
if (!containsInput(currentRecipe.sourceId1, currentRecipe.sourceQty1)
|| !containsInput(currentRecipe.sourceId2, currentRecipe.sourceQty2)) {
if (!containsInput(currentRecipe.ingredient1)
|| !containsInput(currentRecipe.ingredient2)) {
decreaseAnimation();
return;
}
@ -273,29 +274,33 @@ public class TileRefinery extends TileMachine implements ILiquidContainer, IPowe
float energyUsed = powerProvider.useEnergy(currentRecipe.energy, currentRecipe.energy, true);
if (energyUsed != 0) {
if (consumeInput(currentRecipe.sourceId1, currentRecipe.sourceQty1)
&& consumeInput(currentRecipe.sourceId2, currentRecipe.sourceQty2)) {
result.liquidId = currentRecipe.resultId;
result.quantity += currentRecipe.resultQty;
if (consumeInput(currentRecipe.ingredient1)
&& consumeInput(currentRecipe.ingredient2)) {
result.liquidId = currentRecipe.result.itemID;
result.quantity += currentRecipe.result.amount;
}
}
}
private boolean containsInput(int id, int qty) {
return id == 0 || (slot1.liquidId == id && slot1.quantity >= qty) || (slot2.liquidId == id && slot2.quantity >= qty);
private boolean containsInput(LiquidStack liquid) {
if(liquid == null)
return true;
return liquid.isLiquidEqual(new LiquidStack(slot1.liquidId, slot1.quantity, 0)) || liquid.isLiquidEqual(new LiquidStack(slot2.liquidId, slot2.quantity, 0));
}
private boolean consumeInput(int id, int qty) {
if (id == 0) {
private boolean consumeInput(LiquidStack liquid) {
if(liquid == null)
return true;
} else if (slot1.liquidId == id && slot1.quantity >= qty) {
slot1.quantity -= qty;
if(liquid.isLiquidEqual(new LiquidStack(slot1.liquidId, slot1.quantity, 0))) {
slot1.quantity -= liquid.amount;
return true;
} else if (slot2.liquidId == id && slot2.quantity >= qty) {
slot2.quantity -= qty;
} else if(liquid.isLiquidEqual(new LiquidStack(slot2.liquidId, slot2.quantity, 0))) {
slot2.quantity -= liquid.amount;
return true;
}
return false;
}

View file

@ -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());