Tweaked color generator and molten metals

This commit is contained in:
Calclavia 2014-01-28 23:30:54 +08:00
parent 9a580564fb
commit a1b0747ba6
4 changed files with 59 additions and 47 deletions

View file

@ -14,6 +14,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.TileMaterial;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver;
@ -75,14 +76,14 @@ public class TileFirebox extends TileExternalInventory implements IPacketSender,
{
usedHeat = true;
if (heatEnergy >= requiredMeltIronEnergy)
//if (heatEnergy >= requiredMeltIronEnergy)
{
TileEntity dustTile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (dustTile instanceof TileMaterial)
{
String name = ((TileMaterial) dustTile).name;
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResonantInduction.blockFluidMaterial.blockID, 8, 3);
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResonantInduction.blockFluidMaterial.get(ResourceGenerator.materialNames.indexOf(name)).blockID, 8, 3);
TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (tile instanceof TileMaterial)

View file

@ -1,5 +1,7 @@
package resonantinduction.core;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.minecraft.block.Block;
@ -74,11 +76,11 @@ public class ResonantInduction
public static ItemOreResource itemRefinedDust;
public static Block blockDust;
public static Block blockFluidMixture;
public static Block blockFluidMaterial;
public static List<Block> blockFluidMaterial = new ArrayList<Block>();
public static Block blockGas;
public static Fluid fluidMixture;
public static Fluid fluidMaterial;
public static List<Fluid> fluidMaterial = new ArrayList<Fluid>();
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID);
@ -99,16 +101,11 @@ public class ResonantInduction
fluidMixture = new Fluid("water");
FluidRegistry.registerFluid(fluidMixture);
blockFluidMixture = contentRegistry.createTile(BlockFluidMixture.class, TileFluidMixture.class);
/**
* Melting dusts
*/
blockDust = contentRegistry.createTile(BlockDust.class, TileMaterial.class);
fluidMaterial = new Fluid("moltenMaterial");
fluidMaterial.setDensity(7);
fluidMaterial.setViscosity(10000);
fluidMaterial.setTemperature(273 + 1538);
FluidRegistry.registerFluid(fluidMaterial);
blockFluidMaterial = contentRegistry.createTile(BlockFluidMaterial.class, TileMaterial.class);
// Items
itemRubble = new ItemOreResource(Settings.getNextItemID(), "oreRubble");
@ -135,7 +132,7 @@ public class ResonantInduction
@EventHandler
public void postInit(FMLPostInitializationEvent evt)
{
// Generate Dusts
// Generate Resources
ResourceGenerator.generateOreResources();
}

View file

