diff --git a/src/main/scala/com/github/whelmaze/tfcwailaplugin/ModTFCWailaPlugin.scala b/src/main/scala/com/github/whelmaze/tfcwailaplugin/ModTFCWailaPlugin.scala index 9b91bb5..20da47e 100644 --- a/src/main/scala/com/github/whelmaze/tfcwailaplugin/ModTFCWailaPlugin.scala +++ b/src/main/scala/com/github/whelmaze/tfcwailaplugin/ModTFCWailaPlugin.scala @@ -9,7 +9,7 @@ object ModTFCWailaPlugin { @EventHandler def init(event: FMLInitializationEvent): Unit = { - FMLInterModComms.sendMessage("Waila", "register", "tfcwailaplugin.Providers.init") + FMLInterModComms.sendMessage("Waila", "register", "com.github.whelmaze.tfcwailaplugin.Providers.init") } } diff --git a/src/main/scala/com/github/whelmaze/tfcwailaplugin/PotteryProvider.scala b/src/main/scala/com/github/whelmaze/tfcwailaplugin/PotteryProvider.scala index b0ac8e6..81014dc 100644 --- a/src/main/scala/com/github/whelmaze/tfcwailaplugin/PotteryProvider.scala +++ b/src/main/scala/com/github/whelmaze/tfcwailaplugin/PotteryProvider.scala @@ -9,17 +9,18 @@ import com.bioxx.tfc.TileEntities.TEPottery import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor} import net.minecraft.item.ItemStack import net.minecraftforge.common.util.ForgeDirection +import scala.language.postfixOps import implicits.ItemFoodTFCAdapter import implicits.ItemStackAdapter object PotteryProvider extends ProviderBase[TEPottery] { - override def getWailaStack(accessor: IWailaDataAccessor, config: IWailaConfigHandler): ItemStack = accessor.getTileEntity match { - case e: TEPottery => - val pos = accessor.getPosition + override def getWailaStack(accessor: IWailaDataAccessor, config: IWailaConfigHandler): ItemStack = { + Option(accessor.getTileEntity) collect { + case e: TEPottery if e.straw < 8 && ForgeDirection.getOrientation(accessor.getPosition.sideHit) == ForgeDirection.UP => + val pos = accessor.getPosition - if (e.straw < 8 && ForgeDirection.getOrientation(pos.sideHit) == ForgeDirection.UP) { val v = pos.hitVec val hitX = v.xCoord - v.xCoord.floor val hitZ = v.zCoord - v.zCoord.floor @@ -34,8 +35,7 @@ object PotteryProvider extends ProviderBase[TEPottery] { else if (hitX > 0.5 && hitZ > 0.5) e.getStackInSlot(3) else null - } else null - case _ => null // null null null... + } orNull } override def getWailaBody(stack: ItemStack, diff --git a/src/main/scala/com/github/whelmaze/tfcwailaplugin/implicits.scala b/src/main/scala/com/github/whelmaze/tfcwailaplugin/implicits.scala index 21d6136..53fd38f 100644 --- a/src/main/scala/com/github/whelmaze/tfcwailaplugin/implicits.scala +++ b/src/main/scala/com/github/whelmaze/tfcwailaplugin/implicits.scala @@ -3,7 +3,7 @@ package com.github.whelmaze.tfcwailaplugin import com.bioxx.tfc.Food.ItemFoodTFC import com.bioxx.tfc.api.Util.Helper import net.minecraft.inventory.IInventory -import net.minecraft.item.ItemStack +import net.minecraft.item.{Item, ItemStack} object implicits { @@ -39,8 +39,8 @@ object implicits { @inline def toInfoString: String = is.getItem match { case i: ItemFoodTFC => i.toSimpleInfoString(is) - case i if i == null => s"$WHITE*** ${GOLD}ItemStack is null! $WHITE***" - case i => s"${is.getDisplayName} x${is.stackSize}" + case i: Item => s"${is.getDisplayName} x${is.stackSize}" + case _ => s"$WHITE*** ${GOLD}Invalid ItemStack $WHITE***" } }