Added handheld multimeter reading feature

This commit is contained in:
Calclavia 2013-08-03 22:00:43 -04:00
parent f77f7387b7
commit 7eaf73341b
3 changed files with 45 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import resonantinduction.contractor.ItemBlockContractor;
import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.entangler.ItemQuantumEntangler;
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.multimeter.ItemBlockMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter;
import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
@ -141,7 +142,7 @@ public class ResonantInduction
CONFIGURATION.save();
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockMultimeter, blockMultimeter.getUnlocalizedName());
GameRegistry.registerBlock(blockMultimeter, ItemBlockMultimeter.class, blockMultimeter.getUnlocalizedName());
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());
// Tiles

View file

@ -0,0 +1,37 @@
/**
*
*/
package resonantinduction.multimeter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* ItemBlock for the Multimeter
*
* @author Calclavia
*
*/
public class ItemBlockMultimeter extends ItemBlock
{
public ItemBlockMultimeter(int par1)
{
super(par1);
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
if (par2EntityPlayer.isSneaking())
{
if (!world.isRemote)
{
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
}
return true;
}
return super.onItemUse(par1ItemStack, par2EntityPlayer, world, x, y, z, par7, par8, par9, par10);
}
}

View file

@ -126,11 +126,17 @@ public class TileEntityMultimeter extends TileEntityBase implements IPacketRecei
ForgeDirection opp = direction.getOpposite();
TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord + opp.offsetX, this.yCoord + opp.offsetY, this.zCoord + opp.offsetZ);
return getDetectedEnergy(tileEntity);
}
public static float getDetectedEnergy(TileEntity tileEntity)
{
// TODO: Universal Compatiblity in the future.
if (tileEntity instanceof TileEntityTesla)
{
return ((TileEntityTesla) tileEntity).getEnergyStored();
}
return 0;
}