Removed treecapitation feature and fixed some energy consumption bugs

This commit is contained in:
MachineMuse 2013-09-24 10:54:26 -06:00
parent d889a2ba5e
commit fcaefe9355
4 changed files with 39 additions and 55 deletions

View file

@ -10,9 +10,7 @@ import net.machinemuse.utils.ElectricItemUtils;
import net.machinemuse.utils.MuseCommonStrings;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
@ -37,8 +35,9 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
addBaseProperty(AXE_HARVEST_SPEED, 8, "x");
addTradeoffProperty("Overclock", AXE_ENERGY_CONSUMPTION, 950);
addTradeoffProperty("Overclock", AXE_HARVEST_SPEED, 22);
addTradeoffProperty("Radius", AXE_ENERGY_CONSUMPTION, 1000);
addTradeoffProperty("Radius", AXE_SEARCH_RADIUS, 3);
// Removed until further research can be done!
// addTradeoffProperty("Radius", AXE_ENERGY_CONSUMPTION, 1000);
// addTradeoffProperty("Radius", AXE_SEARCH_RADIUS, 3);
}
@Override
@ -78,43 +77,11 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
boolean found = true;
double radius = ModuleManager.computeModularProperty(stack, AXE_SEARCH_RADIUS);
int minx = (int) Math.floor(x - radius);
int maxx = (int) Math.ceil(x + radius);
int minz = (int) Math.floor(z - radius);
int maxz = (int) Math.ceil(z + radius);
int newminx, newmaxx, newminz, newmaxz;
while (found) {
y++;
found = false;
newminx = (minx + maxx) / 2;
newmaxx = newminx;
newminz = (minz + maxz) / 2;
newmaxz = newminz;
for (int i = minx; i < maxx; i++) {
for (int j = minz; j < maxz; j++) {
int id = world.getBlockId(i, y, j);
if (Block.blocksList[id] instanceof BlockLog) {
found = true;
newminx = (int) Math.min(newminx, i - radius);
newmaxx = (int) Math.max(newmaxx, i + radius);
newminz = (int) Math.min(newminz, j - radius);
newmaxz = (int) Math.max(newmaxz, j + radius);
playerMP.theItemInWorldManager.tryHarvestBlock(i, y, j);
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, AXE_ENERGY_CONSUMPTION));
}
}
}
minx = newminx;
maxx = newmaxx;
minz = newminz;
maxz = newmaxz;
}
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, AXE_ENERGY_CONSUMPTION));
Block block = Block.blocksList[blockID];
int meta = world.getBlockMetadata(x, y, z);
if (canHarvestBlock(stack, block, meta, player)) {
double energyConsumption = ModuleManager.computeModularProperty(stack, AXE_ENERGY_CONSUMPTION);
ElectricItemUtils.drainPlayerEnergy(player, energyConsumption);
return true;
}
return false;

View file

@ -70,7 +70,8 @@ public class DiamondPickUpgradeModule extends PowerModuleBase implements IBlockB
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
Block block = Block.blocksList[blockID];
if (!PickaxeModule.ironPickaxe.canHarvestBlock(block)) {
int meta = world.getBlockMetadata(x,y,z);
if (canHarvestBlock(stack, block, meta, player) && !PickaxeModule.harvestCheck(stack, block, meta, player)) {
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, PickaxeModule.PICKAXE_ENERGY_CONSUMPTION));
return true;
}

View file

@ -63,6 +63,27 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
@Override
public boolean canHarvestBlock(ItemStack stack, Block block, int meta, EntityPlayer player) {
return harvestCheck(stack, block, meta, player);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
Block block = Block.blocksList[blockID];
int meta = world.getBlockMetadata(x,y,z);
if (canHarvestBlock(stack, block, meta, player)) {
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, PICKAXE_ENERGY_CONSUMPTION));
return true;
} else {
return false;
}
}
@Override
public void handleBreakSpeed(BreakSpeed event) {
event.newSpeed *= ModuleManager.computeModularProperty(event.entityPlayer.getCurrentEquippedItem(), PICKAXE_HARVEST_SPEED);
}
public static boolean harvestCheck(ItemStack stack, Block block, int meta, EntityPlayer player) {
if (ironPickaxe.canHarvestBlock(block) || ForgeHooks.canToolHarvestBlock(block, meta, ironPickaxe)) {
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, PICKAXE_ENERGY_CONSUMPTION)) {
return true;
@ -70,15 +91,4 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
}
return false;
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, PICKAXE_ENERGY_CONSUMPTION));
return true;
}
@Override
public void handleBreakSpeed(BreakSpeed event) {
event.newSpeed *= ModuleManager.computeModularProperty(event.entityPlayer.getCurrentEquippedItem(), PICKAXE_HARVEST_SPEED);
}
}

View file

@ -73,8 +73,14 @@ public class ShovelModule extends PowerModuleBase implements IBlockBreakingModul
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, SHOVEL_ENERGY_CONSUMPTION));
return true;
Block block = Block.blocksList[blockID];
int meta = world.getBlockMetadata(x,y,z);
if (canHarvestBlock(stack, block, meta, player)) {
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, SHOVEL_ENERGY_CONSUMPTION));
return true;
} else {
return false;
}
}
@Override