api refactoring and armor model test
This commit is contained in:
parent
36a204c781
commit
5a0b5c4930
28 changed files with 193 additions and 161 deletions
|
@ -8,6 +8,8 @@ import forestry.api.apiculture.IArmorApiarist
|
|||
import net.minecraft.entity.EntityLivingBase
|
||||
import atomicscience.api.IAntiPoisonArmor
|
||||
import atomicscience.api.poison.Poison
|
||||
import net.machinemuse.api.ModuleManager.itemHasActiveModule
|
||||
import net.machinemuse.api.ModuleManager
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -21,7 +23,7 @@ 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)) {
|
||||
if (ModuleManager.itemHasActiveModule(armor, ApiaristArmorModule.MODULE_APIARIST_ARMOR)) {
|
||||
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(armor, ApiaristArmorModule.APIARIST_ARMOR_ENERGY_CONSUMPTION))
|
||||
true
|
||||
} else false
|
||||
|
@ -30,7 +32,7 @@ trait ApiaristArmor extends IArmorApiarist {
|
|||
|
||||
trait RadiationArmor extends IAntiPoisonArmor {
|
||||
def isProtectedFromPoison(itemStack: ItemStack, EntityLivingBase: EntityLivingBase, `type`: Poison): Boolean = {
|
||||
MuseItemUtils.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
|
||||
ModuleManager.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
|
||||
}
|
||||
|
||||
def onProtectFromPoison(itemStack: ItemStack, EntityLivingBase: EntityLivingBase, `type`: Poison) {}
|
||||
|
|
|
@ -4,7 +4,9 @@ import net.machinemuse.api.moduletrigger.IBlockBreakingModule;
|
|||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||
import net.machinemuse.api.moduletrigger.IRightClickModule;
|
||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||
import net.machinemuse.utils.MuseItemTag;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -54,9 +56,9 @@ public class ModuleManager {
|
|||
|
||||
public static double computeModularProperty(ItemStack stack, String propertyName) {
|
||||
double propertyValue = 0;
|
||||
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||
NBTTagCompound itemTag = MuseItemTag.getMuseItemTag(stack);
|
||||
for (IPowerModule module : moduleList) {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName())) {
|
||||
if (itemHasActiveModule(stack, module.getDataName())) {
|
||||
propertyValue = module.applyPropertyModifiers(itemTag, propertyName, propertyValue);
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +76,75 @@ public class ModuleManager {
|
|||
public static List<IBlockBreakingModule> getBlockBreakingModules() {
|
||||
return blockBreakingModules;
|
||||
}
|
||||
|
||||
public static List<IPowerModule> getValidModulesForItem(EntityPlayer player, ItemStack stack) {
|
||||
List<IPowerModule> validModules = new ArrayList();
|
||||
for (IPowerModule module : getAllModules()) {
|
||||
if (module.isValidForItem(stack, player)) {
|
||||
validModules.add(module);
|
||||
}
|
||||
}
|
||||
return validModules;
|
||||
}
|
||||
|
||||
public static boolean tagHasModule(NBTTagCompound tag, String moduleName) {
|
||||
return tag.hasKey(moduleName);
|
||||
}
|
||||
|
||||
public static boolean isModuleOnline(NBTTagCompound itemTag, String moduleName) {
|
||||
if (tagHasModule(itemTag, moduleName) && !itemTag.getCompoundTag(moduleName).hasKey(MuseItemUtils.ONLINE)) {
|
||||
return true;
|
||||
} else if (tagHasModule(itemTag, moduleName) && itemTag.getCompoundTag(moduleName).getBoolean(MuseItemUtils.ONLINE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void toggleModule(NBTTagCompound itemTag, String name, boolean toggleval) {
|
||||
if (tagHasModule(itemTag, name)) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(name);
|
||||
moduleTag.setBoolean(MuseItemUtils.ONLINE, toggleval);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean itemHasModule(ItemStack stack, String moduleName) {
|
||||
return tagHasModule(MuseItemUtils.getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
public static void tagAddModule(NBTTagCompound tag, IPowerModule module) {
|
||||
tag.setCompoundTag(module.getDataName(), module.getNewTag());
|
||||
}
|
||||
|
||||
public static void itemAddModule(ItemStack stack, IPowerModule moduleType) {
|
||||
tagAddModule(MuseItemUtils.getMuseItemTag(stack), moduleType);
|
||||
}
|
||||
|
||||
public static boolean removeModule(NBTTagCompound tag, String moduleName) {
|
||||
if (tag.hasKey(moduleName)) {
|
||||
tag.removeTag(moduleName);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeModule(ItemStack stack, String moduleName) {
|
||||
return removeModule(MuseItemUtils.getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
public static boolean itemHasActiveModule(ItemStack itemStack, String moduleName) {
|
||||
IPowerModule module = getModule(moduleName);
|
||||
if (module == null || itemStack == null || !module.isAllowed() || !(itemStack.getItem() instanceof IModularItem)) {
|
||||
// playerEntity.sendChatToPlayer("Server has disallowed this module. Sorry!");
|
||||
return false;
|
||||
}
|
||||
if (module instanceof IRightClickModule) {
|
||||
// MuseLogger.logDebug("Module: " + moduleName + " vs Mode: " +
|
||||
// MuseItemUtils.getActiveMode(itemStack));
|
||||
|
||||
return moduleName.equals(MuseItemUtils.getActiveMode(itemStack));
|
||||
} else {
|
||||
return isModuleOnline(MuseItemUtils.getMuseItemTag(itemStack), moduleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import cpw.mods.fml.common.FMLCommonHandler
|
|||
import mods.mffs.api.IFieldTeleporter
|
||||
import powercrystals.minefactoryreloaded.api.IToolHammerAdvanced
|
||||
import net.minecraft.util.ChatMessageComponent
|
||||
import net.machinemuse.api.ModuleManager.{itemHasActiveModule, itemHasModule}
|
||||
import net.machinemuse.api.ModuleManager
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -27,7 +29,7 @@ trait OmniWrench
|
|||
|
||||
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)
|
||||
return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
}
|
||||
|
||||
def onWhack(player: EntityPlayer, crowbar: ItemStack, x: Int, y: Int, z: Int) {
|
||||
|
@ -35,7 +37,7 @@ trait ModularCrowbar extends IToolCrowbar {
|
|||
}
|
||||
|
||||
def canLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
|
||||
return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
}
|
||||
|
||||
def onLink(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
|
||||
|
@ -43,7 +45,7 @@ trait ModularCrowbar extends IToolCrowbar {
|
|||
}
|
||||
|
||||
def canBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart): Boolean = {
|
||||
return MuseItemUtils.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
return ModuleManager.itemHasActiveModule(crowbar, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
}
|
||||
|
||||
def onBoost(player: EntityPlayer, crowbar: ItemStack, cart: EntityMinecart) {
|
||||
|
@ -59,7 +61,7 @@ trait ModularWrench
|
|||
|
||||
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 ModuleManager.itemHasActiveModule(player.getCurrentEquippedItem, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -70,12 +72,12 @@ trait ModularWrench
|
|||
|
||||
// MFR wrench
|
||||
trait ModularHammer extends IToolHammerAdvanced {
|
||||
def isActive(stack: ItemStack): Boolean = MuseItemUtils.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)
|
||||
def isActive(stack: ItemStack): Boolean = ModuleManager.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 (ModuleManager.itemHasModule(stack, MFFSFieldTeleporterModule.MODULE_FIELD_TELEPORTER)) {
|
||||
if (ElectricItemUtils.getPlayerEnergy(player) > ModuleManager.computeModularProperty(stack, MFFSFieldTeleporterModule.FIELD_TELEPORTER_ENERGY_CONSUMPTION)) {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cpw.mods.fml.common.network.Player;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.general.geometry.MusePoint2D;
|
||||
import net.machinemuse.general.gui.clickable.ClickableButton;
|
||||
|
@ -64,7 +65,7 @@ public class InstallSalvageFrame extends ScrollableFrame {
|
|||
IPowerModule module = targetModule.getSelectedModule().getModule();
|
||||
List<ItemStack> itemsToCheck = module.getInstallCost();
|
||||
double yoffset;
|
||||
if (!MuseItemUtils.itemHasModule(stack, module.getDataName())) {
|
||||
if (!ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
yoffset = border.top() + 4;
|
||||
} else {
|
||||
yoffset = border.bottom() - 20;
|
||||
|
@ -101,7 +102,7 @@ public class InstallSalvageFrame extends ScrollableFrame {
|
|||
IPowerModule module = targetModule.getSelectedModule().getModule();
|
||||
List<ItemStack> itemsToDraw = module.getInstallCost();
|
||||
double yoffset;
|
||||
if (!MuseItemUtils.itemHasModule(stack, module.getDataName())) {
|
||||
if (!ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
yoffset = border.top() + 4;
|
||||
} else {
|
||||
yoffset = border.bottom() - 20;
|
||||
|
@ -120,7 +121,7 @@ public class InstallSalvageFrame extends ScrollableFrame {
|
|||
private void drawButtons() {
|
||||
ItemStack stack = targetItem.getSelectedItem().getItem();
|
||||
IPowerModule module = targetModule.getSelectedModule().getModule();
|
||||
if (!MuseItemUtils.itemHasModule(stack, module.getDataName())) {
|
||||
if (!ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
|
||||
installButton.setEnabled(player.capabilities.isCreativeMode || MuseItemUtils.hasInInventory(
|
||||
module.getInstallCost(), player.inventory));
|
||||
|
@ -138,7 +139,7 @@ public class InstallSalvageFrame extends ScrollableFrame {
|
|||
ItemStack stack = selItem.getItem();
|
||||
IPowerModule module = selModule.getModule();
|
||||
|
||||
if (!MuseItemUtils.itemHasModule(stack, module.getDataName())) {
|
||||
if (!ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
if (installButton.hitBox(x, y)) {
|
||||
doInstall();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.machinemuse.general.gui.frame;
|
||||
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.general.geometry.MusePoint2D;
|
||||
import net.machinemuse.general.geometry.MuseRect;
|
||||
|
@ -9,7 +10,6 @@ import net.machinemuse.general.gui.clickable.ClickableItem;
|
|||
import net.machinemuse.general.gui.clickable.ClickableModule;
|
||||
import net.machinemuse.general.sound.Musique;
|
||||
import net.machinemuse.general.sound.SoundLoader;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.machinemuse.utils.render.MuseRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -97,14 +97,14 @@ public class ModuleSelectionFrame extends ScrollableFrame {
|
|||
moduleButtons = new ArrayList<ClickableModule>();
|
||||
categories = new HashMap<String, ModuleSelectionSubFrame>();
|
||||
|
||||
List<IPowerModule> workingModules = MuseItemUtils.getValidModulesForItem(null, selectedItem.getItem());
|
||||
List<IPowerModule> workingModules = ModuleManager.getValidModulesForItem(null, selectedItem.getItem());
|
||||
|
||||
// Prune the list of disallowed modules, if not installed on this
|
||||
// item.
|
||||
for (Iterator<IPowerModule> it = workingModules.iterator(); it.hasNext(); ) {
|
||||
IPowerModule module = it.next();
|
||||
if (module.isAllowed() == false &&
|
||||
MuseItemUtils.itemHasModule(selectedItem.getItem(), module.getDataName()) == false) {
|
||||
ModuleManager.itemHasModule(selectedItem.getItem(), module.getDataName()) == false) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class ModuleSelectionFrame extends ScrollableFrame {
|
|||
// If a disallowed module made it to the list, indicate
|
||||
// it as disallowed
|
||||
moduleClickable.setAllowed(false);
|
||||
} else if (MuseItemUtils.itemHasModule(selectedItem.getItem(), module.getDataName())) {
|
||||
} else if (ModuleManager.itemHasModule(selectedItem.getItem(), module.getDataName())) {
|
||||
moduleClickable.setInstalled(true);
|
||||
}
|
||||
if (moduleClickable.getModule().equals(this.prevSelection)) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.machinemuse.general.gui.frame;
|
|||
import cpw.mods.fml.common.network.Player;
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.IPropertyModifier;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.general.geometry.MusePoint2D;
|
||||
import net.machinemuse.general.gui.clickable.ClickableItem;
|
||||
|
@ -48,7 +49,7 @@ public class ModuleTweakFrame extends ScrollableFrame {
|
|||
if (itemTarget.getSelectedItem() != null && moduleTarget.getSelectedModule() != null) {
|
||||
ItemStack stack = itemTarget.getSelectedItem().getItem();
|
||||
IPowerModule module = moduleTarget.getSelectedModule().getModule();
|
||||
if (MuseItemUtils.itemHasModule(itemTarget.getSelectedItem().getItem(), moduleTarget.getSelectedModule().getModule().getDataName())) {
|
||||
if (ModuleManager.itemHasModule(itemTarget.getSelectedItem().getItem(), moduleTarget.getSelectedModule().getModule().getDataName())) {
|
||||
loadTweaks(stack, module);
|
||||
} else {
|
||||
sliders = null;
|
||||
|
|
|
@ -9,11 +9,12 @@ public class ArmorModelInstance {
|
|||
|
||||
public static ArmorModel getInstance() {
|
||||
if (instance == null) {
|
||||
try {
|
||||
instance = new SMovingArmorModel();
|
||||
} catch (Throwable e) {
|
||||
instance = new VanillaArmorModel();
|
||||
}
|
||||
// try {
|
||||
// instance = new SMovingArmorModel();
|
||||
// } catch (Throwable e) {
|
||||
// instance = new VanillaArmorModel();
|
||||
// }
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
package net.machinemuse.powersuits.client.render.item;
|
||||
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.general.MuseLogger;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.powersuits.client.render.entity.RenderPlasmaBolt;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.powermodule.weapon.PlasmaCannonModule;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.machinemuse.utils.render.MuseRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
@ -490,7 +490,7 @@ public class ToolModel extends ModelBase {
|
|||
|
||||
public void setPoseForPlayer(EntityPlayer player, ItemStack itemStack) {
|
||||
if (player.isUsingItem() && player.getCurrentEquippedItem() != null
|
||||
&& MuseItemUtils.itemHasActiveModule(player.getCurrentEquippedItem(), PlasmaCannonModule.MODULE_PLASMA_CANNON)) {
|
||||
&& ModuleManager.itemHasActiveModule(player.getCurrentEquippedItem(), PlasmaCannonModule.MODULE_PLASMA_CANNON)) {
|
||||
setPose(1.5f, -1, 1.5f, -1, 1.5f, -1);
|
||||
this.boltSize = player.getItemInUseDuration() > 50 ? 50 : player.getItemInUseDuration();
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.machinemuse.api.IModularItem;
|
|||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.api.moduletrigger.IBlockBreakingModule;
|
||||
import net.machinemuse.powersuits.item.ItemPowerFist;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -31,7 +30,7 @@ public class HarvestEventHandler {
|
|||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||
for (IBlockBreakingModule module : ModuleManager.getBlockBreakingModules()) {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName()) && module.canHarvestBlock(stack, block, meta, player)) {
|
||||
if (ModuleManager.itemHasActiveModule(stack, module.getDataName()) && module.canHarvestBlock(stack, block, meta, player)) {
|
||||
if (event.newSpeed == 0) {
|
||||
event.newSpeed = 1;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.machinemuse.powersuits.item.ItemPowerArmor;
|
|||
import net.machinemuse.powersuits.powermodule.movement.JumpAssistModule;
|
||||
import net.machinemuse.powersuits.powermodule.movement.ShockAbsorberModule;
|
||||
import net.machinemuse.utils.ElectricItemUtils;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
@ -39,7 +38,7 @@ public class MovementManager {
|
|||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack stack = player.getCurrentArmor(1);
|
||||
if (stack != null && stack.getItem() instanceof ItemPowerArmor
|
||||
&& MuseItemUtils.itemHasActiveModule(stack, JumpAssistModule.MODULE_JUMP_ASSIST)) {
|
||||
&& ModuleManager.itemHasActiveModule(stack, JumpAssistModule.MODULE_JUMP_ASSIST)) {
|
||||
double jumpAssist = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_MULTIPLIER) * 2;
|
||||
double drain = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_ENERGY_CONSUMPTION);
|
||||
double avail = ElectricItemUtils.getPlayerEnergy(player);
|
||||
|
@ -66,7 +65,7 @@ public class MovementManager {
|
|||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
if (boots != null) {
|
||||
if (MuseItemUtils.itemHasActiveModule(boots, ShockAbsorberModule.MODULE_SHOCK_ABSORBER) && event.distance > 3) {
|
||||
if (ModuleManager.itemHasActiveModule(boots, ShockAbsorberModule.MODULE_SHOCK_ABSORBER) && event.distance > 3) {
|
||||
double distanceAbsorb = event.distance * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_MULTIPLIER);
|
||||
Musique.playerSound(player, SoundLoader.SOUND_GUI_INSTALL, (float) (distanceAbsorb), 2, false);
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ package net.machinemuse.powersuits.event;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.powermodule.movement.FlightControlModule;
|
||||
import net.machinemuse.powersuits.powermodule.movement.GliderModule;
|
||||
import net.machinemuse.powersuits.powermodule.movement.JetBootsModule;
|
||||
import net.machinemuse.powersuits.powermodule.movement.JetPackModule;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.machinemuse.utils.render.GlowBuffer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
@ -45,10 +45,10 @@ public class RenderEventHandler {
|
|||
}
|
||||
|
||||
private boolean playerHasFlightOn(EntityPlayer player) {
|
||||
return MuseItemUtils.itemHasActiveModule(player.getCurrentArmor(2), JetPackModule.MODULE_JETPACK)
|
||||
|| MuseItemUtils.itemHasActiveModule(player.getCurrentArmor(2), GliderModule.MODULE_GLIDER)
|
||||
|| MuseItemUtils.itemHasActiveModule(player.getCurrentArmor(0), JetBootsModule.MODULE_JETBOOTS)
|
||||
|| MuseItemUtils.itemHasActiveModule(player.getCurrentArmor(3), FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
return ModuleManager.itemHasActiveModule(player.getCurrentArmor(2), JetPackModule.MODULE_JETPACK)
|
||||
|| ModuleManager.itemHasActiveModule(player.getCurrentArmor(2), GliderModule.MODULE_GLIDER)
|
||||
|| ModuleManager.itemHasActiveModule(player.getCurrentArmor(0), JetBootsModule.MODULE_JETBOOTS)
|
||||
|| ModuleManager.itemHasActiveModule(player.getCurrentArmor(3), FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
|
|
|
@ -3,7 +3,7 @@ package net.machinemuse.powersuits.event;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -40,7 +40,7 @@ public class ThaumRenderEventHandler {
|
|||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null && player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof IModularItem) {
|
||||
ItemStack stack = player.inventory.armorItemInSlot(3);
|
||||
if (MuseItemUtils.itemHasModule(stack, "Aurameter")) {
|
||||
if (ModuleManager.itemHasModule(stack, "Aurameter")) {
|
||||
renderAuraNodes(event, event.partialTicks, player, Minecraft.getMinecraft().theWorld.getWorldTime());
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ThaumRenderEventHandler {
|
|||
|
||||
if (player != null && player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof IModularItem) {
|
||||
ItemStack stack = player.inventory.armorItemInSlot(3);
|
||||
if (MuseItemUtils.itemHasModule(stack, "Aurameter")) {
|
||||
if (ModuleManager.itemHasModule(stack, "Aurameter")) {
|
||||
drawTags(event.target, player.worldObj, event.partialTicks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ import net.machinemuse.general.geometry.Colour
|
|||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.client.model.ModelBiped
|
||||
import net.machinemuse.powersuits.client.render.item.ArmorModel
|
||||
import net.machinemuse.api.{ArmorTraits, ModuleManager, IModularItem}
|
||||
import net.machinemuse.api.{ModuleManager, ArmorTraits, IModularItem}
|
||||
import net.machinemuse.api.ModuleManager.{itemHasActiveModule, tagHasModule}
|
||||
|
||||
/**
|
||||
* Describes the 4 different modular armor pieces - head, torso, legs, feet.
|
||||
|
@ -71,10 +72,10 @@ abstract class ItemPowerArmor(id: Int, renderIndex: Int, armorType: Int)
|
|||
entity match {
|
||||
case player: EntityPlayer =>
|
||||
Option(player.getCurrentArmor(2)).map(chest =>
|
||||
if (MuseItemUtils.itemHasActiveModule(chest, InvisibilityModule.MODULE_ACTIVE_CAMOUFLAGE)) return null)
|
||||
if (ModuleManager.itemHasActiveModule(chest, InvisibilityModule.MODULE_ACTIVE_CAMOUFLAGE)) return null)
|
||||
case _ =>
|
||||
}
|
||||
if (MuseItemUtils.itemHasActiveModule(itemstack, TransparentArmorModule.MODULE_TRANSPARENT_ARMOR)) {
|
||||
if (ModuleManager.itemHasActiveModule(itemstack, TransparentArmorModule.MODULE_TRANSPARENT_ARMOR)) {
|
||||
return null
|
||||
}
|
||||
model.renderSpec = MuseItemUtils.getMuseRenderTag(itemstack, armorSlot)
|
||||
|
@ -91,7 +92,7 @@ abstract class ItemPowerArmor(id: Int, renderIndex: Int, armorType: Int)
|
|||
*/
|
||||
override def hasColor(stack: ItemStack): Boolean = {
|
||||
val itemTag: NBTTagCompound = MuseItemUtils.getMuseItemTag(stack)
|
||||
return MuseItemUtils.tagHasModule(itemTag, TintModule.RED_TINT) || MuseItemUtils.tagHasModule(itemTag, TintModule.GREEN_TINT) || MuseItemUtils.tagHasModule(itemTag, TintModule.BLUE_TINT)
|
||||
return ModuleManager.tagHasModule(itemTag, TintModule.RED_TINT) || ModuleManager.tagHasModule(itemTag, TintModule.GREEN_TINT) || ModuleManager.tagHasModule(itemTag, TintModule.BLUE_TINT)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,8 @@ import cpw.mods.fml.relauncher.SideOnly
|
|||
import atomicscience.api.poison.Poison
|
||||
import net.machinemuse.utils.{MuseItemUtils}
|
||||
import net.machinemuse.utils.render.MuseRenderer
|
||||
import net.machinemuse.api.ModuleManager.itemHasActiveModule
|
||||
import net.machinemuse.api.ModuleManager
|
||||
|
||||
class ItemPowerArmorHelmet(id: Int) extends ItemPowerArmor(id, 0, 0) with IBreathableArmor {
|
||||
val iconpath = MuseRenderer.ICON_PREFIX + "armorhead"
|
||||
|
@ -25,7 +27,7 @@ class ItemPowerArmorHelmet(id: Int) extends ItemPowerArmor(id, 0, 0) with IBreat
|
|||
def handleGearType(gearType: EnumGearType): Boolean = gearType eq EnumGearType.HELMET
|
||||
|
||||
def canBreathe(helm: ItemStack, player: EntityPlayer, gearType: EnumGearType): Boolean = {
|
||||
return MuseItemUtils.itemHasActiveModule(helm, AirtightSealModule.AIRTIGHT_SEAL_MODULE)
|
||||
return ModuleManager.itemHasActiveModule(helm, AirtightSealModule.AIRTIGHT_SEAL_MODULE)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -3,7 +3,7 @@ package net.machinemuse.powersuits.item
|
|||
import cpw.mods.fml.relauncher.Side
|
||||
import cpw.mods.fml.relauncher.SideOnly
|
||||
import forestry.api.arboriculture.IToolGrafter
|
||||
import net.machinemuse.api.{OmniWrench, IModularItem, IPowerModule, ModuleManager}
|
||||
import net.machinemuse.api._
|
||||
import net.machinemuse.api.moduletrigger.IRightClickModule
|
||||
import net.machinemuse.general.gui.MuseIcon
|
||||
import net.machinemuse.powersuits.common.Config
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.util.DamageSource
|
||||
import net.minecraft.util.Vec3
|
||||
import net.minecraft.world.World
|
||||
import net.machinemuse.api.ModuleManager.itemHasActiveModule
|
||||
|
||||
/**
|
||||
* Describes the modular power tool.
|
||||
|
@ -60,11 +61,11 @@ with OmniWrench {
|
|||
* entry argument beside stack. They just raise the damage on the stack.
|
||||
*/
|
||||
override def hitEntity(stack: ItemStack, entityBeingHit: EntityLivingBase, entityDoingHitting: EntityLivingBase): Boolean = {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)) {
|
||||
if (ModuleManager.itemHasActiveModule(stack, OmniWrenchModule.MODULE_OMNI_WRENCH)) {
|
||||
entityBeingHit.rotationYaw += 90.0F;
|
||||
entityBeingHit.rotationYaw %= 360.0F;
|
||||
}
|
||||
if (entityDoingHitting.isInstanceOf[EntityPlayer] && MuseItemUtils.itemHasActiveModule(stack, MeleeAssistModule.MODULE_MELEE_ASSIST)) {
|
||||
if (entityDoingHitting.isInstanceOf[EntityPlayer] && ModuleManager.itemHasActiveModule(stack, MeleeAssistModule.MODULE_MELEE_ASSIST)) {
|
||||
val player: EntityPlayer = entityDoingHitting.asInstanceOf[EntityPlayer]
|
||||
val drain: Double = ModuleManager.computeModularProperty(stack, MeleeAssistModule.PUNCH_ENERGY)
|
||||
if (ElectricItemUtils.getPlayerEnergy(player) > drain) {
|
||||
|
@ -91,7 +92,7 @@ with OmniWrench {
|
|||
case player: EntityPlayer =>
|
||||
import scala.collection.JavaConversions._
|
||||
for (module <- ModuleManager.getBlockBreakingModules) {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName)) {
|
||||
if (ModuleManager.itemHasActiveModule(stack, module.getDataName)) {
|
||||
if (module.onBlockDestroyed(stack, world, blockID, x, y, z, player)) {
|
||||
return true
|
||||
}
|
||||
|
@ -149,7 +150,7 @@ with OmniWrench {
|
|||
override def onItemRightClick(itemStack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
import scala.collection.JavaConversions._
|
||||
for (module <- ModuleManager.getRightClickModules) {
|
||||
if (module.isValidForItem(itemStack, player) && MuseItemUtils.itemHasActiveModule(itemStack, module.getDataName)) {
|
||||
if (module.isValidForItem(itemStack, player) && ModuleManager.itemHasActiveModule(itemStack, module.getDataName)) {
|
||||
module.onRightClick(player, world, itemStack)
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +200,7 @@ with OmniWrench {
|
|||
}
|
||||
|
||||
def getSaplingModifier(stack: ItemStack, world: World, player: EntityPlayer, x: Int, y: Int, z: Int): Float = {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, GrafterModule.MODULE_GRAFTER)) {
|
||||
if (ModuleManager.itemHasActiveModule(stack, GrafterModule.MODULE_GRAFTER)) {
|
||||
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(stack, GrafterModule.GRAFTER_ENERGY_CONSUMPTION))
|
||||
MuseHeatUtils.heatPlayer(player, ModuleManager.computeModularProperty(stack, GrafterModule.GRAFTER_HEAT_GENERATION))
|
||||
return 100F
|
||||
|
@ -213,7 +214,7 @@ with OmniWrench {
|
|||
}
|
||||
import scala.collection.JavaConversions._
|
||||
for (module <- ModuleManager.getBlockBreakingModules) {
|
||||
if (MuseItemUtils.itemHasActiveModule(stack, module.getDataName) && module.canHarvestBlock(stack, block, meta, player)) {
|
||||
if (ModuleManager.itemHasActiveModule(stack, module.getDataName) && module.canHarvestBlock(stack, block, meta, player)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.machinemuse.powersuits.powermodule.misc.{CosmeticGlowModule, TintModu
|
|||
import net.machinemuse.utils.MuseMathUtils._
|
||||
import net.machinemuse.api.electricity.MuseElectricItem
|
||||
import net.machinemuse.api.{ModuleManager, IModularItem}
|
||||
import net.machinemuse.api.ModuleManager.itemHasActiveModule
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -21,7 +22,7 @@ trait ModularItemBase extends Item with IModularItem with MuseElectricItem {
|
|||
}
|
||||
|
||||
def getGlowFromItemStack(stack: ItemStack): Colour = {
|
||||
if (!MuseItemUtils.itemHasActiveModule(stack, CosmeticGlowModule.MODULE_GLOW)) {
|
||||
if (!ModuleManager.itemHasActiveModule(stack, CosmeticGlowModule.MODULE_GLOW)) {
|
||||
return Colour.LIGHTBLUE
|
||||
}
|
||||
val computedred: Double = ModuleManager.computeModularProperty(stack, CosmeticGlowModule.RED_GLOW)
|
||||
|
@ -32,7 +33,7 @@ trait ModularItemBase extends Item with IModularItem with MuseElectricItem {
|
|||
}
|
||||
|
||||
def getColorFromItemStack(stack: ItemStack): Colour = {
|
||||
if (!MuseItemUtils.itemHasActiveModule(stack, TintModule.MODULE_TINT)) {
|
||||
if (!ModuleManager.itemHasActiveModule(stack, TintModule.MODULE_TINT)) {
|
||||
return Colour.WHITE
|
||||
}
|
||||
val computedred: Double = ModuleManager.computeModularProperty(stack, TintModule.RED_TINT)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.machinemuse.general.MuseLogger
|
||||
import net.minecraft.util.ChatMessageComponent
|
||||
import net.machinemuse.api.ModuleManager.{itemAddModule, itemHasModule}
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server decides whether it is a valid upgrade or not and replies with an associated
|
||||
|
@ -57,8 +58,8 @@ class MusePacketInstallModuleRequest(player: Player, itemSlot: Int, moduleName:
|
|||
return
|
||||
}
|
||||
val cost: List[ItemStack] = moduleType.getInstallCost
|
||||
if ((!MuseItemUtils.itemHasModule(stack, moduleName) && MuseItemUtils.hasInInventory(cost, playerEntity.inventory)) || playerEntity.capabilities.isCreativeMode) {
|
||||
MuseItemUtils.itemAddModule(stack, moduleType)
|
||||
if ((!ModuleManager.itemHasModule(stack, moduleName) && MuseItemUtils.hasInInventory(cost, playerEntity.inventory)) || playerEntity.capabilities.isCreativeMode) {
|
||||
ModuleManager.itemAddModule(stack, moduleType)
|
||||
import scala.collection.JavaConversions._
|
||||
for (stackInCost <- cost) {
|
||||
ElectricItemUtils.givePlayerEnergy(playerEntity, ElectricItemUtils.jouleValueOfComponent(stackInCost))
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.HashSet
|
|||
import java.util.List
|
||||
import java.util.Set
|
||||
import scala.Predef._
|
||||
import net.machinemuse.api.ModuleManager.{removeModule, itemHasModule}
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server
|
||||
|
@ -50,9 +51,9 @@ class MusePacketSalvageModuleRequest(player: Player, itemSlot: Int, moduleName:
|
|||
val stack = playerEntity.inventory.getStackInSlot(itemSlot)
|
||||
val moduleType: IPowerModule = ModuleManager.getModule(moduleName)
|
||||
val refund: List[ItemStack] = moduleType.getInstallCost
|
||||
if (MuseItemUtils.itemHasModule(stack, moduleName)) {
|
||||
if (ModuleManager.itemHasModule(stack, moduleName)) {
|
||||
val slots: Set[Integer] = new HashSet[Integer]
|
||||
MuseItemUtils.removeModule(stack, moduleName)
|
||||
ModuleManager.removeModule(stack, moduleName)
|
||||
import scala.collection.JavaConversions._
|
||||
for (refundItem <- refund) {
|
||||
slots.addAll(MuseItemUtils.giveOrDropItemWithChance(refundItem.copy, playerEntity, Config.getSalvageChance))
|
||||
|
|
|
@ -10,6 +10,8 @@ import net.minecraft.entity.player.EntityPlayerMP
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import java.io.DataInputStream
|
||||
import scala.Predef._
|
||||
import net.machinemuse.api.ModuleManager.tagHasModule
|
||||
import net.machinemuse.api.ModuleManager
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server
|
||||
|
@ -43,7 +45,7 @@ class MusePacketTweakRequest(player: Player, itemSlot: Int, moduleName: String,
|
|||
if (moduleName != null && tweakName != null) {
|
||||
val stack = playerEntity.inventory.getStackInSlot(itemSlot)
|
||||
val itemTag: NBTTagCompound = MuseItemUtils.getMuseItemTag(stack)
|
||||
if (itemTag != null && MuseItemUtils.tagHasModule(itemTag, moduleName)) {
|
||||
if (itemTag != null && ModuleManager.tagHasModule(itemTag, moduleName)) {
|
||||
val moduleTag: NBTTagCompound = itemTag.getCompoundTag(moduleName)
|
||||
moduleTag.setDouble(tweakName, MuseMathUtils.clampDouble(tweakValue, 0, 1))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.machinemuse.powersuits.powermodule.movement;
|
||||
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||
|
@ -61,7 +62,7 @@ public class GliderModule extends PowerModuleBase implements IToggleableModule,
|
|||
boolean hasParachute = false;
|
||||
MusePlayerUtils.resetFloatKickTicks(player);
|
||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||
hasParachute = MuseItemUtils.itemHasActiveModule(torso, ParachuteModule.MODULE_PARACHUTE);
|
||||
hasParachute = ModuleManager.itemHasActiveModule(torso, ParachuteModule.MODULE_PARACHUTE);
|
||||
}
|
||||
if (sneakkey && player.motionY < 0 && (!hasParachute || forwardkey > 0)) {
|
||||
if (player.motionY < -0.1) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class JetBootsModule extends PowerModuleBase implements IToggleableModule
|
|||
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||
boolean jumpkey = movementInput.jumpKey;
|
||||
ItemStack helmet = player.getCurrentArmor(3);
|
||||
boolean hasFlightControl = MuseItemUtils.itemHasActiveModule(helmet, FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
boolean hasFlightControl = ModuleManager.itemHasActiveModule(helmet, FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
double jetEnergy = ModuleManager.computeModularProperty(item, JET_ENERGY_CONSUMPTION);
|
||||
double thrust = ModuleManager.computeModularProperty(item, JET_THRUST);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class JetPackModule extends PowerModuleBase implements IToggleableModule,
|
|||
boolean jumpkey = movementInput.jumpKey;
|
||||
ItemStack helmet = player.getCurrentArmor(3);
|
||||
boolean hasFlightControl = helmet != null && helmet.getItem() instanceof IModularItem
|
||||
&& MuseItemUtils.itemHasActiveModule(helmet, FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
&& ModuleManager.itemHasActiveModule(helmet, FlightControlModule.MODULE_FLIGHT_CONTROL);
|
||||
double jetEnergy = 0;
|
||||
double thrust = 0;
|
||||
jetEnergy += ModuleManager.computeModularProperty(item, JET_ENERGY_CONSUMPTION);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.machinemuse.powersuits.powermodule.movement;
|
||||
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||
|
@ -52,7 +53,7 @@ public class ParachuteModule extends PowerModuleBase implements IToggleableModul
|
|||
boolean hasGlider = false;
|
||||
MusePlayerUtils.resetFloatKickTicks(player);
|
||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||
hasGlider = MuseItemUtils.itemHasActiveModule(torso, GliderModule.MODULE_GLIDER);
|
||||
hasGlider = ModuleManager.itemHasActiveModule(torso, GliderModule.MODULE_GLIDER);
|
||||
}
|
||||
if (sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
|
||||
double totalVelocity = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ + player.motionY * player.motionY)
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PlayerTickHandler implements ITickHandler {
|
|||
foundItemWithModule = false;
|
||||
for (ItemStack itemStack : modularItemsEquipped) {
|
||||
if (module.isValidForItem(itemStack, player)) {
|
||||
if (MuseItemUtils.itemHasActiveModule(itemStack, module.getDataName())) {
|
||||
if (ModuleManager.itemHasActiveModule(itemStack, module.getDataName())) {
|
||||
module.onPlayerTickActive(player, itemStack);
|
||||
foundItemWithModule = true;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public class RenderTickHandler implements ITickHandler {
|
|||
|
||||
private void drawGogglesHUD(EntityPlayer player, Minecraft mc, float partialTickTime) {
|
||||
|
||||
if (ModCompatability.isThaumCraftLoaded() && ModCompatability.enableThaumGogglesModule() && player.getCurrentArmor(3) != null && player.getCurrentArmor(3).getItem() instanceof IModularItem && MuseItemUtils.itemHasActiveModule(player.getCurrentArmor(3), "Aurameter")) {
|
||||
if (ModCompatability.isThaumCraftLoaded() && ModCompatability.enableThaumGogglesModule() && player.getCurrentArmor(3) != null && player.getCurrentArmor(3).getItem() instanceof IModularItem && ModuleManager.itemHasActiveModule(player.getCurrentArmor(3), "Aurameter")) {
|
||||
ThaumRenderEventHandler.renderGogglesHUD(partialTickTime, player, mc.theWorld.getWorldTime());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ public abstract class MuseCommonStrings {
|
|||
public static List<String> getItemInstalledModules(EntityPlayer player, ItemStack stack) {
|
||||
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||
List<String> modules = new LinkedList();
|
||||
for (IPowerModule module : MuseItemUtils.getValidModulesForItem(player, stack)) {
|
||||
if (MuseItemUtils.tagHasModule(itemTag, module.getDataName())) {
|
||||
for (IPowerModule module : ModuleManager.getValidModulesForItem(player, stack)) {
|
||||
if (ModuleManager.tagHasModule(itemTag, module.getDataName())) {
|
||||
modules.add(module.getDataName());
|
||||
}
|
||||
}
|
||||
|
|
33
src/minecraft/net/machinemuse/utils/MuseItemTag.scala
Normal file
33
src/minecraft/net/machinemuse/utils/MuseItemTag.scala
Normal file
|
@ -0,0 +1,33 @@
|
|||
package net.machinemuse.utils
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.item.ItemStack
|
||||
import java.lang.String
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 6:58 PM, 8/6/13
|
||||
*/
|
||||
object MuseItemTag {
|
||||
final val NBTPREFIX: String = "mmmpsmod"
|
||||
|
||||
/**
|
||||
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
|
||||
*
|
||||
* @param stack
|
||||
* @return an NBTTagCompound, may be newly created. If stack is null,
|
||||
* returns null.
|
||||
*/
|
||||
def getMuseItemTag(stack: ItemStack): NBTTagCompound = {
|
||||
if (stack == null) {
|
||||
return null
|
||||
}
|
||||
val stackTag: NBTTagCompound = if (stack.hasTagCompound) stack.getTagCompound else new NBTTagCompound
|
||||
stack.setTagCompound(stackTag)
|
||||
val properties: NBTTagCompound = if (stackTag.hasKey(NBTPREFIX)) stackTag.getCompoundTag(NBTPREFIX) else new NBTTagCompound
|
||||
stackTag.setCompoundTag(NBTPREFIX, properties)
|
||||
|
||||
properties
|
||||
}
|
||||
|
||||
}
|
|
@ -24,19 +24,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import java.util.*;
|
||||
|
||||
public class MuseItemUtils {
|
||||
public static final String NBTPREFIX = "mmmpsmod";
|
||||
public static final String ONLINE = "Active";
|
||||
|
||||
public static List<IPowerModule> getValidModulesForItem(EntityPlayer player, ItemStack stack) {
|
||||
List<IPowerModule> validModules = new ArrayList();
|
||||
for (IPowerModule module : ModuleManager.getAllModules()) {
|
||||
if (module.isValidForItem(stack, player)) {
|
||||
validModules.add(module);
|
||||
}
|
||||
}
|
||||
return validModules;
|
||||
}
|
||||
|
||||
private static int clampMode(int selection, int modesSize) {
|
||||
if (selection > 0) {
|
||||
return selection % modesSize;
|
||||
|
@ -66,10 +55,6 @@ public class MuseItemUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean tagHasModule(NBTTagCompound tag, String moduleName) {
|
||||
return tag.hasKey(moduleName);
|
||||
}
|
||||
|
||||
public static List<String> getValidModes(ItemStack stack, EntityPlayer player) {
|
||||
List<String> modes = new ArrayList();
|
||||
if (stack.getItem() instanceof IModularItem) {
|
||||
|
@ -86,7 +71,7 @@ public class MuseItemUtils {
|
|||
List<String> modes = new ArrayList();
|
||||
if (stack.getItem() instanceof IModularItem) {
|
||||
for (IPowerModule module : ModuleManager.getAllModules()) {
|
||||
if (module.isValidForItem(stack, player) && module instanceof IRightClickModule && itemHasModule(stack, module.getDataName())) {
|
||||
if (module.isValidForItem(stack, player) && module instanceof IRightClickModule && ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
modes.add(module.getDataName());
|
||||
}
|
||||
}
|
||||
|
@ -94,47 +79,6 @@ public class MuseItemUtils {
|
|||
return modes;
|
||||
}
|
||||
|
||||
public static boolean isModuleOnline(NBTTagCompound itemTag, String moduleName) {
|
||||
if (MuseItemUtils.tagHasModule(itemTag, moduleName) && !itemTag.getCompoundTag(moduleName).hasKey(ONLINE)) {
|
||||
return true;
|
||||
} else if (MuseItemUtils.tagHasModule(itemTag, moduleName) && itemTag.getCompoundTag(moduleName).getBoolean(ONLINE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void toggleModule(NBTTagCompound itemTag, String name, boolean toggleval) {
|
||||
if (MuseItemUtils.tagHasModule(itemTag, name)) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(name);
|
||||
moduleTag.setBoolean(ONLINE, toggleval);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean itemHasModule(ItemStack stack, String moduleName) {
|
||||
return tagHasModule(getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
public static void tagAddModule(NBTTagCompound tag, IPowerModule module) {
|
||||
tag.setCompoundTag(module.getDataName(), module.getNewTag());
|
||||
}
|
||||
|
||||
public static void itemAddModule(ItemStack stack, IPowerModule moduleType) {
|
||||
tagAddModule(getMuseItemTag(stack), moduleType);
|
||||
}
|
||||
|
||||
public static boolean removeModule(NBTTagCompound tag, String moduleName) {
|
||||
if (tag.hasKey(moduleName)) {
|
||||
tag.removeTag(moduleName);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeModule(ItemStack stack, String moduleName) {
|
||||
return removeModule(getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
|
||||
*
|
||||
|
@ -143,25 +87,7 @@ public class MuseItemUtils {
|
|||
* returns null.
|
||||
*/
|
||||
public static NBTTagCompound getMuseItemTag(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound stackTag;
|
||||
if (stack.hasTagCompound()) {
|
||||
stackTag = stack.getTagCompound();
|
||||
} else {
|
||||
stackTag = new NBTTagCompound();
|
||||
stack.setTagCompound(stackTag);
|
||||
}
|
||||
|
||||
NBTTagCompound properties;
|
||||
if (stackTag.hasKey(NBTPREFIX)) {
|
||||
properties = stackTag.getCompoundTag(NBTPREFIX);
|
||||
} else {
|
||||
properties = new NBTTagCompound();
|
||||
stackTag.setCompoundTag(NBTPREFIX, properties);
|
||||
}
|
||||
return properties;
|
||||
return MuseItemTag.getMuseItemTag(stack);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getMuseRenderTag(ItemStack stack, int armorSlot) {
|
||||
|
@ -480,8 +406,8 @@ public class MuseItemUtils {
|
|||
List<IPowerModule> installedModules = new ArrayList();
|
||||
for (ItemStack stack : MuseItemUtils.modularItemsEquipped(player)) {
|
||||
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||
for (IPowerModule module : MuseItemUtils.getValidModulesForItem(player, stack)) {
|
||||
if (tagHasModule(itemTag, module.getDataName())) {
|
||||
for (IPowerModule module : ModuleManager.getValidModulesForItem(player, stack)) {
|
||||
if (ModuleManager.tagHasModule(itemTag, module.getDataName())) {
|
||||
installedModules.add(module);
|
||||
}
|
||||
}
|
||||
|
@ -492,27 +418,11 @@ public class MuseItemUtils {
|
|||
public static void toggleModuleForPlayer(EntityPlayer player, String name, boolean toggleval) {
|
||||
for (ItemStack stack : MuseItemUtils.modularItemsEquipped(player)) {
|
||||
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||
toggleModule(itemTag, name, toggleval);
|
||||
ModuleManager.toggleModule(itemTag, name, toggleval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean itemHasActiveModule(ItemStack itemStack, String moduleName) {
|
||||
IPowerModule module = ModuleManager.getModule(moduleName);
|
||||
if (module == null || itemStack == null || !module.isAllowed() || !(itemStack.getItem() instanceof IModularItem)) {
|
||||
// playerEntity.sendChatToPlayer("Server has disallowed this module. Sorry!");
|
||||
return false;
|
||||
}
|
||||
if (module instanceof IRightClickModule) {
|
||||
// MuseLogger.logDebug("Module: " + moduleName + " vs Mode: " +
|
||||
// MuseItemUtils.getActiveMode(itemStack));
|
||||
|
||||
return moduleName.equals(MuseItemUtils.getActiveMode(itemStack));
|
||||
} else {
|
||||
return isModuleOnline(getMuseItemTag(itemStack), moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getActiveMode(ItemStack itemStack) {
|
||||
return getMuseItemTag(itemStack).getString("Mode");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue