Merge pull request #664 from lehjr/experimental

experimental fix for https://github.com/MachineMuse/MachineMusePowersuits/issues/628
This commit is contained in:
Claire 2015-12-14 12:10:52 -08:00
commit db4d7d6c9e
4 changed files with 23 additions and 5 deletions

View file

@ -1,5 +1,6 @@
package net.machinemuse.powersuits.powermodule.tool;
import com.google.common.collect.Sets;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.moduletrigger.IBlockBreakingModule;
@ -10,19 +11,21 @@ import net.machinemuse.utils.ElectricItemUtils;
import net.machinemuse.utils.MuseCommonStrings;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.List;
import java.util.Set;
public class AxeModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule {
public static final String MODULE_AXE = "Axe";
public static final String AXE_ENERGY_CONSUMPTION = "Axe Energy Consumption";
public static final String AXE_HARVEST_SPEED = "Axe Harvest Speed";
public static final String AXE_SEARCH_RADIUS = "Axe Search Radius";
private static final Set HarvestableMaterials = Sets.newHashSet(new Material[]{Material.wood, Material.vine, Material.plants, Material.cactus, Material.gourd});
public AxeModule(List<IModularItem> validItems) {
super(validItems);
@ -62,7 +65,7 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
@Override
public boolean canHarvestBlock(ItemStack stack, Block block, int meta, EntityPlayer player) {
if (Items.iron_axe.canHarvestBlock(block, stack)) {
if (Items.iron_axe.canHarvestBlock(block, stack) || HarvestableMaterials.contains(block.getMaterial())) {
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, AXE_ENERGY_CONSUMPTION)) {
return true;
}

View file

@ -78,4 +78,4 @@ public class DiamondPickUpgradeModule extends PowerModuleBase implements IBlockB
event.newSpeed = (float) ModuleManager.computeModularProperty(event.entityPlayer.getCurrentEquippedItem(),
PickaxeModule.PICKAXE_HARVEST_SPEED);
}
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.List;
@ -22,6 +23,7 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
public static final String MODULE_PICKAXE = "Pickaxe";
public static final String PICKAXE_HARVEST_SPEED = "Pickaxe Harvest Speed";
public static final String PICKAXE_ENERGY_CONSUMPTION = "Pickaxe Energy Consumption";
public static final ItemStack ironShovel = new ItemStack(Items.iron_shovel);
public PickaxeModule(List<IModularItem> validItems) {
super(validItems);
@ -86,4 +88,4 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
}
return false;
}
}
}

View file

@ -1,5 +1,6 @@
package net.machinemuse.powersuits.powermodule.tool;
import com.google.common.collect.Sets;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.moduletrigger.IBlockBreakingModule;
@ -10,18 +11,30 @@ import net.machinemuse.utils.ElectricItemUtils;
import net.machinemuse.utils.MuseCommonStrings;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class ShovelModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule {
public static final String MODULE_SHOVEL = "Shovel";
public static final String SHOVEL_HARVEST_SPEED = "Shovel Harvest Speed";
public static final String SHOVEL_ENERGY_CONSUMPTION = "Shovel Energy Consumption";
public static final ItemStack ironShovel = new ItemStack(Items.iron_shovel);
public static final ItemStack diamond_shovel = new ItemStack(Items.diamond_shovel);
private static final Set HarvestableMaterials = Sets.newHashSet(new Material[]{Material.sand,
Material.ground,
Material.snow,
Material.craftedSnow,
Material.snow,
Material.grass,
Material.clay});
public ShovelModule(List<IModularItem> validItems) {
super(validItems);
@ -59,7 +72,7 @@ public class ShovelModule extends PowerModuleBase implements IBlockBreakingModul
@Override
public boolean canHarvestBlock(ItemStack stack, Block block, int meta, EntityPlayer player) {
if (Items.iron_shovel.canHarvestBlock(block, stack)) {
if ((Items.iron_shovel.canHarvestBlock(block, stack)) || HarvestableMaterials.contains(block.getMaterial())) {
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, SHOVEL_ENERGY_CONSUMPTION)) {
return true;
}