From fecac008c6e52e77295172ea2c99f21e5a7f20ed Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Sun, 24 Mar 2013 07:15:36 -0600 Subject: [PATCH] added hoe module and tweaked recipes --- .../machinemuse/powersuits/common/Config.java | 2 + .../powersuits/common/ModularPowersuits.java | 10 +- .../powermodule/tool/HoeModule.java | 120 ++++++++++++++++++ .../powermodule/tool/ShearsModule.java | 2 +- 4 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 src/minecraft/net/machinemuse/powersuits/powermodule/tool/HoeModule.java diff --git a/src/minecraft/net/machinemuse/powersuits/common/Config.java b/src/minecraft/net/machinemuse/powersuits/common/Config.java index c27e6aa..f16c43d 100644 --- a/src/minecraft/net/machinemuse/powersuits/common/Config.java +++ b/src/minecraft/net/machinemuse/powersuits/common/Config.java @@ -35,6 +35,7 @@ import net.machinemuse.powersuits.powermodule.movement.SwimAssistModule; import net.machinemuse.powersuits.powermodule.tool.AquaAffinityModule; import net.machinemuse.powersuits.powermodule.tool.AxeModule; import net.machinemuse.powersuits.powermodule.tool.DiamondPickUpgradeModule; +import net.machinemuse.powersuits.powermodule.tool.HoeModule; import net.machinemuse.powersuits.powermodule.tool.PickaxeModule; import net.machinemuse.powersuits.powermodule.tool.ShearsModule; import net.machinemuse.powersuits.powermodule.tool.ShovelModule; @@ -209,6 +210,7 @@ public class Config { addModule(new PickaxeModule(TOOLONLY)); addModule(new ShovelModule(TOOLONLY)); addModule(new ShearsModule(TOOLONLY)); + addModule(new HoeModule(TOOLONLY)); // Weapon module = new ToggleablePowerModule(MuseCommonStrings.MODULE_MELEE_ASSIST, TOOLONLY, "toolfist", MuseCommonStrings.CATEGORY_WEAPON) diff --git a/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java b/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java index 7fd6ed4..076272e 100644 --- a/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java +++ b/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java @@ -49,10 +49,8 @@ import cpw.mods.fml.common.registry.EntityRegistry; // things that add new blocks/items, false for things like Rei's Minimap or // Inventory Tweaks. @NetworkMod(clientSideRequired = true, serverSideRequired = true, - clientPacketHandlerSpec = - @SidedPacketHandler(channels = { "mmmPowersuits" }, packetHandler = MusePacketHandler.class), - serverPacketHandlerSpec = - @SidedPacketHandler(channels = { "mmmPowersuits" }, packetHandler = MusePacketHandler.class)) + clientPacketHandlerSpec = @SidedPacketHandler(channels = { "mmmPowersuits" }, packetHandler = MusePacketHandler.class), + serverPacketHandlerSpec = @SidedPacketHandler(channels = { "mmmPowersuits" }, packetHandler = MusePacketHandler.class)) public class ModularPowersuits { public static ItemPowerArmorHelmet powerArmorHead; @@ -75,7 +73,9 @@ public class ModularPowersuits { * execute side-specific code like registering renderers (for the client) or * different tick handlers (for the server). */ - @SidedProxy(clientSide = "net.machinemuse.powersuits.client.ClientProxy", serverSide = "net.machinemuse.powersuits.common.CommonProxy") + @SidedProxy( + clientSide = "net.machinemuse.powersuits.client.ClientProxy", + serverSide = "net.machinemuse.powersuits.common.CommonProxy") public static CommonProxy proxy; /** diff --git a/src/minecraft/net/machinemuse/powersuits/powermodule/tool/HoeModule.java b/src/minecraft/net/machinemuse/powersuits/powermodule/tool/HoeModule.java new file mode 100644 index 0000000..72c150c --- /dev/null +++ b/src/minecraft/net/machinemuse/powersuits/powermodule/tool/HoeModule.java @@ -0,0 +1,120 @@ +package net.machinemuse.powersuits.powermodule.tool; + +import java.util.List; + +import net.machinemuse.api.IModularItem; +import net.machinemuse.api.IPowerModule; +import net.machinemuse.api.ModuleManager; +import net.machinemuse.api.MuseCommonStrings; +import net.machinemuse.api.MuseItemUtils; +import net.machinemuse.api.electricity.ElectricItemUtils; +import net.machinemuse.api.moduletrigger.IRightClickModule; +import net.machinemuse.powersuits.item.ItemComponent; +import net.machinemuse.powersuits.powermodule.PowerModuleBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.entity.player.UseHoeEvent; + +public class HoeModule extends PowerModuleBase implements IPowerModule, IRightClickModule { + public static final String HOE_ENERGY_CONSUMPTION = "Hoe Energy Consumption"; + + public HoeModule(List validItems) { + super(validItems); + addInstallCost(new ItemStack(Item.ingotIron, 2)); + addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.solenoid, 1)); + + addBaseProperty(HOE_ENERGY_CONSUMPTION, 50); + } + + @Override + public void onRightClick(EntityPlayer playerClicking, World world, ItemStack item) { + } + + @Override + public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if (!player.canPlayerEdit(x, y, z, side, itemStack)) + { + return; + } + else + { + UseHoeEvent event = new UseHoeEvent(player, itemStack, world, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + + if (event.getResult() == Result.ALLOW) + { + ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(itemStack, HOE_ENERGY_CONSUMPTION)); + return; + } + + int i1 = world.getBlockId(x, y, z); + int j1 = world.getBlockId(x, y + 1, z); + + if ((side == 0 || j1 != 0 || i1 != Block.grass.blockID) && i1 != Block.dirt.blockID) + { + return; + } + else + { + Block block = Block.tilledField; + world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), + block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if (world.isRemote) + { + return; + } + else + { + world.setBlock(x, y, z, block.blockID); + ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(itemStack, HOE_ENERGY_CONSUMPTION)); + return; + } + } + } + } + + @Override + public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, + float hitZ) { + return false; + } + + @Override + public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer player, int par4) { + } + + @Override + public String getCategory() { + return MuseCommonStrings.CATEGORY_TOOL; + } + + @Override + public String getName() { + return "Rototiller"; + } + + @Override + public String getDescription() { + return "An automated tilling addon to make it easy to till large swaths of land at once."; + } + + @Override + public String getTextureFile() { + return null; + } + + @Override + public Icon getIcon(ItemStack item) { + return Item.hoeGold.getIconFromDamage(0); + } +} diff --git a/src/minecraft/net/machinemuse/powersuits/powermodule/tool/ShearsModule.java b/src/minecraft/net/machinemuse/powersuits/powermodule/tool/ShearsModule.java index 35e3498..27d8e8c 100644 --- a/src/minecraft/net/machinemuse/powersuits/powermodule/tool/ShearsModule.java +++ b/src/minecraft/net/machinemuse/powersuits/powermodule/tool/ShearsModule.java @@ -37,7 +37,7 @@ public class ShearsModule extends PowerModuleBase implements IBlockBreakingModul public ShearsModule(List validItems) { super(validItems); - addInstallCost(new ItemStack(Item.ingotIron, 3)); + addInstallCost(new ItemStack(Item.ingotIron, 2)); addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.solenoid, 1)); addBaseProperty(SHEARING_ENERGY_CONSUMPTION, 50, "J"); addBaseProperty(SHEARING_HARVEST_SPEED, 8, "x");