Skip to content

Commit

Permalink
Change FluidType to a more appropriate class
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Jul 1, 2014
1 parent 3de90bd commit c79ddf8
Show file tree
Hide file tree
Showing 36 changed files with 225 additions and 253 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/tinker/textures/armor/leather_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/tinker/textures/armor/travel_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed resources/assets/tinker/textures/items/redstoneball.png
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 1 addition & 11 deletions src/main/java/tconstruct/library/armor/ArmorCore.java
Expand Up @@ -54,17 +54,7 @@ public ItemStack onItemRightClick (ItemStack par1ItemStack, World par2World, Ent

if (itemstack1 == null)
{
par3EntityPlayer.setCurrentItemOrArmor(i + 1, par1ItemStack.copy()); // Forge:
// Vanilla
// bug
// fix
// associated
// with
// fixed
// setCurrentItemOrArmor
// indexs
// for
// players.
par3EntityPlayer.setCurrentItemOrArmor(i + 1, par1ItemStack.copy());
par1ItemStack.stackSize = 0;
}

Expand Down
105 changes: 35 additions & 70 deletions src/main/java/tconstruct/library/crafting/FluidType.java
@@ -1,102 +1,67 @@
package tconstruct.library.crafting;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.world.TinkerWorld;

public enum FluidType
public class FluidType
{
/** Vanilla Water Smelting **/
Water(Blocks.snow, 0, 20, FluidRegistry.getFluid("water"), false),
/** Iron Smelting **/
Iron(Blocks.iron_block, 0, 600, TinkerSmeltery.moltenIronFluid, true),
/** Gold Smelting **/
Gold(Blocks.gold_block, 0, 400, TinkerSmeltery.moltenGoldFluid, false),
/** Tin Smelting **/
Tin(TinkerWorld.metalBlock, 5, 400, TinkerSmeltery.moltenTinFluid, false),
/** Copper Smelting **/
Copper(TinkerWorld.metalBlock, 3, 550, TinkerSmeltery.moltenCopperFluid, true),
/** Aluminum Smelting **/
Aluminum(TinkerWorld.metalBlock, 6, 350, TinkerSmeltery.moltenAluminumFluid, false),
/** Natural Aluminum Smelting **/
NaturalAluminum(TinkerWorld.oreSlag, 6, 350, TinkerSmeltery.moltenAluminumFluid, false),
/** Cobalt Smelting **/
Cobalt(TinkerWorld.metalBlock, 0, 650, TinkerSmeltery.moltenCobaltFluid, true),
/** Ardite Smelting **/
Ardite(TinkerWorld.metalBlock, 1, 650, TinkerSmeltery.moltenArditeFluid, true),
/** AluminumBrass Smelting **/
AluminumBrass(TinkerWorld.metalBlock, 7, 350, TinkerSmeltery.moltenAlubrassFluid, false),
/** Alumite Smelting **/
Alumite(TinkerWorld.metalBlock, 8, 800, TinkerSmeltery.moltenAlumiteFluid, true),
/** Manyullyn Smelting **/
Manyullyn(TinkerWorld.metalBlock, 2, 750, TinkerSmeltery.moltenManyullynFluid, true),
/** Bronze Smelting **/
Bronze(TinkerWorld.metalBlock, 4, 500, TinkerSmeltery.moltenBronzeFluid, true),
/** Steel Smelting **/
Steel(TinkerWorld.metalBlock, 9, 700, TinkerSmeltery.moltenSteelFluid, true),
/** Nickel Smelting **/
Nickel(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenNickelFluid, false),
/** Lead Smelting **/
Lead(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenLeadFluid, false),
/** Silver Smelting **/
Silver(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenSilverFluid, false),
/** Platinum Smelting **/
Platinum(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenShinyFluid, false),
/** Invar Smelting **/
Invar(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenInvarFluid, false),
/** Electrum Smelting **/
Electrum(TinkerWorld.metalBlock, 0, 400, TinkerSmeltery.moltenElectrumFluid, false),
/** Obsidian Smelting **/
Obsidian(Blocks.obsidian, 0, 750, TinkerSmeltery.moltenObsidianFluid, true),
/** Ender Smelting **/
Ender(TinkerWorld.metalBlock, 10, 500, TinkerSmeltery.moltenEnderFluid, false),
/** Glass Smelting **/
Glass(Blocks.sand, 0, 625, TinkerSmeltery.moltenGlassFluid, false),
/** Stone Smelting **/
Stone(Blocks.stone, 0, 800, TinkerSmeltery.moltenStoneFluid, true),
/** Emerald Smelting **/
Emerald(Blocks.emerald_ore, 0, 575, TinkerSmeltery.moltenEmeraldFluid, false),
/** Slime Smelting **/
Slime(TinkerWorld.slimeGel, 0, 250, TinkerWorld.blueSlimeFluid, false),
/** Pigiron Smelting **/
PigIron(TinkerWorld.meatBlock, 0, 610, TinkerSmeltery.pigIronFluid, true),
/** Glue Smelting **/
Glue(TinkerSmeltery.glueBlock, 0, 125, TinkerSmeltery.glueFluid, false);

public final Block renderBlock;
public final int renderMeta;
public final int baseTemperature;
public final Fluid fluid;
public final boolean isToolpart;

public static HashMap<String, FluidType> fluidTypes = new HashMap<String, FluidType>();

FluidType(Block b, int meta, int baseTemperature, Fluid fluid, boolean isToolpart)
public FluidType(Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart)
{
this.renderBlock = b;
this.renderBlock = block;
this.renderMeta = meta;
this.baseTemperature = baseTemperature;
this.fluid = fluid;
this.isToolpart = isToolpart;
}

public static void registerFluidType(String name, FluidType type)
{
fluidTypes.put(name, type);
}

public static void registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart)
{
FluidType type = new FluidType(block, meta, baseTemperature, fluid, isToolpart);
registerFluidType(name, type);
}

public static FluidType getFluidType(String typeName)
{
return fluidTypes.get(typeName);
}

public static FluidType getFluidType (Fluid searchedFluid)
{
for (FluidType ft : values())
Iterator iter = fluidTypes.entrySet().iterator();
while (iter.hasNext())
{
if (ft.fluid == searchedFluid)
return ft;
Map.Entry pairs = (Map.Entry) iter.next();
if (((FluidType)pairs.getValue()).fluid.equals(searchedFluid))
return (FluidType) pairs.getValue();
}
return null;
}

public static int getTemperatureByFluid (Fluid searchedFluid)
{
for (FluidType ft : values())
Iterator iter = fluidTypes.entrySet().iterator();
while (iter.hasNext())
{
if (ft.fluid == searchedFluid)
return ft.baseTemperature;
Map.Entry pairs = (Map.Entry) iter.next();
if (((FluidType)pairs.getValue()).fluid.equals(searchedFluid))
return ((FluidType) pairs.getValue()).baseTemperature;
}
return 800;
}
Expand Down
87 changes: 31 additions & 56 deletions src/main/java/tconstruct/library/crafting/Smeltery.java
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
Expand All @@ -25,13 +26,9 @@ public class Smeltery
* Smeltery.addMelting(Block.oreIron, 0, 600, new
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
*
* @param stack
* The itemstack to liquify
* @param temperature
* How hot the block should be before liquifying. Max temp in the
* Smeltery is 800, other structures may vary
* @param output
* The result of the process in liquid form
* @param stack The itemstack to liquify
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
* @param output The result of the process in liquid form
*/
public static void addMelting0 (ItemStack stack, int temperature, FluidStack output)
{
Expand All @@ -43,15 +40,10 @@ public static void addMelting0 (ItemStack stack, int temperature, FluidStack out
* Smeltery.addMelting(Block.oreIron, 0, 600, new
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
*
* @param blockID
* The ID of the block to liquify and render
* @param metadata
* The metadata of the block to liquify and render
* @param temperature
* How hot the block should be before liquifying. Max temp in the
* Smeltery is 800, other structures may vary
* @param output
* The result of the process in liquid form
* @param blockID The ID of the block to liquify and render
* @param metadata The metadata of the block to liquify and render
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
* @param output The result of the process in liquid form
*/
public static void addMelting (Block block, int metadata, int temperature, FluidStack output)
{
Expand All @@ -64,16 +56,11 @@ public static void addMelting (Block block, int metadata, int temperature, Fluid
* 0, 600, new FluidStack(liquidMetalStill.blockID,
* TConstruct.ingotLiquidValue * 2, 0));
*
* @param input
* The item to liquify
* @param blockID
* The ID of the block to render
* @param metadata
* The metadata of the block to render
* @param temperature
* How hot the block should be before liquifying
* @param liquid
* The result of the process
* @param input The item to liquify
* @param blockID The ID of the block to render
* @param metadata The metadata of the block to render
* @param temperature How hot the block should be before liquifying
* @param liquid The result of the process
*/
public static void addMelting (ItemStack input, Block blockID, int metadata, int temperature, FluidStack liquid)
{
Expand All @@ -88,11 +75,8 @@ public static void addMelting (ItemStack input, Block blockID, int metadata, int
* FluidStack(tinID, 1, 0)); The example mixes 3 copper with 1 tin to make 2
* bronze
*
* @param result
* The output of the combination of mixers. The quantity is used
* for amount of a successful mix
* @param mixers
* the liquids to be mixed. Quantities are used as ratios
* @param result The output of the combination of mixers. The quantity is used for amount of a successful mix
* @param mixers the liquids to be mixed. Quantities are used as ratios
*/
public static void addAlloyMixing (FluidStack result, FluidStack... mixers)
{
Expand All @@ -106,8 +90,7 @@ public static void addAlloyMixing (FluidStack result, FluidStack... mixers)
/**
* Used to get the resulting temperature from a source ItemStack
*
* @param item
* The Source ItemStack
* @param item The Source ItemStack
* @return The result temperature
*/
public static Integer getLiquifyTemperature (ItemStack item)
Expand All @@ -125,8 +108,7 @@ public static Integer getLiquifyTemperature (ItemStack item)
/**
* Used to get the resulting temperature from a source Block
*
* @param item
* The Source ItemStack
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static Integer getLiquifyTemperature (int blockID, int metadata)
Expand All @@ -137,8 +119,7 @@ public static Integer getLiquifyTemperature (int blockID, int metadata)
/**
* Used to get the resulting ItemStack from a source ItemStack
*
* @param item
* The Source ItemStack
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static FluidStack getSmelteryResult (ItemStack item)
Expand All @@ -155,8 +136,7 @@ public static FluidStack getSmelteryResult (ItemStack item)
/**
* Used to get the resulting ItemStack from a source Block
*
* @param item
* The Source ItemStack
* @param item The Source ItemStack
* @return The result ItemStack
*/
public static FluidStack getSmelteryResult (int blockID, int metadata)
Expand Down Expand Up @@ -209,37 +189,32 @@ public static ArrayList<AlloyMix> getAlloyList ()
*
* @author samtrion
*
* @param type
* Type of Fluid
* @param input
* The item to liquify
* @param temperatureDifference
* Difference between FluidType BaseTemperature
* @param fluidAmount
* Amount of Fluid
* @param type Type of Fluid
* @param input The item to liquify
* @param temperatureDifference Difference between FluidType BaseTemperature
* @param fluidAmount Amount of Fluid
*/
public static void addMelting (FluidType type, ItemStack input, int temperatureDifference, int fluidAmount)
{
int temp = type.baseTemperature + temperatureDifference;
if (temp <= 20)
temp = type.baseTemperature;

addMelting(input, type.renderBlock, type.renderMeta, type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
if (input.getItem() instanceof ItemBlock)
addMelting(input, ((ItemBlock) input.getItem()).field_150939_a, type.renderMeta, type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
else
addMelting(input, type.renderBlock, type.renderMeta, type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
}

/**
* Adds all Items to the Smeltery based on the oreDictionary Name
*
* @author samtrion
*
* @param oreName
* oreDictionary name e.g. oreIron
* @param type
* Type of Fluid
* @param temperatureDifference
* Difference between FluidType BaseTemperature
* @param fluidAmount
* Amount of Fluid
* @param oreName oreDictionary name e.g. oreIron
* @param type Type of Fluid
* @param temperatureDifference Difference between FluidType BaseTemperature
* @param fluidAmount Amount of Fluid
*/
public static void addDictionaryMelting (String oreName, FluidType type, int temperatureDifference, int fluidAmount)
{
Expand Down

0 comments on commit c79ddf8

Please sign in to comment.