Added ability to left/right click capacitors into battery
This commit is contained in:
parent
fd8806ffee
commit
19208dd01a
2 changed files with 57 additions and 30 deletions
|
@ -14,6 +14,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.api.IBattery;
|
||||
import resonantinduction.base.BlockBase;
|
||||
import resonantinduction.base.ListUtil;
|
||||
import resonantinduction.render.BlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -32,6 +33,21 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
this.func_111022_d(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer)
|
||||
{
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = ListUtil.getTop(tileEntity.structure.inventory);
|
||||
|
||||
if (tileEntity.structure.inventory.remove(itemStack))
|
||||
{
|
||||
entityPlayer.dropPlayerItem(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float xClick, float yClick, float zClick)
|
||||
{
|
||||
|
@ -47,8 +63,18 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
if (side != 0 && side != 1)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
tileEntity.structure.inventory.add(entityPlayer.getCurrentEquippedItem());
|
||||
tileEntity.structure.sortInventory();
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Place cells into block. 2 Dimensional Click Zone
|
||||
* Place cells into block. 2 Dimensional Click Zone.
|
||||
*
|
||||
* TODO: In the future.
|
||||
*/
|
||||
float xHit = 0;
|
||||
float yHit = yClick;
|
||||
|
@ -93,6 +119,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue