Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated MPS api

  • Loading branch information...
commit 42c315c016bde079b57877174a0e75e3ba3a33d8 1 parent ae4dcbe
Mikee Franklin authored
4 build.xml
@@ -17,8 +17,8 @@
17 17 <property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft"/>
18 18
19 19 <property name="mc.version" value="1.5.2"/>
20   - <property name="forge.version" value="7.8.0.712"/>
21   - <property name="mod.version" value="0.1.9"/>
  20 + <property name="forge.version" value="7.8.1.738"/>
  21 + <property name="mod.version" value="0.1.10"/>
22 22 <property name="mod.name" value="OpenPeripheral"/>
23 23
24 24 <property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
37 src/net/machinemuse/api/ArmorTraits.scala
... ... @@ -0,0 +1,37 @@
  1 +package net.machinemuse.api
  2 +
  3 +import net.minecraft.entity.player.EntityPlayer
  4 +import net.minecraft.item.ItemStack
  5 +import net.machinemuse.utils.{ElectricItemUtils, MuseItemUtils}
  6 +import net.machinemuse.powersuits.powermodule.armor.{HazmatModule, ApiaristArmorModule}
  7 +import forestry.api.apiculture.IArmorApiarist
  8 +import net.minecraft.entity.EntityLiving
  9 +import atomicscience.api.poison.Poison
  10 +import atomicscience.api.IAntiPoisonArmor
  11 +
  12 +/**
  13 + * Author: MachineMuse (Claire Semple)
  14 + * Created: 6:54 AM, 4/28/13
  15 + */
  16 +trait ArmorTraits extends IModularItem
  17 +with ApiaristArmor
  18 +with RadiationArmor {
  19 +
  20 +}
  21 +
  22 +trait ApiaristArmor extends IArmorApiarist {
  23 + def protectPlayer(player: EntityPlayer, armor: ItemStack, cause: String, doProtect: Boolean): Boolean = {
  24 + if (MuseItemUtils.itemHasActiveModule(armor, ApiaristArmorModule.MODULE_APIARIST_ARMOR)) {
  25 + ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(armor, ApiaristArmorModule.APIARIST_ARMOR_ENERGY_CONSUMPTION))
  26 + true
  27 + } else false
  28 + }
  29 +}
  30 +
  31 +trait RadiationArmor extends IAntiPoisonArmor {
  32 + def isProtectedFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison): Boolean = {
  33 + MuseItemUtils.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
  34 + }
  35 +
  36 + def onProtectFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison) {}
  37 +}
