Permalink
Browse files

updated MPS api

  • Loading branch information...
1 parent ae4dcbe commit 42c315c016bde079b57877174a0e75e3ba3a33d8 @mikeemoo committed Jul 1, 2013
View
@@ -17,8 +17,8 @@
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft"/>
<property name="mc.version" value="1.5.2"/>
- <property name="forge.version" value="7.8.0.712"/>
- <property name="mod.version" value="0.1.9"/>
+ <property name="forge.version" value="7.8.1.738"/>
+ <property name="mod.version" value="0.1.10"/>
<property name="mod.name" value="OpenPeripheral"/>
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
@@ -0,0 +1,37 @@
+package net.machinemuse.api
+
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.ItemStack
+import net.machinemuse.utils.{ElectricItemUtils, MuseItemUtils}
+import net.machinemuse.powersuits.powermodule.armor.{HazmatModule, ApiaristArmorModule}
+import forestry.api.apiculture.IArmorApiarist
+import net.minecraft.entity.EntityLiving
+import atomicscience.api.poison.Poison
+import atomicscience.api.IAntiPoisonArmor
+
+/**
+ * Author: MachineMuse (Claire Semple)
+ * Created: 6:54 AM, 4/28/13
+ */
+trait ArmorTraits extends IModularItem
+with ApiaristArmor
+with RadiationArmor {
+
+}
+
+trait ApiaristArmor extends IArmorApiarist {
+ def protectPlayer(player: EntityPlayer, armor: ItemStack, cause: String, doProtect: Boolean): Boolean = {
+ if (MuseItemUtils.itemHasActiveModule(armor, ApiaristArmorModule.MODULE_APIARIST_ARMOR)) {
+ ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(armor, ApiaristArmorModule.APIARIST_ARMOR_ENERGY_CONSUMPTION))
+ true
+ } else false
+ }
+}
+
+trait RadiationArmor extends IAntiPoisonArmor {
+ def isProtectedFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison): Boolean = {
+ MuseItemUtils.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
+ }
+
+ def onProtectFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison) {}
+}
@@ -1,14 +1,14 @@
package net.machinemuse.api;
-import java.util.List;
-import java.util.Map;
-
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
+import java.util.List;
+import java.util.Map;
+
public interface IPowerModule {
public abstract List<ItemStack> getInstallCost();
@@ -22,7 +22,9 @@
public abstract boolean isValidForItem(ItemStack stack, EntityPlayer player);
- public abstract String getName();
+ public abstract String getDataName();
+
+ public abstract String getLocalizedName();
public abstract double applyPropertyModifiers(NBTTagCompound itemTag, String propertyName, double propertyValue);
@@ -36,7 +36,7 @@ public static IPowerModule getModule(String key) {
public static void addModule(IPowerModule module) {
- moduleMap.put(module.getName(), module);
+ moduleMap.put(module.getDataName(), module);
moduleList.add(module);
if (module instanceof IPlayerTickModule) {
playerTickModules.add((IPlayerTickModule) module);
@@ -56,7 +56,7 @@ public static double computeModularProperty(ItemStack stack, String propertyName
double propertyValue = 0;
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
for (IPowerModule module : moduleList) {
- if (MuseItemUtils.itemHasActiveModule(stack, module.getName())) {
+ if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName())) {
propertyValue = module.applyPropertyModifiers(itemTag, propertyName, propertyValue);
}
}
@@ -0,0 +1,94 @@
+package net.machinemuse.api
+
+import mods.railcraft.api.core.items.IToolCrowbar
+import net.machinemuse.utils.{ElectricItemUtils, MuseItemUtils}
+import net.machinemuse.powersuits.powermodule.tool.{MFFSFieldTeleporterModule, OmniWrenchModule}
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.ItemStack
+import net.minecraft.entity.item.EntityMinecart
+import buildcraft.api.tools.IToolWrench
+import universalelectricity.prefab.implement.IToolConfigurator
+import cpw.mods.fml.common.FMLCommonHandler
+import mods.mffs.api.IFieldTeleporter
+import powercrystals.minefactoryreloaded.api.IToolHammerAdvanced
+
+/**
+ * Author: MachineMuse (Claire Semple)
+ * Created: 5:06 PM, 29/04/13
+ */
+trait OmniWrench
+ extends ModularWrench
+ with ModularCrowbar
+ with ModularHammer
+ with ForceFieldManipulator {
+
+}
+
+trait ModularCrowbar extends IToolCrowbar {
+ def canWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int): Boolean = {
+ return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
+ }
+
+ def onWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int) {
+ player.swingItem
+ }
+
+ def canLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
+ return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
+ }
+
+ def onLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
+ player.swingItem
+ }
+
+ def canBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
+ return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
+ }
+
+ def onBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
+ player.swingItem
+ }
+}
+
+
+trait ModularWrench
+ extends IToolWrench // Buildcraft wrench
+ with IToolConfigurator {
+ // Universal Electricity wrench
+
+ def canWrench(player: EntityPlayer, x: Int, y: Int, z: Int): Boolean = {
+ if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[IModularItem]) {
+ return MuseItemUtils.itemHasActiveModule(player.getCurrentEquippedItem, OmniWrenchModule.MODULE_OMNI_WRENCH)
+ }
+ return false
+ }
+
+ def wrenchUsed(player: EntityPlayer, x: Int, y: Int, z: Int) {
+ }
+}
+
+// MFR wrench
+trait ModularHammer extends IToolHammerAdvanced {
+ def isActive(stack: ItemStack): Boolean = MuseItemUtils.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)
+}
+
+trait ForceFieldManipulator extends IFieldTeleporter {
+ def canFieldTeleport(player: EntityPlayer, stack: ItemStack, teleportCost: Int): Boolean = {
+ if (MuseItemUtils.itemHasModule(stack, MFFSFieldTeleporterModule.MODULE_FIELD_TELEPORTER)) {
+ if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION)) {
+ return true
+ }
+ else if (FMLCommonHandler.instance.getEffectiveSide.isServer) {
+ player.sendChatToPlayer("[Field Security] Could not teleport through forcefield. 20,000J is required to teleport.")
+ }
+ }
+ return false
+ }
+
+ def onFieldTeleportSuccess(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
+ ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION))
+ }
+
+ def onFieldTeleportFailed(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
+ }
+}
@@ -14,6 +14,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
+import net.minecraft.util.StatCollector;
import openperipheral.OpenPeripheral;
import openperipheral.common.util.ReflectionHelper;
@@ -60,11 +61,6 @@ public boolean isValidForItem(ItemStack stack, EntityPlayer player) {
}
@Override
- public String getName() {
- return "OpenPeripheral Terminal Module";
- }
-
- @Override
public double applyPropertyModifiers(NBTTagCompound itemTag, String propertyName, double propertyValue) {
return propertyValue;
}
@@ -89,4 +85,14 @@ public boolean isAllowed() {
return true;
}
+ @Override
+ public String getDataName() {
+ return "Terminal Glasses Module";
+ }
+
+ @Override
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal("item.openperipheral.glasses.name");
+ }
+
}

0 comments on commit 42c315c

Please sign in to comment.