Added fluid mixture

This commit is contained in:
Calclavia 2014-01-05 14:20:01 +08:00
parent 013c5fb53a
commit 1b4a25fc0b
7 changed files with 128 additions and 170 deletions

View file

@ -4,6 +4,7 @@ import ic2.api.item.Items;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
@ -12,8 +13,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.Icon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@ -24,6 +30,7 @@ import resonantinduction.machine.BlockMachinePart;
import resonantinduction.machine.crusher.ItemDust;
import resonantinduction.machine.furnace.BlockAdvancedFurnace;
import resonantinduction.machine.furnace.TileAdvancedFurnace;
import resonantinduction.machine.liquid.BlockFluidMixture;
import resonantinduction.transport.battery.BlockBattery;
import resonantinduction.transport.battery.ItemBlockBattery;
import resonantinduction.transport.battery.TileBattery;
@ -56,6 +63,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Calclavia
@ -154,7 +163,9 @@ public class ResonantInduction
// Blocks
public static Block blockTesla, blockEMContractor, blockBattery, blockAdvancedFurnace,
blockMachinePart;
blockMachinePart, blockFluidMixture;
public static Fluid MIXTURE;
/**
* Packets
@ -197,6 +208,10 @@ public class ResonantInduction
blockBattery = new BlockBattery(getNextBlockID());
blockMachinePart = new BlockMachinePart(getNextBlockID());
MIXTURE = new Fluid("mixture");
FluidRegistry.registerFluid(MIXTURE);
blockFluidMixture = new BlockFluidMixture(getNextBlockID(), MIXTURE);
if (REPLACE_FURNACE)
{
blockAdvancedFurnace = BlockAdvancedFurnace.createNew(false);
@ -211,6 +226,7 @@ public class ResonantInduction
GameRegistry.registerItem(itemTransformer, itemTransformer.getUnlocalizedName());
GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName());
GameRegistry.registerBlock(blockFluidMixture, blockFluidMixture.getUnlocalizedName());
GameRegistry.registerBlock(blockMachinePart, blockMachinePart.getUnlocalizedName());
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());
@ -337,4 +353,29 @@ public class ResonantInduction
e.printStackTrace();
}
}
public static final HashMap<String, Icon> fluidIconMap = new HashMap<String, Icon>();
public void registerIcon(String name, TextureStitchEvent.Pre event)
{
fluidIconMap.put(name, event.map.registerIcon(name));
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void preTextureHook(TextureStitchEvent.Pre event)
{
if (event.map.textureType == 0)
{
registerIcon(PREFIX + "mixture", event);
}
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event)
{
MIXTURE.setIcons(fluidIconMap.get(PREFIX + "mixture"));
}
}

View file

@ -0,0 +1,27 @@
/**
*
*/
package resonantinduction.core.base;
import calclavia.lib.prefab.block.BlockRotatable;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
import universalelectricity.api.UniversalElectricity;
/**
* @author Calclavia
*
*/
public class BlockRotatableBase extends BlockRotatable
{
public BlockRotatableBase(String name, int id)
{
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), UniversalElectricity.machine);
this.setCreativeTab(TabRI.INSTANCE);
this.setUnlocalizedName(ResonantInduction.PREFIX + name);
this.setTextureName(ResonantInduction.PREFIX + name);
this.setHardness(1f);
}
}

View file

@ -1,169 +0,0 @@
package resonantinduction.core.base;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class ListUtil
{
public static <V> List<V> inverse(List<V> list)
{
List<V> toReturn = new ArrayList<V>();
for (int i = list.size() - 1; i >= 0; i--)
{
toReturn.add(list.get(i));
}
return toReturn;
}
public static <V> List<V> cap(List<V> list, int cap)
{
List<V> toReturn = new ArrayList<V>();
if (list.size() <= cap)
{
toReturn = copy(list);
}
else
{
int count = 0;
for (V obj : list)
{
count++;
toReturn.add(obj);
if (count == cap)
{
break;
}
}
}
return toReturn;
}
public static <V> List<V> copy(List<V> list)
{
List<V> toReturn = new ArrayList<V>();
for (V obj : list)
{
toReturn.add(obj);
}
return toReturn;
}
public static <V> List<V> merge(List<V> listOne, List<V> listTwo)
{
List<V> newList = new ArrayList<V>();
for (V obj : listOne)
{
newList.add(obj);
}
for (V obj : listTwo)
{
newList.add(obj);
}
return newList;
}
public static <V> List<V> capRemains(List<V> list, int cap)
{
List<V> toReturn = new ArrayList<V>();
if (list.size() <= cap)
{
return toReturn;
}
else
{
List<V> inverse = inverse(list);
int iterNeeded = list.size() - cap;
int count = 0;
for (V obj : list)
{
count++;
toReturn.add(obj);
if (count == iterNeeded)
{
break;
}
}
return toReturn;
}
}
public static <V> ArrayList<List<V>> split(List<V> list, int divide)
{
int remain = list.size() % divide;
int size = (list.size() - remain) / divide;
ArrayList<List<V>> toReturn = new ArrayList<List<V>>();
for (int i = 0; i < divide; i++)
{
toReturn.add(i, new ArrayList<V>());
}
for (List<V> iterSet : toReturn)
{
List<V> removed = new ArrayList<V>();
int toAdd = size;
if (remain > 0)
{
remain--;
toAdd++;
}
for (V obj : list)
{
if (toAdd == 0)
{
break;
}
iterSet.add(obj);
removed.add(obj);
toAdd--;
}
for (V obj : removed)
{
list.remove(obj);
}
}
return toReturn;
}
public static <V> V getTop(List<V> list)
{
for (V obj : list)
{
return obj;
}
return null;
}
public static <V> List<V> asList(Set<V> set)
{
return (List<V>) Arrays.asList(set.toArray());
}
}

View file

@ -0,0 +1,27 @@
package resonantinduction.machine.liquid;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
/**
* @author Calclavia
*
*/
public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityProvider
{
public BlockFluidMixture(int id, Fluid fluid)
{
super(id, fluid, Material.water);
this.setTextureName("water_flow");
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileFluidMixture();
}
}

View file

@ -0,0 +1,12 @@
package resonantinduction.machine.liquid;
import calclavia.lib.prefab.tile.TileAdvanced;
/**
* @author Calclavia
*
*/
public class TileFluidMixture extends TileAdvanced
{
}

View file

@ -0,0 +1,17 @@
package resonantinduction.transport.levitator;
import resonantinduction.core.base.BlockRotatableBase;
/**
* A block that represents a filter for item transportation.
*
* @author Calclavia
*
*/
public class BlockFilter extends BlockRotatableBase
{
public BlockFilter(int id)
{
super("filter", id);
}
}

View file

@ -7,11 +7,14 @@ itemGroup.resonantinduction=Resonant Induction
meta.resonantinduction.description=Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!
meta.resonantinduction.credits=Thanks to Archadia for the awesome assets!
fluid.mixture=Mixture
## Blocks
tile.resonantinduction\:tesla.name=Tesla Coil
tile.resonantinduction\:contractor.name=Electromagnetic Levitator
tile.resonantinduction\:battery.name=Battery
tile.resonantinduction\:machinePart.name=Machine Part
tile.resonantinduction\:filter.name=Filter
## Items
item.resonantinduction\:quantumEntangler.name=Quantum Entangler