Start work on bounding blocks

This commit is contained in:
Aidan Brady 2013-11-21 08:44:59 -05:00
parent 890de9446b
commit 44ca9d1067
4 changed files with 13 additions and 18 deletions

View file

@ -156,9 +156,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
@Override @Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{ {
boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); boolean place = true;
if(place) if(stack.getItemDamage() == MachineType.DIGITAL_MINER.meta)
{
}
if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{ {
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
@ -206,9 +211,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); ((ISustainedInventory)tileEntity).setInventory(getInventory(stack));
tileEntity.electricityStored = getEnergy(stack); tileEntity.electricityStored = getEnergy(stack);
return true;
} }
return place; return false;
} }
@Override @Override

View file

@ -102,14 +102,14 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{ {
ChargeUtils.discharge(27, this); ChargeUtils.discharge(27, this);
if(running && getEnergy() >= MekanismUtils.getEnergy(getSpeedMultiplier(), ENERGY_USAGE) && searcher.state == State.FINISHED && oresToMine.size() > 0) if(running && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE) && searcher.state == State.FINISHED && oresToMine.size() > 0)
{ {
if(delay > 0) if(delay > 0)
{ {
delay--; delay--;
} }
setEnergy(getEnergy()-MekanismUtils.getEnergy(getSpeedMultiplier(), ENERGY_USAGE)); setEnergy(getEnergy()-MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE));
if(delay == 0) if(delay == 0)
{ {

View file

@ -557,18 +557,6 @@ public final class MekanismUtils
return (int)(def * Math.pow(10, (-speedUpgrade/9.0))); return (int)(def * Math.pow(10, (-speedUpgrade/9.0)));
} }
/**
* Gets the energy required per tick for a machine via it's upgrades.
* @param speedUpgrade - number of speed upgrades
* @param energyUpgrade - number of energy upgrades
* @param def - the original, default energy required
* @return max energy per tick
*/
public static int getEnergyPerTick(int speedUpgrade, int energyUpgrade, int def)
{
return (int)(def * Math.pow(10, ((speedUpgrade-energyUpgrade)/9.0)));
}
/** /**
* Gets the energy required per tick for a machine via it's upgrades. * Gets the energy required per tick for a machine via it's upgrades.
* @param speedUpgrade - number of speed upgrades * @param speedUpgrade - number of speed upgrades

View file

@ -112,7 +112,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{ {
if(world.getBlockId(x, y, z) != Block.tallGrass.blockID && world.getBlockId(x, y, z) != 0) if(!Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z) && world.getBlockId(x, y, z) != 0)
place = false; place = false;
if(world.getBlockId(x, y, z) != 0) if(world.getBlockId(x, y, z) != 0)