part of nicknames made and package system improved
This commit is contained in:
parent
1d2782a364
commit
d889a2ba5e
13 changed files with 42 additions and 73 deletions
|
@ -1,7 +1,6 @@
|
|||
package net.machinemuse.api;
|
||||
|
||||
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;
|
||||
|
@ -20,7 +19,7 @@ public interface IPowerModule {
|
|||
|
||||
public abstract String getCategory();
|
||||
|
||||
public abstract boolean isValidForItem(ItemStack stack, EntityPlayer player);
|
||||
public abstract boolean isValidForItem(ItemStack stack);
|
||||
|
||||
public abstract String getDataName();
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ModuleManager {
|
|||
public static List<IPowerModule> getValidModulesForItem(EntityPlayer player, ItemStack stack) {
|
||||
List<IPowerModule> validModules = new ArrayList();
|
||||
for (IPowerModule module : getAllModules()) {
|
||||
if (module.isValidForItem(stack, player)) {
|
||||
if (module.isValidForItem(stack)) {
|
||||
validModules.add(module);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import net.machinemuse.powersuits.tick.ClientTickHandler;
|
|||
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||
import net.machinemuse.powersuits.tick.RenderTickHandler;
|
||||
import net.machinemuse.utils.render.MuseShaders;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
|
@ -134,9 +134,10 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendModeChange(EntityPlayer player, int dMode, String newMode) {
|
||||
public void sendModeChange(int dMode, String newMode) {
|
||||
EntityClientPlayerMP player= Minecraft.getMinecraft().thePlayer;
|
||||
RenderGameOverlayEventHandler.updateSwap((int) Math.signum(dMode));
|
||||
MusePacket modeChangePacket = new MusePacketModeChangeRequest((Player) player, newMode, player.inventory.currentItem);
|
||||
((EntityClientPlayerMP) player).sendQueue.addToSendQueue(modeChangePacket.getPacket131());
|
||||
player.sendQueue.addToSendQueue(modeChangePacket.getPacket131());
|
||||
}
|
||||
}
|
|
@ -4,9 +4,7 @@ import cpw.mods.fml.common.registry.TickRegistry;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.machinemuse.numina.network.MusePacketHandler;
|
||||
import net.machinemuse.powersuits.network.packets.MPSPacketList;
|
||||
import net.machinemuse.powersuits.network.packets.MPSPacketList$;
|
||||
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -50,7 +48,7 @@ public class CommonProxy {
|
|||
return CommonProxy.class.getResource(url);
|
||||
}
|
||||
|
||||
public void sendModeChange(EntityPlayer player, int dMode, String newMode) {
|
||||
public void sendModeChange(int dMode, String newMode) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ import forestry.api.arboriculture.IToolGrafter
|
|||
import net.machinemuse.api._
|
||||
import net.machinemuse.api.moduletrigger.IRightClickModule
|
||||
import net.machinemuse.general.gui.MuseIcon
|
||||
import net.machinemuse.powersuits.common.{ModularPowersuits, Config}
|
||||
import net.machinemuse.powersuits.common.Config
|
||||
import net.machinemuse.powersuits.powermodule.tool.{OmniWrenchModule, GrafterModule}
|
||||
import net.machinemuse.powersuits.powermodule.weapon.MeleeAssistModule
|
||||
import net.machinemuse.utils.{MuseItemUtils, ElectricItemUtils, MuseHeatUtils}
|
||||
import net.machinemuse.utils.{ElectricItemUtils, MuseHeatUtils}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
import net.minecraft.entity.{EntityLivingBase, Entity}
|
||||
|
@ -17,11 +17,9 @@ import net.minecraft.entity.player.EntityPlayer
|
|||
import net.minecraft.item.EnumAction
|
||||
import net.minecraft.item.EnumToolMaterial
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.{Icon, DamageSource, Vec3}
|
||||
import net.minecraft.util.{DamageSource, Vec3}
|
||||
import net.minecraft.world.World
|
||||
import net.machinemuse.numina.scala.OptionCast
|
||||
import net.machinemuse.numina.item.ModeChangingItem
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import scala.Predef.String
|
||||
|
||||
/**
|
||||
|
@ -151,7 +149,7 @@ with ModeChangingModularItem {
|
|||
override def onItemRightClick(itemStack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
import scala.collection.JavaConversions._
|
||||
for (module <- ModuleManager.getRightClickModules) {
|
||||
if (module.isValidForItem(itemStack, player) && ModuleManager.itemHasActiveModule(itemStack, module.getDataName)) {
|
||||
if (module.isValidForItem(itemStack) && ModuleManager.itemHasActiveModule(itemStack, module.getDataName)) {
|
||||
module.onRightClick(player, world, itemStack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,9 @@ package net.machinemuse.powersuits.item
|
|||
import net.machinemuse.numina.item.ModeChangingItem
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.Icon
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.machinemuse.api.ModuleManager
|
||||
import net.machinemuse.utils.MuseItemUtils
|
||||
import net.machinemuse.powersuits.common.ModularPowersuits
|
||||
import net.machinemuse.api.moduletrigger.IRightClickModule
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -17,9 +14,9 @@ import net.minecraft.client.Minecraft
|
|||
trait ModeChangingModularItem extends ModeChangingItem {
|
||||
override def getActiveMode(stack: ItemStack): String = {
|
||||
val mode = super.getActiveMode(stack)
|
||||
val modes = MuseItemUtils.getModes(stack, Minecraft.getMinecraft.thePlayer)
|
||||
val modes = getModes(stack)
|
||||
if (mode.isEmpty && modes.size > 0) {
|
||||
modes.get(0)
|
||||
modes(0)
|
||||
} else {
|
||||
mode
|
||||
}
|
||||
|
@ -33,10 +30,10 @@ trait ModeChangingModularItem extends ModeChangingItem {
|
|||
|
||||
def nextMode(stack: ItemStack): String = {
|
||||
val mode: String = getActiveMode(stack)
|
||||
val modes = MuseItemUtils.getModes(stack, Minecraft.getMinecraft.thePlayer)
|
||||
val modes = getModes(stack)
|
||||
if (modes.size > 0) {
|
||||
val modeIndex: Int = modes.indexOf(mode)
|
||||
modes.get(clampMode(modeIndex + 1, modes.size))
|
||||
modes(clampMode(modeIndex + 1, modes.size))
|
||||
} else {
|
||||
mode
|
||||
}
|
||||
|
@ -44,34 +41,34 @@ trait ModeChangingModularItem extends ModeChangingItem {
|
|||
|
||||
def prevMode(stack: ItemStack): String = {
|
||||
val mode: String = getActiveMode(stack)
|
||||
val modes = MuseItemUtils.getModes(stack, Minecraft.getMinecraft.thePlayer)
|
||||
val modes = getModes(stack)
|
||||
if (modes.size > 0) {
|
||||
val modeIndex: Int = modes.indexOf(mode)
|
||||
modes.get(clampMode(modeIndex - 1, modes.size))
|
||||
modes(clampMode(modeIndex - 1, modes.size))
|
||||
} else {
|
||||
mode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def cycleMode(stack: ItemStack, dMode: Int, player: EntityPlayer) {
|
||||
def cycleMode(stack: ItemStack, dMode: Int) {
|
||||
if (stack != null && stack.getItem.isInstanceOf[ModeChangingItem]) {
|
||||
val mode: String = getActiveMode(stack)
|
||||
val modes = MuseItemUtils.getModes(stack, player)
|
||||
val modes = getModes(stack)
|
||||
if (modes.size > 0 && dMode != 0) {
|
||||
val modeIndex: Int = modes.indexOf(mode)
|
||||
val newMode: String = modes.get(clampMode(modeIndex + dMode, modes.size))
|
||||
val newMode: String = modes(clampMode(modeIndex + dMode, modes.size))
|
||||
this.setActiveMode(stack, newMode)
|
||||
ModularPowersuits.proxy.sendModeChange(player, dMode, newMode)
|
||||
ModularPowersuits.proxy.sendModeChange(dMode, newMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getModes(stack: ItemStack, player: EntityPlayer) = {
|
||||
def getModes(stack: ItemStack) = {
|
||||
import scala.collection.JavaConversions._
|
||||
for {
|
||||
module <- ModuleManager.getAllModules
|
||||
if module.isValidForItem(stack, player)
|
||||
if module.isValidForItem(stack)
|
||||
if module.isInstanceOf[IRightClickModule]
|
||||
if ModuleManager.itemHasModule(stack, module.getDataName)
|
||||
} yield {
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack
|
|||
import cpw.mods.fml.common.network.Player
|
||||
import net.machinemuse.numina.network.{MusePackager, MusePacket}
|
||||
import net.machinemuse.numina.scala.OptionCast
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -35,6 +36,7 @@ class MusePacketInventoryRefresh(player: Player, slot: Int, stack: ItemStack) ex
|
|||
writeItemStack(stack)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def handleClient(player: EntityClientPlayerMP) {
|
||||
val inventory: IInventory = player.inventory
|
||||
inventory.setInventorySlotContents(slot, stack)
|
||||
|
|
|
@ -7,13 +7,13 @@ import cpw.mods.fml.common.network.Player
|
|||
import net.machinemuse.utils.MuseItemUtils
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import java.io.DataInputStream
|
||||
import java.util.List
|
||||
import scala.Predef._
|
||||
import net.machinemuse.numina.network.{MusePackager, MusePacket}
|
||||
import net.machinemuse.numina.item.ModeChangingItem
|
||||
import net.machinemuse.numina.scala.OptionCast
|
||||
import net.machinemuse.powersuits.item.ModeChangingModularItem
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -38,14 +38,15 @@ class MusePacketModeChangeRequest(player: Player, mode: String, slot: Int) exten
|
|||
override def handleServer(player: EntityPlayerMP) {
|
||||
var stack: ItemStack = null
|
||||
if (slot > -1 && slot < 9) {
|
||||
stack = player.inventory.mainInventory(slot)
|
||||
}
|
||||
if (stack == null) {
|
||||
return
|
||||
}
|
||||
val modes: List[String] = MuseItemUtils.getModes(stack, player)
|
||||
if (modes.contains(mode)) {
|
||||
OptionCast[ModeChangingItem](stack.getItem).map(i => i.setActiveMode(stack, mode))
|
||||
for {
|
||||
stack <- Option(player.inventory.mainInventory(slot))
|
||||
item <- OptionCast[ModeChangingModularItem](stack.getItem)
|
||||
} {
|
||||
val modes = item.getModes(stack)
|
||||
if (modes.contains(mode)) {
|
||||
OptionCast[ModeChangingItem](stack.getItem).map(i => i.setActiveMode(stack, mode))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.Minecraft
|
|||
import net.minecraft.client.entity.EntityClientPlayerMP
|
||||
import cpw.mods.fml.common.network.Player
|
||||
import net.machinemuse.numina.network.{MusePackager, MusePacket}
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -27,6 +28,7 @@ class MusePacketPlasmaBolt(player: Player, entityID: Int, size: Double) extends
|
|||
writeDouble(size)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def handleClient(player: EntityClientPlayerMP) {
|
||||
try {
|
||||
val entity: EntityPlasmaBolt = Minecraft.getMinecraft.theWorld.getEntityByID(entityID).asInstanceOf[EntityPlasmaBolt]
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.machinemuse.powersuits.powermodule.{PowerModuleBase, PropertyModifier
|
|||
import net.machinemuse.numina.network.{MusePackager, MusePacket}
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
|
@ -47,6 +48,7 @@ class MusePacketPropertyModifierConfig(player: Player, data: DataInputStream) ex
|
|||
*
|
||||
* @param player
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def handleClient(player: EntityClientPlayerMP) {
|
||||
val d = MusePacketPropertyModifierConfig
|
||||
val numModules = d readInt data
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.machinemuse.numina.render.MuseTextureUtils;
|
|||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -68,7 +67,7 @@ public abstract class PowerModuleBase implements IPowerModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidForItem(ItemStack stack, EntityPlayer player) {
|
||||
public boolean isValidForItem(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
return item instanceof IModularItem && this.validItems.contains(item);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PlayerTickHandler implements ITickHandler {
|
|||
for (IPlayerTickModule module : ModuleManager.getPlayerTickModules()) {
|
||||
foundItemWithModule = false;
|
||||
for (ItemStack itemStack : modularItemsEquipped) {
|
||||
if (module.isValidForItem(itemStack, player)) {
|
||||
if (module.isValidForItem(itemStack)) {
|
||||
if (ModuleManager.itemHasActiveModule(itemStack, module.getDataName())) {
|
||||
module.onPlayerTickActive(player, itemStack);
|
||||
foundItemWithModule = true;
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
package net.machinemuse.utils;
|
||||
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.api.IPowerModule;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.api.MuseItemTag;
|
||||
import net.machinemuse.api.moduletrigger.IRightClickModule;
|
||||
import net.machinemuse.numina.general.MuseLogger;
|
||||
import net.machinemuse.numina.general.MuseMathUtils;
|
||||
import net.machinemuse.numina.item.ModeChangingItem;
|
||||
import net.machinemuse.powersuits.client.render.modelspec.DefaultModelSpec;
|
||||
import net.machinemuse.powersuits.item.ItemComponent;
|
||||
import net.machinemuse.numina.network.MusePacket;
|
||||
import net.machinemuse.powersuits.network.packets.MusePacketModeChangeRequest;
|
||||
import net.machinemuse.powersuits.tick.RenderTickHandler;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
@ -33,34 +28,9 @@ public class MuseItemUtils {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public static void cycleMode(ItemStack stack, EntityClientPlayerMP player, int dMode) {
|
||||
if (stack != null && stack.getItem() instanceof ModeChangingItem) {
|
||||
((ModeChangingItem)(stack.getItem())).cycleMode(stack, dMode, player);
|
||||
((ModeChangingItem)(stack.getItem())).cycleMode(stack, dMode);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getValidModes(ItemStack stack, EntityPlayer player) {
|
||||
List<String> modes = new ArrayList();
|
||||
if (stack.getItem() instanceof IModularItem) {
|
||||
for (IPowerModule module : ModuleManager.getAllModules()) {
|
||||
if (module.isValidForItem(stack, player) && module instanceof IRightClickModule) {
|
||||
modes.add(module.getDataName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
|
||||
public static List<String> getModes(ItemStack stack, EntityPlayer player) {
|
||||
List<String> modes = new ArrayList();
|
||||
if (stack.getItem() instanceof IModularItem) {
|
||||
for (IPowerModule module : ModuleManager.getAllModules()) {
|
||||
if (module.isValidForItem(stack, player) && module instanceof IRightClickModule && ModuleManager.itemHasModule(stack, module.getDataName())) {
|
||||
modes.add(module.getDataName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue