diff --git a/src/main/java/resonantinduction/core/prefab/item/ItemBase.java b/src/main/java/resonantinduction/core/prefab/item/ItemBase.java index 93b8fca39..8c1e5de57 100644 --- a/src/main/java/resonantinduction/core/prefab/item/ItemBase.java +++ b/src/main/java/resonantinduction/core/prefab/item/ItemBase.java @@ -6,18 +6,19 @@ import resonantinduction.core.Reference; import resonantinduction.core.ResonantInductionTabs; import resonantinduction.core.Settings; -/** - * - * @author AidanBrady - * - */ +/** @author AidanBrady */ public class ItemBase extends Item { - public ItemBase(String name, int id) - { - super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id)); - this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(Reference.PREFIX + name); - this.setTextureName(Reference.PREFIX + name); - } + public ItemBase(String name) + { + this(name, Settings.getNextItemID()); + } + + public ItemBase(String name, int id) + { + super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id)); + this.setCreativeTab(ResonantInductionTabs.CORE); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); + } } diff --git a/src/main/java/resonantinduction/electrical/multimeter/ItemReadoutTools.java b/src/main/java/resonantinduction/electrical/multimeter/ItemReadoutTools.java deleted file mode 100644 index 28ba0b155..000000000 --- a/src/main/java/resonantinduction/electrical/multimeter/ItemReadoutTools.java +++ /dev/null @@ -1,199 +0,0 @@ -package resonantinduction.electrical.multimeter; - -import java.util.List; - -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatMessageComponent; -import net.minecraft.util.Icon; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; -import resonantinduction.api.IReadOut; -import resonantinduction.api.IReadOut.EnumTools; -import resonantinduction.core.Reference; -import resonantinduction.core.Settings; -import resonantinduction.core.prefab.tile.TileEnergyMachine; -import resonantinduction.core.prefab.tile.TileGenerator; -import universalelectricity.api.electricity.IVoltageInput; -import universalelectricity.api.electricity.IVoltageOutput; -import universalelectricity.api.energy.IConductor; -import universalelectricity.api.energy.IEnergyContainer; -import universalelectricity.api.energy.IEnergyNetwork; -import universalelectricity.api.energy.UnitDisplay; -import universalelectricity.api.energy.UnitDisplay.Unit; -import buildcraft.api.power.IPowerReceptor; -import calclavia.lib.prefab.item.ItemBase; -import calclavia.lib.utility.FluidHelper; -import cofh.api.energy.IEnergyStorage; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemReadoutTools extends ItemBase -{ - Icon pipeGuage, multiMeter; - - public ItemReadoutTools() - { - super(Settings.getNextItemID(), "DMTools", Settings.CONFIGURATION, Reference.PREFIX, CreativeTabs.tabTools); - this.setHasSubtypes(true); - this.setMaxStackSize(1); - - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IconRegister iconRegister) - { - this.pipeGuage = iconRegister.registerIcon(Reference.PREFIX + "readout.PipeGauge"); - this.multiMeter = iconRegister.registerIcon(Reference.PREFIX + "readout.multi-Meter"); - } - - @SideOnly(Side.CLIENT) - @Override - public Icon getIconFromDamage(int meta) - { - if (meta == 0) - { - return pipeGuage; - } - if (meta == 1) - { - return multiMeter; - } - return null; - } - - @Override - public String getUnlocalizedName(ItemStack itemStack) - { - int meta = itemStack.getItemDamage(); - if (meta == 0) - { - return "item." + "PipeGauge"; - } - else if (meta == 1) - { - return "item." + "MultiMeter"; - } - return "item." + this.getUnlocalizedName() + "." + meta; - } - - @Override - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(this, 1, 0)); - par3List.add(new ItemStack(this, 1, 1)); - } - - @Override - public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if (!world.isRemote) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - EnumTools tool = EnumTools.get(itemStack.getItemDamage()); - - if (tool != null) - { - ForgeDirection hitSide = ForgeDirection.getOrientation(side); - if (tileEntity instanceof IReadOut) - { - String output = ((IReadOut) tileEntity).getMeterReading(player, hitSide, tool); - if (output != null && !output.isEmpty()) - { - if (output.length() > 100) - { - output = output.substring(0, 100); - } - output.trim(); - player.sendChatToPlayer(ChatMessageComponent.createFromText("ReadOut> " + output)); - return true; - } - } - if (tool == EnumTools.PIPE_GUAGE) - { - if (tileEntity instanceof IFluidHandler) - { - FluidTankInfo[] tanks = ((IFluidHandler) tileEntity).getTankInfo(ForgeDirection.getOrientation(side)); - if (tanks != null) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("FluidHandler> Side:" + hitSide.toString() + " Tanks:" + tanks.length)); - for (FluidStack stack : FluidHelper.getFluidList(tanks)) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("Fluid>" + stack.amount + "mb of " + stack.getFluid().getName())); - } - return true; - } - } - } - // TODO add shift click support to bring up a easier to read GUI or link to the - // block and add an on screen gui so the player can toy with a design and be updated - // TODO add toggle support to only get one energy system(UE,TE,BC,IC2) readings - // rather than all or first type read - if (tool == EnumTools.MULTI_METER) - { - if (tileEntity instanceof IVoltageInput && ((IVoltageInput) tileEntity).getVoltageInput(hitSide) > 0) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("V~In:" + ((IVoltageInput) tileEntity).getVoltageInput(hitSide))); - } - if (tileEntity instanceof IVoltageOutput && ((IVoltageOutput) tileEntity).getVoltageOutput(hitSide) > 0) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("V~Out:" + ((IVoltageOutput) tileEntity).getVoltageOutput(hitSide))); - } - if (tileEntity instanceof IConductor) - { - IEnergyNetwork network = ((IConductor) tileEntity).getNetwork(); - if (network != null) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("Network:" + network.toString())); - player.sendChatToPlayer(ChatMessageComponent.createFromText("E~In:" + UnitDisplay.getDisplay(network.getRequest(), Unit.JOULES, 2, false))); - player.sendChatToPlayer(ChatMessageComponent.createFromText("E~Out:" + UnitDisplay.getDisplay(network.getLastBuffer(), Unit.JOULES, 2, false))); - player.sendChatToPlayer(ChatMessageComponent.createFromText("R~Ohm:" + UnitDisplay.getDisplay(network.getResistance(), Unit.RESISTANCE, 2, false))); - } - } - else if (tileEntity instanceof IEnergyContainer) - { - if (((IEnergyContainer) tileEntity).getEnergyCapacity(hitSide) > 0) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("E~:" + UnitDisplay.getDisplay(((IEnergyContainer) tileEntity).getEnergy(hitSide), Unit.JOULES, 2, false) + "/" + UnitDisplay.getDisplay(((IEnergyContainer) tileEntity).getEnergyCapacity(hitSide), Unit.JOULES, 2, false))); - } - if (tileEntity instanceof TileEnergyMachine) - { - if (tileEntity instanceof TileGenerator) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("E~Out:" + UnitDisplay.getDisplay(((TileEnergyMachine) tileEntity).getJoulesPerTick(), Unit.JOULES, 2, true) + "/tick")); - } - else - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("E~In:" + UnitDisplay.getDisplay(((TileEnergyMachine) tileEntity).getJoulesPerTick(), Unit.JOULES, 2, true) + "/tick")); - - } - } - } - else if (tileEntity instanceof IEnergyStorage && ((IEnergyStorage) tileEntity).getMaxEnergyStored() > 0) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("RF~:" + UnitDisplay.getDisplay(((IEnergyStorage) tileEntity).getEnergyStored(), Unit.REDFLUX, 2, true) + "/" + UnitDisplay.getDisplay(((IEnergyStorage) tileEntity).getMaxEnergyStored(), Unit.REDFLUX, 2, true))); - } - else if (tileEntity instanceof IPowerReceptor && ((IPowerReceptor) tileEntity).getPowerReceiver(hitSide) != null && ((IPowerReceptor) tileEntity).getPowerReceiver(hitSide).getMaxEnergyStored() > 0) - { - // TODO recode for input and output - if (((IPowerReceptor) tileEntity).getPowerReceiver(hitSide) != null) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText("Mj~:" + UnitDisplay.getDisplay(((IPowerReceptor) tileEntity).getPowerReceiver(hitSide).getEnergyStored(), Unit.MINECRAFT_JOULES, 2, true) + "/" + UnitDisplay.getDisplay(((IPowerReceptor) tileEntity).getPowerReceiver(hitSide).getMaxEnergyStored(), Unit.MINECRAFT_JOULES, 2, true))); - } - } - // TODO add IC2 support - } - } - - } - - return false; - } -} diff --git a/src/main/java/resonantinduction/mechanical/Mechanical.java b/src/main/java/resonantinduction/mechanical/Mechanical.java index 95f725132..060bea327 100644 --- a/src/main/java/resonantinduction/mechanical/Mechanical.java +++ b/src/main/java/resonantinduction/mechanical/Mechanical.java @@ -1,6 +1,7 @@ package resonantinduction.mechanical; import net.minecraft.block.Block; +import net.minecraft.item.Item; import resonantinduction.core.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.Settings; @@ -17,6 +18,7 @@ import resonantinduction.mechanical.fluid.tank.BlockTank; import resonantinduction.mechanical.fluid.tank.TileTank; import resonantinduction.mechanical.gear.BlockGear; import resonantinduction.mechanical.gear.TileGear; +import resonantinduction.mechanical.item.ItemPipeGauge; import resonantinduction.mechanical.logistic.BlockDetector; import resonantinduction.mechanical.logistic.BlockManipulator; import resonantinduction.mechanical.logistic.BlockRejector; @@ -35,72 +37,74 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; -/** - * Resonant Induction Archaic Module +/** Resonant Induction Archaic Module * - * @author DarkCow, Calclavia - */ + * @author DarkCow, Calclavia */ @Mod(modid = Mechanical.ID, name = Mechanical.NAME, version = Reference.VERSION, dependencies = "required-after:" + ResonantInduction.ID) @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class Mechanical { - /** Mod Information */ - public static final String ID = "ResonantInduction|Mechanical"; - public static final String NAME = Reference.NAME + " Mechanical"; + /** Mod Information */ + public static final String ID = "ResonantInduction|Mechanical"; + public static final String NAME = Reference.NAME + " Mechanical"; - @Instance(ID) - public static Mechanical INSTANCE; + @Instance(ID) + public static Mechanical INSTANCE; - @SidedProxy(clientSide = "resonantinduction.mechanical.ClientProxy", serverSide = "resonantinduction.mechanical.CommonProxy") - public static CommonProxy proxy; + @SidedProxy(clientSide = "resonantinduction.mechanical.ClientProxy", serverSide = "resonantinduction.mechanical.CommonProxy") + public static CommonProxy proxy; - @Mod.Metadata(ID) - public static ModMetadata metadata; + @Mod.Metadata(ID) + public static ModMetadata metadata; - public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID); + public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID); - // Energy - public static Block blockGear; - public static Block blockGearShaft; + // Energy + public static Block blockGear; + public static Block blockGearShaft; - // Transport - public static Block blockConveyorBelt; - public static Block blockManipulator; - public static Block blockDetector; - public static Block blockRejector; + // Transport + public static Block blockConveyorBelt; + public static Block blockManipulator; + public static Block blockDetector; + public static Block blockRejector; - // Fluids - public static Block blockTank; - public static Block blockPipe; - public static Block blockReleaseValve; - public static Block blockGrate; - public static Block blockPump; + // Fluids + public static Block blockTank; + public static Block blockPipe; + public static Block blockReleaseValve; + public static Block blockGrate; + public static Block blockPump; - @EventHandler - public void preInit(FMLPreInitializationEvent evt) - { - Settings.load(); - NetworkRegistry.instance().registerGuiHandler(this, proxy); - blockGear = contentRegistry.createTile(BlockGear.class, TileGear.class); - //blockGearShaft = contentRegistry.createTile(BlockRejector.class, TileRejector.class); - - blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class); - blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class); - blockDetector = contentRegistry.createTile(BlockDetector.class, TileDetector.class); - blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class); + public static Item itemPipeGuage; - blockTank = contentRegistry.createBlock(BlockTank.class, ItemBlockFluidContainer.class, TileTank.class); - blockPipe = contentRegistry.createBlock(BlockPipe.class, ItemBlockFluidContainer.class, TilePipe.class); - blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class); - blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class); - proxy.preInit(); - Settings.save(); - } + @EventHandler + public void preInit(FMLPreInitializationEvent evt) + { + Settings.load(); + NetworkRegistry.instance().registerGuiHandler(this, proxy); + blockGear = contentRegistry.createTile(BlockGear.class, TileGear.class); + //blockGearShaft = contentRegistry.createTile(BlockRejector.class, TileRejector.class); - @EventHandler - public void init(FMLInitializationEvent evt) - { - Settings.setModMetadata(metadata, ID, NAME); - proxy.init(); - } + blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class); + blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class); + blockDetector = contentRegistry.createTile(BlockDetector.class, TileDetector.class); + blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class); + + blockTank = contentRegistry.createBlock(BlockTank.class, ItemBlockFluidContainer.class, TileTank.class); + blockPipe = contentRegistry.createBlock(BlockPipe.class, ItemBlockFluidContainer.class, TilePipe.class); + blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class); + blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class); + + itemPipeGuage = contentRegistry.createItem("PipeGauge", ItemPipeGauge.class); + proxy.preInit(); + Settings.save(); + } + + @EventHandler + public void init(FMLInitializationEvent evt) + { + Settings.setModMetadata(metadata, ID, NAME); + proxy.init(); + } } diff --git a/src/main/java/resonantinduction/mechanical/item/ItemReadoutTools.java b/src/main/java/resonantinduction/mechanical/item/ItemPipeGauge.java similarity index 75% rename from src/main/java/resonantinduction/mechanical/item/ItemReadoutTools.java rename to src/main/java/resonantinduction/mechanical/item/ItemPipeGauge.java index 28bccb2bc..ea44954d3 100644 --- a/src/main/java/resonantinduction/mechanical/item/ItemReadoutTools.java +++ b/src/main/java/resonantinduction/mechanical/item/ItemPipeGauge.java @@ -23,55 +23,20 @@ import calclavia.lib.utility.FluidHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemReadoutTools extends ItemBase +public class ItemPipeGauge extends ItemBase { Icon pipeGuage; - public ItemReadoutTools() + public ItemPipeGauge() { - super("PipeGuage", Settings.getNextItemID()); + super("PipeGuage"); this.setHasSubtypes(true); this.setCreativeTab(CreativeTabs.tabTools); this.setMaxStackSize(1); + this.setTextureName(Reference.PREFIX + "readout.PipeGauge"); } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IconRegister iconRegister) - { - this.pipeGuage = iconRegister.registerIcon(Reference.PREFIX + "readout.PipeGauge"); - } - - @SideOnly(Side.CLIENT) - @Override - public Icon getIconFromDamage(int meta) - { - if (meta == 0) - { - return pipeGuage; - } - return null; - } - - @Override - public String getUnlocalizedName(ItemStack itemStack) - { - int meta = itemStack.getItemDamage(); - if (meta == 0) - { - return "item." + "PipeGauge"; - } - return "item." + this.getUnlocalizedName() + "." + meta; - } - - @Override - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(this, 1, 0)); - par3List.add(new ItemStack(this, 1, 1)); - } - @Override public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {