This commit is contained in:
Aidan Brady 2013-08-04 22:32:46 -04:00
commit e3ab3e67ea
4 changed files with 73 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -4,7 +4,6 @@
package resonantinduction.battery; package resonantinduction.battery;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -12,6 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.api.IBattery;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -32,7 +32,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float xClick, float yClick, float zClick)
{ {
if (entityPlayer.isSneaking()) if (entityPlayer.isSneaking())
{ {
@ -40,7 +40,61 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
} }
else else
{ {
if (entityPlayer.getCurrentEquippedItem() != null)
{
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IBattery)
{
if (side != 0 && side != 1)
{
/**
* Place cells into block. 2 Dimensional Click Zone
*/
float xHit = 0;
float yHit = yClick;
if (side == 2 || side == 3)
{
xHit = xClick;
if (side == 2)
{
xHit = 1 - xHit;
}
}
else if (side == 4 || side == 5)
{
xHit = zClick;
if (side == 5)
{
xHit = 1 - xHit;
}
}
// Convert to quadrant coords.
xHit -= 0.5f;
yHit -= 0.5f;
// Quadrant 1
if (xHit > 0 && yHit > 0)
{
}// Quadrant 2
if (xHit > 0 && yHit < 0)
{
}// Quadrant 3
if (xHit < 0 && yHit < 0)
{
}// Quadrant 4
if (xHit < 0 && yHit > 0)
{
}
}
}
}
} }
return true; return true;

View file

@ -75,10 +75,10 @@ public class GuiMultimeter extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2) protected void drawGuiContainerForegroundLayer(int par1, int par2)
{ {
String s = this.tileEntity.getBlockType().getLocalizedName(); String s = this.tileEntity.getBlockType().getLocalizedName();
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752); this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
this.fontRenderer.drawString("Energy: " + Math.round(this.tileEntity.getDetectedEnergy()) + " J", 35, 32, 4210752); this.fontRenderer.drawString("Average Energy: " + Math.round(this.tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752);
this.fontRenderer.drawString("Average Energy: " + Math.round(this.tileEntity.getAverageDetectedEnergy()) + " J", 35, 20, 4210752); this.fontRenderer.drawString("Energy: " + Math.round(this.tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752);
this.fontRenderer.drawString("Output Redstone If... ", 35, 46, 4210752); this.fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752);
this.fontRenderer.drawString(this.tileEntity.getMode().display, 35, 65, 4210752); this.fontRenderer.drawString(this.tileEntity.getMode().display, 35, 65, 4210752);
this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752); this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752);
@ -95,12 +95,9 @@ public class GuiMultimeter extends GuiContainer
GL11.glColor4f(1, 1, 1, 1); GL11.glColor4f(1, 1, 1, 1);
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize);
/* int length = (int) (this.tileEntity.getDetectedEnergy() / this.tileEntity.getPeak()) * 117;
* if (this.tileEntity.getMode() != DetectMode.NONE) { int length = (int) // length = 177;
* (Math.abs(this.tileEntity.getDetectedEnergy() - this.tileEntity.getLimit()) / this.drawTexturedModalRect(this.containerWidth + 13, this.containerHeight + 133 - length, 176, 117 - length, 30, length);
* this.tileEntity.getLimit()) * 110; this.drawTexturedModalRect(this.containerWidth + 13,
* this.containerHeight + 128 - length, 176, 0, 30, length); }
*/
} }
@Override @Override

View file

@ -37,6 +37,7 @@ public class TileEntityMultimeter extends TileEntityBase implements IPacketRecei
} }
private DetectMode detectMode = DetectMode.NONE; private DetectMode detectMode = DetectMode.NONE;
private float peakDetection;
private float energyLimit; private float energyLimit;
private float detectedEnergy; private float detectedEnergy;
private float detectedAverageEnergy; private float detectedAverageEnergy;
@ -52,6 +53,7 @@ public class TileEntityMultimeter extends TileEntityBase implements IPacketRecei
float prevDetectedEnergy = this.detectedEnergy; float prevDetectedEnergy = this.detectedEnergy;
this.detectedEnergy = this.doGetDetectedEnergy(); this.detectedEnergy = this.doGetDetectedEnergy();
this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2; this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2;
this.peakDetection = Math.max(peakDetection, this.detectedEnergy);
boolean outputRedstone = false; boolean outputRedstone = false;
@ -193,4 +195,12 @@ public class TileEntityMultimeter extends TileEntityBase implements IPacketRecei
return this.energyLimit; return this.energyLimit;
} }
/**
* @return
*/
public float getPeak()
{
return this.peakDetection;
}
} }