From fcd3439afcdfe79efbc69641d075e6e4f54fe12b Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Thu, 17 Oct 2013 21:56:33 -0600 Subject: [PATCH] fixed npe case on server gui --- src/minecraft/net/machinemuse/api/ModuleManager.java | 2 +- .../net/machinemuse/powersuits/block/BlockTinkerTable.java | 2 +- .../net/machinemuse/powersuits/common/GuiHandler.scala | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/minecraft/net/machinemuse/api/ModuleManager.java b/src/minecraft/net/machinemuse/api/ModuleManager.java index a31fc73..094046b 100644 --- a/src/minecraft/net/machinemuse/api/ModuleManager.java +++ b/src/minecraft/net/machinemuse/api/ModuleManager.java @@ -139,7 +139,7 @@ public class ModuleManager { // playerEntity.sendChatToPlayer("Server has disallowed this module. Sorry!"); return false; } - if (module instanceof IRightClickModule) { + if (module instanceof IRightClickModule && itemStack.getItem() instanceof ModeChangingModularItem) { // MuseLogger.logDebug("Module: " + moduleName + " vs Mode: " + // MuseItemUtils.getActiveMode(itemStack)); ModeChangingModularItem item = (ModeChangingModularItem) itemStack.getItem(); diff --git a/src/minecraft/net/machinemuse/powersuits/block/BlockTinkerTable.java b/src/minecraft/net/machinemuse/powersuits/block/BlockTinkerTable.java index 1d92115..e8eb5f2 100644 --- a/src/minecraft/net/machinemuse/powersuits/block/BlockTinkerTable.java +++ b/src/minecraft/net/machinemuse/powersuits/block/BlockTinkerTable.java @@ -106,7 +106,7 @@ public class BlockTinkerTable extends Block { if (player.isSneaking()) { return false; } - player.openGui(ModularPowersuits.INSTANCE, Config.Guis.GuiTinkerTable.ordinal(), world, x, y, z); + player.openGui(ModularPowersuits.INSTANCE, 0, world, x, y, z); return true; } diff --git a/src/minecraft/net/machinemuse/powersuits/common/GuiHandler.scala b/src/minecraft/net/machinemuse/powersuits/common/GuiHandler.scala index 5e0f6fb..7b611c0 100644 --- a/src/minecraft/net/machinemuse/powersuits/common/GuiHandler.scala +++ b/src/minecraft/net/machinemuse/powersuits/common/GuiHandler.scala @@ -10,7 +10,7 @@ import net.minecraft.client.entity.EntityClientPlayerMP import net.minecraft.entity.player.EntityPlayer import net.minecraft.stats.AchievementList import net.minecraft.world.World -import cpw.mods.fml.relauncher.{SideOnly, Side} +import net.machinemuse.numina.scala.OptionCast /** * Gui handler for this mod. Mainly just takes an ID according to what was @@ -25,11 +25,9 @@ class GuiHandler extends IGuiHandler { } } - @SideOnly(Side.CLIENT) override def getClientGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = { Minecraft.getMinecraft.thePlayer.addStat(AchievementList.openInventory, 1) - val cplayer = if (player.isInstanceOf[EntityClientPlayerMP]) Some(player.asInstanceOf[EntityClientPlayerMP]) else None - cplayer.map(p => + OptionCast[EntityClientPlayerMP](player) map (p => ID match { case 0 => new GuiTinkerTable(p) case 1 => new KeyConfigGui(p)