Conflicts:
	src/resonantinduction/battery/TileEntityBattery.java
This commit is contained in:
Calclavia 2013-08-05 13:02:31 -04:00
commit cafd17a9ac
6 changed files with 80 additions and 3 deletions

View file

@ -2,6 +2,6 @@ dir.development=./
dir.mcp=${dir.development}forge/mcp
version.minecraft=1.6.2
version.mod.major=0
version.mod.minor=0
version.mod.revis=1
version.mod.minor=1
version.mod.revis=0
version.universalelectricity=2.0.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View file

@ -16,6 +16,8 @@ public interface IBattery
public float getEnergyStored(ItemStack itemStack);
public float getMaxEnergyStored(ItemStack itemStack);
public float getTransfer(ItemStack itemStack);
/**
* @param itemStack

View file

@ -66,6 +66,12 @@ public class ItemCapacitor extends ItemBase implements IBattery
return amount;
}
@Override
public float getTransfer(ItemStack itemStack)
{
return getMaxEnergyStored(itemStack)*0.05F;
}
@Override
public float getMaxEnergyStored(ItemStack itemStack)

View file

@ -69,6 +69,30 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
}
}
if (structure.visibleInventory[1] != null)
{
ItemStack itemStack = structure.visibleInventory[1];
IBattery battery = (IBattery) itemStack.getItem();
float energyStored = getMaxEnergyStored();
float batteryNeeded = battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack);
float toGive = Math.min(energyStored, Math.min(battery.getTransfer(itemStack), batteryNeeded));
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + removeEnergy(toGive, true));
}
if (structure.visibleInventory[2] != null)
{
ItemStack itemStack = structure.visibleInventory[2];
IBattery battery = (IBattery) itemStack.getItem();
float energyNeeded = getMaxEnergyStored() - getEnergyStored();
float batteryStored = battery.getEnergyStored(itemStack);
float toReceive = Math.min(energyNeeded, Math.min(battery.getTransfer(itemStack), batteryStored));
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) - addEnergy(toReceive, true));
}
if (prevStructure != structure)
{
for (EntityPlayer player : playersUsing)

View file

@ -6,6 +6,9 @@ package resonantinduction.multimeter;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -29,9 +32,51 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
this.func_111022_d(ResonantInduction.PREFIX + "machine");
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
@Override
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
int metadata = par1World.getBlockMetadata(par2, par3, par4) & 7;
float thickness = 0.15f;
System.out.println(metadata);
if (metadata == 0)
{
this.setBlockBounds(0, 0, 0, 1, thickness, 1);
}
else if (metadata == 1)
{
this.setBlockBounds(0, 1 - thickness, 0, 1, 1, 1);
}
else if (metadata == 2)
{
this.setBlockBounds(0, 0, 0, 1, 1, thickness);
}
else if (metadata == 3)
{
this.setBlockBounds(1-thickness, 0, 1-thickness, 1, 1, 1-thickness);
// this.setBlockBounds(0.5F - thickness, 0.2F, 1.0F - thickness * 2.0F, 0.5F + thickness, 0.8F, 1.0F);
}
else if (metadata == 4)
{
this.setBlockBounds(0.0F, 0.2F, 0.5F - thickness, thickness * 2.0F, 0.8F, 0.5F + thickness);
}
else if (metadata == 5)
{
this.setBlockBounds(1.0F - thickness * 2.0F, 0.2F, 0.5F - thickness, 1.0F, 0.8F, 0.5F + thickness);
}
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
* hitZ, block metadata
* hi@OverridetZ, block metadata
*/
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
{