moved module triggers into a separate package and added multimeter module + rightclickfirst trigger

This commit is contained in:
MachineMuse 2013-03-21 00:10:41 -06:00
parent 3fae2628cf
commit 9abeb0061d
30 changed files with 140 additions and 68 deletions

View file

@ -1,5 +0,0 @@
package net.machinemuse.api;
public interface IToggleableModule extends IPowerModule {
}

View file

@ -5,6 +5,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IRightClickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -58,7 +58,6 @@ public abstract class MuseCommonStrings {
public static final String MODULE_TINT = "Custom Colour Module";
public static final String MODULE_MELEE_ASSIST = "Melee Assist";
public static final String CITIZEN_JOE_STYLE = "Citizen Joe Style";
public static final String MODULE_MULTIMETER = "Multimeter";
public static final String MODULE_HAZMAT = "Radiation Shielding";
/**

View file

@ -6,6 +6,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import net.machinemuse.api.moduletrigger.IRightClickModule;
import net.machinemuse.general.MuseMathUtils;
import net.machinemuse.powersuits.item.ItemComponent;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,5 +1,6 @@
package net.machinemuse.api;
package net.machinemuse.api.moduletrigger;
import net.machinemuse.api.IPowerModule;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View file

@ -0,0 +1,13 @@
package net.machinemuse.api.moduletrigger;
import net.machinemuse.api.IPowerModule;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IRightClickFirstModule extends IPowerModule {
public boolean onItemUseFirst(
ItemStack itemStack, EntityPlayer player, World worldObj,
int x, int y, int z,
int side, float hitX, float hitY, float hitZ);
}

View file

@ -1,5 +1,6 @@
package net.machinemuse.api;
package net.machinemuse.api.moduletrigger;
import net.machinemuse.api.IPowerModule;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

View file

@ -0,0 +1,7 @@
package net.machinemuse.api.moduletrigger;
import net.machinemuse.api.IPowerModule;
public interface IToggleableModule extends IPowerModule {
}

View file

@ -6,8 +6,8 @@ import java.util.List;
import java.util.Set;
import net.machinemuse.api.IPowerModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.general.MuseRenderer;
import net.machinemuse.general.geometry.Colour;
import net.machinemuse.general.geometry.MusePoint2D;

View file

@ -9,8 +9,8 @@ import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModule;
import net.machinemuse.powersuits.powermodule.RightClickPowerModule;
import net.machinemuse.powersuits.powermodule.ToggleablePowerModule;
import net.machinemuse.powersuits.powermodule.modules.MultimeterModule;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
@ -154,18 +154,11 @@ public class ModCompatability {
}
// Add UE multimeter module
if (ModCompatability.isBasicComponentsLoaded()) {
IPowerModule module = new RightClickPowerModule(MuseCommonStrings.MODULE_MULTIMETER,
Arrays.asList((IModularItem) ModularPowersuits.powerTool), "redplate", MuseCommonStrings.CATEGORY_TOOL)
.setDescription("A tool addon that reads the Universal Electricity power generation in a wire.")
.addInstallCost(Config.copyAndResize(ItemComponent.wiring, 2)).addInstallCost(Config.copyAndResize(ItemComponent.solenoid, 1));
ModuleManager.addModule(module);
}
IPowerModule module = new MultimeterModule(Arrays.asList((IModularItem) ModularPowersuits.powerTool));
if (ModCompatability.isAtomicScienceLoaded()) {
IPowerModule module = new ToggleablePowerModule(MuseCommonStrings.MODULE_HAZMAT, Arrays.asList(
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_HAZMAT, Arrays.asList(
(IModularItem) ModularPowersuits.powerArmorHead, (IModularItem) ModularPowersuits.powerArmorTorso,
(IModularItem) ModularPowersuits.powerArmorLegs, (IModularItem) ModularPowersuits.powerArmorFeet), "greenstar",
MuseCommonStrings.CATEGORY_ARMOR)

View file

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IRightClickModule;
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.general.MuseStringUtils;
import net.machinemuse.general.geometry.Colour;
import net.machinemuse.general.gui.MuseIcon;
@ -368,25 +368,11 @@ public class ItemPowerTool extends ItemElectricTool implements IModularItem {
return MuseIcon.POWERTOOL;
}
// @Override
// public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY,
// float hitZ) {
//
// if (ModCompatability.isBasicComponentsLoaded() && MuseItemUtils.itemHasActiveModule(itemStack, MuseCommonStrings.MODULE_MULTIMETER)) {
// if (!worldObj.isRemote) {
// TileEntity tileEntity = worldObj.getBlockTileEntity(x, y, z);
// if (tileEntity instanceof IConductor) {
// IConductor wireTile = (IConductor) tileEntity;
// ElectricityPack getProduced = wireTile.getNetwork().getProduced();
// player.addChatMessage("Reading: " + ElectricInfo.getDisplay(getProduced.amperes, ElectricUnit.AMPERE) + ", "
// + ElectricInfo.getDisplay(getProduced.voltage, ElectricUnit.VOLTAGE) + ", "
// + ElectricInfo.getDisplay(getProduced.getWatts() * 20, ElectricUnit.WATT));
// return true;
// }
// }
// }
//
// return false;
// }
@Override
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY,
float hitZ) {
return false;
}
}

View file

@ -3,7 +3,7 @@ package net.machinemuse.powersuits.powermodule;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IRightClickModule;
import net.machinemuse.api.moduletrigger.IRightClickModule;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

View file

@ -3,7 +3,7 @@ package net.machinemuse.powersuits.powermodule;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
public class ToggleablePowerModule extends PowerModule implements IToggleableModule {

View file

@ -3,11 +3,11 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IRightClickModule;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MusePlayerUtils;
import net.machinemuse.api.electricity.ElectricItemUtils;
import net.machinemuse.api.moduletrigger.IRightClickModule;
import net.machinemuse.powersuits.common.Config;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,9 +3,9 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,10 +3,10 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -4,11 +4,11 @@ import java.util.Collection;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.electricity.ElectricItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -3,12 +3,12 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
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.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,12 +3,12 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
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.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,10 +3,10 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.event.MovementManager;
import net.machinemuse.powersuits.item.ItemComponent;

View file

@ -0,0 +1,73 @@
package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.moduletrigger.IRightClickFirstModule;
import net.machinemuse.powersuits.common.Config;
import net.machinemuse.powersuits.common.ModCompatability;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
import universalelectricity.core.electricity.ElectricityPack;
public class MultimeterModule extends PowerModuleBase implements IRightClickFirstModule {
public static final String MODULE_MULTIMETER = "Multimeter";
public MultimeterModule(String name, List<IModularItem> validItems) {
super(name, validItems); // Add UE multimeter module
addInstallCost(Config.copyAndResize(ItemComponent.wiring, 2)).addInstallCost(Config.copyAndResize(ItemComponent.solenoid, 1));
}
public MultimeterModule(List<IModularItem> validItems) {
super(validItems);
}
@Override
public String getCategory() {
return MuseCommonStrings.CATEGORY_TOOL;
}
@Override
public String getName() {
return MODULE_MULTIMETER;
}
@Override
public String getDescription() {
return "A tool addon that reads the Universal Electricity power generation in a wire.";
}
@Override
public String getTextureFile() {
return "redplate";
}
@Override
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY,
float hitZ) {
if (ModCompatability.isBasicComponentsLoaded()) {
if (!worldObj.isRemote) {
TileEntity tileEntity = worldObj.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IConductor) {
IConductor wireTile = (IConductor) tileEntity;
ElectricityPack getProduced = wireTile.getNetwork().getProduced();
player.addChatMessage("Reading: " + ElectricityDisplay.getDisplay(getProduced.amperes, ElectricUnit.AMPERE) + ", "
+ ElectricityDisplay.getDisplay(getProduced.voltage, ElectricUnit.VOLTAGE) + ", "
+ ElectricityDisplay.getDisplay(getProduced.getWatts() * 20, ElectricUnit.WATT));
return true;
}
}
}
return false;
}
}

View file

@ -4,11 +4,11 @@ import java.util.Collection;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.electricity.ElectricItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -3,10 +3,10 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,10 +3,10 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IRightClickModule;
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.entity.player.EntityPlayer;

View file

@ -3,12 +3,12 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IRightClickModule;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.MusePlayerUtils;
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.entity.player.EntityPlayer;

View file

@ -3,9 +3,9 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.minecraft.block.Block;

View file

@ -3,11 +3,11 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.electricity.ElectricItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.Config;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -3,10 +3,10 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
import net.machinemuse.api.MuseCommonStrings;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -3,12 +3,12 @@ package net.machinemuse.powersuits.powermodule.modules;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.IToggleableModule;
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.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.powersuits.common.PlayerInputMap;
import net.machinemuse.powersuits.item.ItemComponent;
import net.machinemuse.powersuits.powermodule.PowerModuleBase;

View file

@ -7,10 +7,10 @@ import java.util.EnumSet;
import java.util.List;
import net.machinemuse.api.IModularItem;
import net.machinemuse.api.IPlayerTickModule;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.MuseItemUtils;
import net.machinemuse.api.electricity.ElectricItemUtils;
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.general.MuseMathUtils;
import net.machinemuse.powersuits.common.MuseLogger;
import net.machinemuse.powersuits.common.PlayerInputMap;