10 src/net/machinemuse/api/IPowerModule.java
... ... @@ -1,14 +1,14 @@
1 1 package net.machinemuse.api;
2 2
3   -import java.util.List;
4   -import java.util.Map;
5   -
6 3 import net.minecraft.client.renderer.texture.IconRegister;
7 4 import net.minecraft.entity.player.EntityPlayer;
8 5 import net.minecraft.item.ItemStack;
9 6 import net.minecraft.nbt.NBTTagCompound;
10 7 import net.minecraft.util.Icon;
11 8
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
12 12 public interface IPowerModule {
13 13 public abstract List<ItemStack> getInstallCost();
14 14
@@ -22,7 +22,9 @@
22 22
23 23 public abstract boolean isValidForItem(ItemStack stack, EntityPlayer player);
24 24
25   - public abstract String getName();
  25 + public abstract String getDataName();
  26 +
  27 + public abstract String getLocalizedName();
26 28
27 29 public abstract double applyPropertyModifiers(NBTTagCompound itemTag, String propertyName, double propertyValue);
28 30
4 src/net/machinemuse/api/ModuleManager.java
@@ -36,7 +36,7 @@ public static IPowerModule getModule(String key) {
36 36
37 37 public static void addModule(IPowerModule module) {
38 38
39   - moduleMap.put(module.getName(), module);
  39 + moduleMap.put(module.getDataName(), module);
40 40 moduleList.add(module);
41 41 if (module instanceof IPlayerTickModule) {
42 42 playerTickModules.add((IPlayerTickModule) module);
@@ -56,7 +56,7 @@ public static double computeModularProperty(ItemStack stack, String propertyName
56 56 double propertyValue = 0;
57 57 NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
58 58 for (IPowerModule module : moduleList) {
59   - if (MuseItemUtils.itemHasActiveModule(stack, module.getName())) {
  59 + if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName())) {
60 60 propertyValue = module.applyPropertyModifiers(itemTag, propertyName, propertyValue);
61 61 }
62 62 }
94 src/net/machinemuse/api/OmniWrench.scala
... ... @@ -0,0 +1,94 @@
  1 +package net.machinemuse.api
  2 +
  3 +import mods.railcraft.api.core.items.IToolCrowbar
  4 +import net.machinemuse.utils.{ElectricItemUtils, MuseItemUtils}
  5 +import net.machinemuse.powersuits.powermodule.tool.{MFFSFieldTeleporterModule, OmniWrenchModule}
  6 +import net.minecraft.entity.player.EntityPlayer
  7 +import net.minecraft.item.ItemStack
  8 +import net.minecraft.entity.item.EntityMinecart
  9 +import buildcraft.api.tools.IToolWrench
  10 +import universalelectricity.prefab.implement.IToolConfigurator
  11 +import cpw.mods.fml.common.FMLCommonHandler
  12 +import mods.mffs.api.IFieldTeleporter
  13 +import powercrystals.minefactoryreloaded.api.IToolHammerAdvanced
  14 +
  15 +/**
  16 + * Author: MachineMuse (Claire Semple)
  17 + * Created: 5:06 PM, 29/04/13
  18 + */
  19 +trait OmniWrench
  20 + extends ModularWrench
  21 + with ModularCrowbar
  22 + with ModularHammer
  23 + with ForceFieldManipulator {
  24 +
  25 +}
  26 +
  27 +trait ModularCrowbar extends IToolCrowbar {
  28 + def canWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int): Boolean = {
  29 + return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
  30 + }
  31 +
  32 + def onWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int) {
  33 + player.swingItem
  34 + }
  35 +
  36 + def canLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
  37 + return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
  38 + }
  39 +
  40 + def onLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
  41 + player.swingItem
  42 + }
  43 +
  44 + def canBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
  45 + return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
  46 + }
  47 +
  48 + def onBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
  49 + player.swingItem
  50 + }
  51 +}
  52 +
  53 +
  54 +trait ModularWrench
  55 + extends IToolWrench // Buildcraft wrench
  56 + with IToolConfigurator {
  57 + // Universal Electricity wrench
  58 +
  59 + def canWrench(player: EntityPlayer, x: Int, y: Int, z: Int): Boolean = {
  60 + if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[IModularItem]) {
  61 + return MuseItemUtils.itemHasActiveModule(player.getCurrentEquippedItem, OmniWrenchModule.MODULE_OMNI_WRENCH)
  62 + }
  63 + return false
  64 + }
  65 +
  66 + def wrenchUsed(player: EntityPlayer, x: Int, y: Int, z: Int) {
  67 + }
  68 +}
  69 +
  70 +// MFR wrench
  71 +trait ModularHammer extends IToolHammerAdvanced {
  72 + def isActive(stack: ItemStack): Boolean = MuseItemUtils.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)
  73 +}
  74 +
  75 +trait ForceFieldManipulator extends IFieldTeleporter {
  76 + def canFieldTeleport(player: EntityPlayer, stack: ItemStack, teleportCost: Int): Boolean = {
  77 + if (MuseItemUtils.itemHasModule(stack, MFFSFieldTeleporterModule.MODULE_FIELD_TELEPORTER)) {
  78 + if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION)) {
  79 + return true
  80 + }
  81 + else if (FMLCommonHandler.instance.getEffectiveSide.isServer) {
  82 + player.sendChatToPlayer("[Field Security] Could not teleport through forcefield. 20,000J is required to teleport.")
  83 + }
  84 + }
  85 + return false
  86 + }
  87 +
  88 + def onFieldTeleportSuccess(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
  89 + ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION))
  90 + }
  91 +
  92 + def onFieldTeleportFailed(player: EntityPlayer, stack: ItemStack, teleportCost: Int) {
  93 + }
  94 +}
16 src/openperipheral/common/integration/mps/GlassesModule.java
@@ -14,6 +14,7 @@
14 14 import net.minecraft.item.ItemStack;
15 15 import net.minecraft.nbt.NBTTagCompound;
16 16 import net.minecraft.util.Icon;
  17 +import net.minecraft.util.StatCollector;
17 18 import openperipheral.OpenPeripheral;
18 19 import openperipheral.common.util.ReflectionHelper;
19 20
@@ -60,11 +61,6 @@ public boolean isValidForItem(ItemStack stack, EntityPlayer player) {
60 61 }
61 62
62 63 @Override
63   - public String getName() {
64   - return "OpenPeripheral Terminal Module";
65   - }
66   -
67   - @Override
68 64 public double applyPropertyModifiers(NBTTagCompound itemTag, String propertyName, double propertyValue) {
69 65 return propertyValue;
70 66 }
@@ -89,4 +85,14 @@ public boolean isAllowed() {
89 85 return true;
90 86 }
91 87
  88 + @Override
  89 + public String getDataName() {
  90 + return "Terminal Glasses Module";
  91 + }
  92 +
  93 + @Override
  94 + public String getLocalizedName() {
  95 + return StatCollector.translateToLocal("item.openperipheral.glasses.name");
  96 + }
  97 +
92 98 }

0 comments on commit 42c315c

Please sign in to comment.
Something went wrong with that request. Please try again.