@ -18,6 +18,8 @@ import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import resonantinduction.api.recipe.MachineRecipes;
@ -25,6 +27,8 @@ import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.api.recipe.OreDetectionBlackList;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -66,26 +70,38 @@ public class ResourceGenerator
for (String materialName : materialNames)
{
// Caps version of the name
String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
String nameCaps = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
if (OreDictionary.getOres("ore" + name).size() > 0)
/**
* Generate molten fluids
*/
Fluid fluidMaterial = new Fluid("molten" + nameCaps);
fluidMaterial.setDensity(7);
fluidMaterial.setViscosity(5000);
fluidMaterial.setTemperature(273 + 1538);
FluidRegistry.registerFluid(fluidMaterial);
Block blockFluidMaterial = new BlockFluidMaterial(fluidMaterial);
GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps);
ResonantInduction.blockFluidMaterial.add(blockFluidMaterial);
if (OreDictionary.getOres("ore" + nameCaps).size() > 0)
{
if (OreDictionary.getOres("dust" + name).size() == 0)
if (OreDictionary.getOres("dust" + nameCaps).size() == 0)
{
OreDictionary.registerOre("rubble" + name, ResonantInduction.itemRubble.getStackFromMaterial(materialName));
OreDictionary.registerOre("dust" + name, ResonantInduction.itemDust.getStackFromMaterial(materialName));
OreDictionary.registerOre("dustRefined" + name, ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName));
OreDictionary.registerOre("rubble" + nameCaps, ResonantInduction.itemRubble.getStackFromMaterial(materialName));
OreDictionary.registerOre("dust" + nameCaps, ResonantInduction.itemDust.getStackFromMaterial(materialName));
OreDictionary.registerOre("dustRefined" + nameCaps, ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName));
}
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER, "ore" + name, "rubble" + name);
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "rubble" + name, "dust" + name, "dust" + name);
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER, "dust" + name, "dustRefined" + name);
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER, "dustRefined" + name, "ingot" + name);
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER, "ore" + nameCaps, "rubble" + nameCaps);
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "rubble" + nameCaps, "dust" + nameCaps, "dust" + nameCaps);
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER, "dust" + nameCaps, "dustRefined" + nameCaps);
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER, "dustRefined" + nameCaps, "ingot" + nameCaps);
ItemStack dust = ResonantInduction.itemDust.getStackFromMaterial(materialName);
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), OreDictionary.getOres("ingot" + name).get(0).copy(), 0.7f);
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), OreDictionary.getOres("ingot" + nameCaps).get(0).copy(), 0.7f);
ItemStack refinedDust = ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName);
ItemStack smeltResult = OreDictionary.getOres("ingot" + name).get(0).copy();
ItemStack smeltResult = OreDictionary.getOres("ingot" + nameCaps).get(0).copy();
smeltResult.stackSize = 2;
FurnaceRecipes.smelting().addSmelting(refinedDust.itemID, refinedDust.getItemDamage(), smeltResult, 0.7f);
}
@ -166,10 +182,19 @@ public class ResourceGenerator
for (int y = 0; y < height; y++)
{
Color rgb = new Color(bufferedimage.getRGB(x, y));
totalR += rgb.getRed();
totalG += rgb.getGreen();
totalB += rgb.getBlue();
colorCount++;
/**
* Ignore things that are too dark.per ITU-R BT.709
*/
double luma = 0.2126 * rgb.getRed() + 0.7152 * rgb.getGreen() + 0.0722 * rgb.getGreen();
if (luma > 50)
{
totalR += rgb.getRed();
totalG += rgb.getGreen();
totalB += rgb.getBlue();
colorCount++;
}
}
}
}

View file

@ -25,13 +25,14 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author Calclavia
*
*/
public class BlockFluidMaterial extends BlockFluidFinite implements ITileEntityProvider
public class BlockFluidMaterial extends BlockFluidFinite
{
public BlockFluidMaterial()
public BlockFluidMaterial(Fluid fluid)
{
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, "fluidMaterial", Settings.getNextBlockID()).getInt(), ResonantInduction.fluidMaterial, Material.lava);
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, fluid.getName(), Settings.getNextBlockID()).getInt(), fluid, Material.lava);
setTextureName(Reference.PREFIX + "molten_flow");
this.setUnlocalizedName(Reference.PREFIX + "fluidMaterial");
setUnlocalizedName(Reference.PREFIX + "fluidMaterial");
setQuantaPerBlock(16);
}
public void setQuanta(World world, int x, int y, int z, int quanta)
@ -46,8 +47,9 @@ public class BlockFluidMaterial extends BlockFluidFinite implements ITileEntityP
@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
{
TileMaterial tileFluid = (TileMaterial) world.getBlockTileEntity(x, y, z);
FluidStack stack = new FluidStack(ResonantInduction.fluidMaterial, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
FluidStack stack = new FluidStack(getFluid(), (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
if (doDrain)
world.setBlockToAir(x, y, z);
return stack;
}
@ -55,14 +57,7 @@ public class BlockFluidMaterial extends BlockFluidFinite implements ITileEntityP
@Override
public int colorMultiplier(IBlockAccess access, int x, int y, int z)
{
TileEntity tileEntity = access.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileMaterial)
{
return ((TileMaterial) tileEntity).clientColor;
}
return 16777215;
return ResourceGenerator.materialColors.get(getFluid().getName().replace("molten", "").toLowerCase());
}
@Override
@ -70,10 +65,4 @@ public class BlockFluidMaterial extends BlockFluidFinite implements ITileEntityP
{
return true;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileMaterial();
}
}