Fixed crash between fluid names and ore dict names

This commit is contained in:
Calclavia 2014-02-26 00:11:09 +08:00
parent ef506bf88e
commit beb453df1e
7 changed files with 57 additions and 14 deletions

View file

@ -126,7 +126,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
if (heatEnergy >= getMeltIronEnergy((meta / 8f) * 1000))
{
// TODO: Make refined dust yield more molten fluid than normal dust.
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResourceGenerator.getFluidMaterial(name).blockID, meta, 3);
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResourceGenerator.getMolten(name).blockID, meta, 3);
TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (tile instanceof TileMaterial)

View file

@ -13,6 +13,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.recipe.MachineRecipes;
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.api.recipe.RecipeResource;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.BlockTile;
@ -71,17 +72,18 @@ public class BlockFilter extends BlockTile
*/
BlockFluidMixture fluidBlock = (BlockFluidMixture) bAbove;
int amount = fluidBlock.getQuantaValue(world, checkAbove.intX(), checkAbove.intY(), checkAbove.intZ());
int leakAmount = 2;
/**
* Drop item from fluid.
*/
for (RecipeResource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, "dust" + LanguageUtility.capitalizeFirst(fluidBlock.getFluid().getName().replace("mixture", ""))))
for (RecipeResource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, "dust" + ResourceGenerator.mixtureToMaterial(fluidBlock.getFluid().getName())))
{
InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), resoure.getItemStack().copy());
}
// TODO: Check if this is correct?
int remaining = amount - 2;
int remaining = amount - leakAmount;
/**
* Remove liquid from top.

View file

@ -15,6 +15,7 @@ import resonantinduction.api.recipe.MachineRecipes;
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import resonantinduction.mechanical.network.TileMechanical;
import resonantinduction.mechanical.process.Timer;
@ -153,7 +154,7 @@ public class TileMixer extends TileMechanical
}
else if (worldObj.isAirBlock(mixPosition.intX(), mixPosition.intY(), mixPosition.intZ()) || block.blockID == Block.waterStill.blockID || block.blockID == Block.waterMoving.blockID)
{
mixPosition.setBlock(worldObj, ResonantInduction.blockFluidMixtures.get(entity.getEntityItem().getItemDamage()).blockID);
mixPosition.setBlock(worldObj, ResourceGenerator.getMixture(ResourceGenerator.getName(entity.getEntityItem().getItemDamage())).blockID);
}
return false;

View file

@ -77,8 +77,8 @@ public class ResonantInduction
public static ItemOreResource itemDust;
public static ItemOreResource itemRefinedDust;
public static Block blockDust;
public static final List<Block> blockFluidMixtures = new ArrayList<Block>();
public static final List<Block> blockFluidMaterials = new ArrayList<Block>();
public static final List<Block> blockMixtureFluids = new ArrayList<Block>();
public static final List<Block> blockMoltenFluid = new ArrayList<Block>();
public static Block blockMachinePart;
public static List<Fluid> fluidMixtures = new ArrayList<Fluid>();

View file

@ -26,10 +26,10 @@ public class NEIResonantInductionConfig implements IConfigureNEI
API.registerRecipeHandler(new RISmelterRecipeHandler());
API.registerUsageHandler(new RISmelterRecipeHandler());
for (Block block : ResonantInduction.blockFluidMixtures)
for (Block block : ResonantInduction.blockMixtureFluids)
API.hideItem(block.blockID);
for (Block block : ResonantInduction.blockFluidMaterials)
for (Block block : ResonantInduction.blockMoltenFluid)
API.hideItem(block.blockID);
API.hideItem(ResonantInduction.blockDust.blockID);

View file

@ -103,23 +103,23 @@ public class ResourceGenerator
/**
* Generate molten fluids
*/
Fluid fluidMolten = new Fluid("molten" + nameCaps);
Fluid fluidMolten = new Fluid(materialNameToMolten(materialName));
fluidMolten.setDensity(7);
fluidMolten.setViscosity(5000);
fluidMolten.setTemperature(273 + 1538);
FluidRegistry.registerFluid(fluidMolten);
Block blockFluidMaterial = new BlockFluidMaterial(fluidMolten);
GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps);
ResonantInduction.blockFluidMaterials.add(blockFluidMaterial);
ResonantInduction.blockMoltenFluid.add(blockFluidMaterial);
/**
* Generate dust mixture fluids
*/
Fluid fluidMixture = new Fluid("mixture" + nameCaps);
Fluid fluidMixture = new Fluid(materialNameToMixture(materialName));
FluidRegistry.registerFluid(fluidMixture);
Block blockFluidMixture = new BlockFluidMixture(fluidMixture);
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps);
ResonantInduction.blockFluidMixtures.add(blockFluidMixture);
ResonantInduction.blockMixtureFluids.add(blockFluidMixture);
if (OreDictionary.getOres("ore" + nameCaps).size() > 0)
{
@ -252,9 +252,44 @@ public class ResourceGenerator
return 0xFFFFFF;
}
public static Block getFluidMaterial(String name)
public static String moltenNameToMaterial(String fluidName)
{
return ResonantInduction.blockFluidMaterials.get((getID(name)));
return fluidNameToMaterial(fluidName, "molten");
}
public static String materialNameToMolten(String fluidName)
{
return materialNameToFluid(fluidName, "molten");
}
public static String mixtureToMaterial(String fluidName)
{
return fluidNameToMaterial(fluidName, "mixture");
}
public static String materialNameToMixture(String fluidName)
{
return materialNameToFluid(fluidName, "mixture");
}
public static String fluidNameToMaterial(String fluidName, String type)
{
return LanguageUtility.underscoreToCamel(fluidName).replace(type, "");
}
public static String materialNameToFluid(String materialName, String type)
{
return type + "_" + LanguageUtility.camelToLowerUnderscore(materialName);
}
public static Block getMixture(String name)
{
return ResonantInduction.blockMixtureFluids.get((getID(name)));
}
public static Block getMolten(String name)
{
return ResonantInduction.blockMoltenFluid.get((getID(name)));
}
public static int getID(String name)

View file

@ -74,4 +74,9 @@ public class BlockFluidMixture extends BlockFluidFinite
{
return true;
}
public int getQuantaPerBlock()
{
return quantaPerBlock;
}
}