Added ability to left/right click capacitors into battery

This commit is contained in:
Calclavia 2013-08-05 13:20:10 -04:00
parent fd8806ffee
commit 19208dd01a
2 changed files with 57 additions and 30 deletions

View file

@ -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,12 +119,13 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
{
}
return true;
}
}
}
}
if(!world.isRemote)
if (!world.isRemote)
{
entityPlayer.openGui(ResonantInduction.INSTNACE, 0, world, x, y, z);
}
@ -146,13 +173,13 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
@Override
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if(!world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
if (!world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{
TileEntityBattery tileEntity = (TileEntityBattery)world.getBlockTileEntity(x, y, z);
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
if(!tileEntity.structure.isMultiblock)
if (!tileEntity.structure.isMultiblock)
{
for(ItemStack itemStack : tileEntity.structure.inventory)
for (ItemStack itemStack : tileEntity.structure.inventory)
{
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;

View file

@ -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);