fixed npe case on server gui

This commit is contained in:
MachineMuse 2013-10-17 21:56:33 -06:00
parent b95beaabc8
commit fcd3439afc
3 changed files with 4 additions and 6 deletions

View file

@ -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();

View file

@ -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;
}

View file

@ -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)