diff --git a/build.properties b/build.properties index 51e863cf7..fcb992797 100644 --- a/build.properties +++ b/build.properties @@ -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 \ No newline at end of file diff --git a/resources/assets/resonantinduction/textures/gui/batterybox_gui.png b/resources/assets/resonantinduction/textures/gui/batterybox_gui.png index a44d57d5f..b0e31bbc0 100644 Binary files a/resources/assets/resonantinduction/textures/gui/batterybox_gui.png and b/resources/assets/resonantinduction/textures/gui/batterybox_gui.png differ diff --git a/src/resonantinduction/api/IBattery.java b/src/resonantinduction/api/IBattery.java index e308a92dc..a24ff289c 100644 --- a/src/resonantinduction/api/IBattery.java +++ b/src/resonantinduction/api/IBattery.java @@ -16,6 +16,8 @@ public interface IBattery public float getEnergyStored(ItemStack itemStack); public float getMaxEnergyStored(ItemStack itemStack); + + public float getTransfer(ItemStack itemStack); /** * @param itemStack diff --git a/src/resonantinduction/battery/ItemCapacitor.java b/src/resonantinduction/battery/ItemCapacitor.java index e6e4fdb24..f7da0caca 100644 --- a/src/resonantinduction/battery/ItemCapacitor.java +++ b/src/resonantinduction/battery/ItemCapacitor.java @@ -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) diff --git a/src/resonantinduction/battery/TileEntityBattery.java b/src/resonantinduction/battery/TileEntityBattery.java index 119bb5c5d..1c20e14b8 100644 --- a/src/resonantinduction/battery/TileEntityBattery.java +++ b/src/resonantinduction/battery/TileEntityBattery.java @@ -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) diff --git a/src/resonantinduction/multimeter/BlockMultimeter.java b/src/resonantinduction/multimeter/BlockMultimeter.java index a09270877..9745689c7 100644 --- a/src/resonantinduction/multimeter/BlockMultimeter.java +++ b/src/resonantinduction/multimeter/BlockMultimeter.java @@ -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) {