Removed treecapitation feature and fixed some energy consumption bugs
This commit is contained in:
parent
d889a2ba5e
commit
fcaefe9355
4 changed files with 39 additions and 55 deletions
|
@ -10,9 +10,7 @@ import net.machinemuse.utils.ElectricItemUtils;
|
||||||
import net.machinemuse.utils.MuseCommonStrings;
|
import net.machinemuse.utils.MuseCommonStrings;
|
||||||
import net.machinemuse.utils.MuseItemUtils;
|
import net.machinemuse.utils.MuseItemUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLog;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
@ -37,8 +35,9 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
|
||||||
addBaseProperty(AXE_HARVEST_SPEED, 8, "x");
|
addBaseProperty(AXE_HARVEST_SPEED, 8, "x");
|
||||||
addTradeoffProperty("Overclock", AXE_ENERGY_CONSUMPTION, 950);
|
addTradeoffProperty("Overclock", AXE_ENERGY_CONSUMPTION, 950);
|
||||||
addTradeoffProperty("Overclock", AXE_HARVEST_SPEED, 22);
|
addTradeoffProperty("Overclock", AXE_HARVEST_SPEED, 22);
|
||||||
addTradeoffProperty("Radius", AXE_ENERGY_CONSUMPTION, 1000);
|
// Removed until further research can be done!
|
||||||
addTradeoffProperty("Radius", AXE_SEARCH_RADIUS, 3);
|
// addTradeoffProperty("Radius", AXE_ENERGY_CONSUMPTION, 1000);
|
||||||
|
// addTradeoffProperty("Radius", AXE_SEARCH_RADIUS, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,43 +77,11 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
|
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
|
||||||
if (player instanceof EntityPlayerMP) {
|
Block block = Block.blocksList[blockID];
|
||||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
boolean found = true;
|
if (canHarvestBlock(stack, block, meta, player)) {
|
||||||
double radius = ModuleManager.computeModularProperty(stack, AXE_SEARCH_RADIUS);
|
double energyConsumption = ModuleManager.computeModularProperty(stack, AXE_ENERGY_CONSUMPTION);
|
||||||
int minx = (int) Math.floor(x - radius);
|
ElectricItemUtils.drainPlayerEnergy(player, energyConsumption);
|
||||||
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));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -70,7 +70,8 @@ public class DiamondPickUpgradeModule extends PowerModuleBase implements IBlockB
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
|
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
|
||||||
Block block = Block.blocksList[blockID];
|
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));
|
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, PickaxeModule.PICKAXE_ENERGY_CONSUMPTION));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,27 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canHarvestBlock(ItemStack stack, Block block, int meta, EntityPlayer player) {
|
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 (ironPickaxe.canHarvestBlock(block) || ForgeHooks.canToolHarvestBlock(block, meta, ironPickaxe)) {
|
||||||
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, PICKAXE_ENERGY_CONSUMPTION)) {
|
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, PICKAXE_ENERGY_CONSUMPTION)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,15 +91,4 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
|
||||||
}
|
}
|
||||||
return false;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,14 @@ public class ShovelModule extends PowerModuleBase implements IBlockBreakingModul
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockDestroyed(ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
|
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));
|
Block block = Block.blocksList[blockID];
|
||||||
return true;
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue