From 1b4a25fc0b577373e1430c44f734caed14b69239 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 5 Jan 2014 14:20:01 +0800 Subject: [PATCH] Added fluid mixture --- .../resonantinduction/ResonantInduction.java | 43 ++++- .../core/base/BlockRotatableBase.java | 27 +++ .../resonantinduction/core/base/ListUtil.java | 169 ------------------ .../machine/liquid/BlockFluidMixture.java | 27 +++ .../machine/liquid/TileFluidMixture.java | 12 ++ .../transport/levitator/BlockFilter.java | 17 ++ .../languages/en_US.properties | 3 + 7 files changed, 128 insertions(+), 170 deletions(-) create mode 100644 src/main/java/resonantinduction/core/base/BlockRotatableBase.java delete mode 100644 src/main/java/resonantinduction/core/base/ListUtil.java create mode 100644 src/main/java/resonantinduction/machine/liquid/BlockFluidMixture.java create mode 100644 src/main/java/resonantinduction/machine/liquid/TileFluidMixture.java create mode 100644 src/main/java/resonantinduction/transport/levitator/BlockFilter.java diff --git a/src/main/java/resonantinduction/ResonantInduction.java b/src/main/java/resonantinduction/ResonantInduction.java index 0a9766a8..fedb6a90 100644 --- a/src/main/java/resonantinduction/ResonantInduction.java +++ b/src/main/java/resonantinduction/ResonantInduction.java @@ -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 fluidIconMap = new HashMap(); + + 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")); + } + } diff --git a/src/main/java/resonantinduction/core/base/BlockRotatableBase.java b/src/main/java/resonantinduction/core/base/BlockRotatableBase.java new file mode 100644 index 00000000..a63bbdcf --- /dev/null +++ b/src/main/java/resonantinduction/core/base/BlockRotatableBase.java @@ -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); + } +} diff --git a/src/main/java/resonantinduction/core/base/ListUtil.java b/src/main/java/resonantinduction/core/base/ListUtil.java deleted file mode 100644 index 61caf7d5..00000000 --- a/src/main/java/resonantinduction/core/base/ListUtil.java +++ /dev/null @@ -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 List inverse(List list) - { - List toReturn = new ArrayList(); - - for (int i = list.size() - 1; i >= 0; i--) - { - toReturn.add(list.get(i)); - } - - return toReturn; - } - - public static List cap(List list, int cap) - { - List toReturn = new ArrayList(); - - 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 List copy(List list) - { - List toReturn = new ArrayList(); - - for (V obj : list) - { - toReturn.add(obj); - } - - return toReturn; - } - - public static List merge(List listOne, List listTwo) - { - List newList = new ArrayList(); - - for (V obj : listOne) - { - newList.add(obj); - } - - for (V obj : listTwo) - { - newList.add(obj); - } - - return newList; - } - - public static List capRemains(List list, int cap) - { - List toReturn = new ArrayList(); - - if (list.size() <= cap) - { - return toReturn; - } - else - { - List 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 ArrayList> split(List list, int divide) - { - int remain = list.size() % divide; - int size = (list.size() - remain) / divide; - - ArrayList> toReturn = new ArrayList>(); - - for (int i = 0; i < divide; i++) - { - toReturn.add(i, new ArrayList()); - } - - for (List iterSet : toReturn) - { - List removed = new ArrayList(); - - 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 getTop(List list) - { - for (V obj : list) - { - return obj; - } - - return null; - } - - public static List asList(Set set) - { - return (List) Arrays.asList(set.toArray()); - } -} diff --git a/src/main/java/resonantinduction/machine/liquid/BlockFluidMixture.java b/src/main/java/resonantinduction/machine/liquid/BlockFluidMixture.java new file mode 100644 index 00000000..b15db5bc --- /dev/null +++ b/src/main/java/resonantinduction/machine/liquid/BlockFluidMixture.java @@ -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(); + } +} diff --git a/src/main/java/resonantinduction/machine/liquid/TileFluidMixture.java b/src/main/java/resonantinduction/machine/liquid/TileFluidMixture.java new file mode 100644 index 00000000..b9d4690c --- /dev/null +++ b/src/main/java/resonantinduction/machine/liquid/TileFluidMixture.java @@ -0,0 +1,12 @@ +package resonantinduction.machine.liquid; + +import calclavia.lib.prefab.tile.TileAdvanced; + +/** + * @author Calclavia + * + */ +public class TileFluidMixture extends TileAdvanced +{ + +} diff --git a/src/main/java/resonantinduction/transport/levitator/BlockFilter.java b/src/main/java/resonantinduction/transport/levitator/BlockFilter.java new file mode 100644 index 00000000..417c5896 --- /dev/null +++ b/src/main/java/resonantinduction/transport/levitator/BlockFilter.java @@ -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); + } +} diff --git a/src/main/resources/assets/resonantinduction/languages/en_US.properties b/src/main/resources/assets/resonantinduction/languages/en_US.properties index b91b34d5..781481d6 100644 --- a/src/main/resources/assets/resonantinduction/languages/en_US.properties +++ b/src/main/resources/assets/resonantinduction/languages/en_US.properties @@ -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