Re-add pipe gauge and removed old versions

This commit is contained in:
DarkGuardsman 2014-01-14 03:13:01 -05:00
parent 0d431b24d3
commit 2ba673c5ad
4 changed files with 74 additions and 303 deletions

View file

@ -6,13 +6,14 @@ import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInductionTabs; import resonantinduction.core.ResonantInductionTabs;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
/** /** @author AidanBrady */
*
* @author AidanBrady
*
*/
public class ItemBase extends Item public class ItemBase extends Item
{ {
public ItemBase(String name)
{
this(name, Settings.getNextItemID());
}
public ItemBase(String name, int id) public ItemBase(String name, int id)
{ {
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id)); super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id));

View file

@ -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;
}
}

View file

@ -1,6 +1,7 @@
package resonantinduction.mechanical; package resonantinduction.mechanical;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
@ -17,6 +18,7 @@ import resonantinduction.mechanical.fluid.tank.BlockTank;
import resonantinduction.mechanical.fluid.tank.TileTank; import resonantinduction.mechanical.fluid.tank.TileTank;
import resonantinduction.mechanical.gear.BlockGear; import resonantinduction.mechanical.gear.BlockGear;
import resonantinduction.mechanical.gear.TileGear; import resonantinduction.mechanical.gear.TileGear;
import resonantinduction.mechanical.item.ItemPipeGauge;
import resonantinduction.mechanical.logistic.BlockDetector; import resonantinduction.mechanical.logistic.BlockDetector;
import resonantinduction.mechanical.logistic.BlockManipulator; import resonantinduction.mechanical.logistic.BlockManipulator;
import resonantinduction.mechanical.logistic.BlockRejector; import resonantinduction.mechanical.logistic.BlockRejector;
@ -35,11 +37,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; 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) @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) @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Mechanical public class Mechanical
@ -76,6 +76,8 @@ public class Mechanical
public static Block blockGrate; public static Block blockGrate;
public static Block blockPump; public static Block blockPump;
public static Item itemPipeGuage;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent evt) public void preInit(FMLPreInitializationEvent evt)
{ {
@ -93,6 +95,8 @@ public class Mechanical
blockPipe = contentRegistry.createBlock(BlockPipe.class, ItemBlockFluidContainer.class, TilePipe.class); blockPipe = contentRegistry.createBlock(BlockPipe.class, ItemBlockFluidContainer.class, TilePipe.class);
blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class); blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class);
blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class); blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class);
itemPipeGuage = contentRegistry.createItem("PipeGauge", ItemPipeGauge.class);
proxy.preInit(); proxy.preInit();
Settings.save(); Settings.save();
} }

View file

@ -23,55 +23,20 @@ import calclavia.lib.utility.FluidHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class ItemReadoutTools extends ItemBase public class ItemPipeGauge extends ItemBase
{ {
Icon pipeGuage; Icon pipeGuage;
public ItemReadoutTools() public ItemPipeGauge()
{ {
super("PipeGuage", Settings.getNextItemID()); super("PipeGuage");
this.setHasSubtypes(true); this.setHasSubtypes(true);
this.setCreativeTab(CreativeTabs.tabTools); this.setCreativeTab(CreativeTabs.tabTools);
this.setMaxStackSize(1); 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 @Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{ {