Skip to content

Commit

Permalink
Fix many bugs
Browse files Browse the repository at this point in the history
- Fix data card crash
- Fix blank check box button
- Fix createGrid method in GuiLib
- Fix empty request gui
- Fix chip side selection
- Fix unusable text box
- Fix router utility guy crash
- Fix crafting gui
- Fix pipes not recognizing chips on load
- Fix pipes not connecting to any inventories
  • Loading branch information
MrTJP committed Jun 14, 2014
1 parent 250a14e commit 7a1a91c
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 36 deletions.
12 changes: 9 additions & 3 deletions src/mrtjp/projectred/core/items.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import net.minecraft.item.{Item, ItemStack}
import mrtjp.projectred.ProjectRedCore
import net.minecraft.util.{EnumChatFormatting, IIcon}
import net.minecraft.creativetab.CreativeTabs
import java.util.{List => JList}
import java.util.{List => JList, Set => JSet}
import cpw.mods.fml.relauncher.{SideOnly, Side}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.World
import mrtjp.projectred.api.IScrewdriver
import net.minecraft.nbt.NBTTagCompound
import org.lwjgl.input.Keyboard
import scala.collection.JavaConversions

abstract class ItemCraftingDamage(name:String) extends ItemCore(name)
{
Expand Down Expand Up @@ -228,11 +229,16 @@ class ItemDataCard extends ItemCore("projectred.core.datacard")
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)||Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) && stack.hasTagCompound)
{
val tag = stack.getTagCompound
for (key <- tag.func_150296_c().asInstanceOf[Set[String]])
import JavaConversions._
var hasData = false
for (key <- tag.func_150296_c().asInstanceOf[JSet[String]])
{
l2.add(EnumChatFormatting.GRAY+
key+"->"+tag.getString(key).substring(0, 10)+(if (key.length>16) "..." else ""))
hasData = true
}
if (!hasData) l2.add(EnumChatFormatting.GRAY + "no data")
}
else l2.add(EnumChatFormatting.GRAY + "no data")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mrtjp/projectred/core/libmc/gui/GuiLib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object GuiLib
def createGrid(x:Int, y:Int, w:Int, h:Int, dx:Int, dy:Int) =
{
var grid = Seq[(Int, Int)]()
for (ix <- 0 until w) for (iy <- 0 until h)
for (iy <- 0 until h) for (ix <- 0 until w)
grid :+= ((x+ix*dx) -> (y+iy*dy))
grid
}
Expand Down
8 changes: 8 additions & 0 deletions src/mrtjp/projectred/core/libmc/gui/buttonwidget.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ class WidgetCheckBox(x1:Int, y1:Int, var state:Boolean) extends WidgetButton(x1-
state = !state
}

override def drawButton(mouseover:Boolean)
{
super.drawButton(mouseover)
ResourceLib.guiExtras.bind()
val u = if (state) 17 else 1
drawTexturedModalRect(x, y, u, 134, 14, 14)
}

def setState(flag:Boolean):this.type = {state = flag; this}

def setActions(unchecked:String, checked:String):this.type =
Expand Down
9 changes: 3 additions & 6 deletions src/mrtjp/projectred/core/libmc/gui/itemlistwidget.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,14 @@ class WidgetItemList(x:Int, y:Int, w:Int, h:Int) extends TWidget

def filterAllows(stack:ItemKeyStack):Boolean =
{
if (stringMatch(stack.key.getName.toLowerCase, filter)) true
//TODO ID matching
else false

def stringMatch(name:String, filter:String):Boolean =
{
for (s <- filter.split(" ")) if (!name.contains(s)) return false
true
}
false

if (stringMatch(stack.key.getName.toLowerCase, filter)) true
else false
}

private def getSeachedCount =
Expand Down Expand Up @@ -154,7 +152,6 @@ class WidgetItemList(x:Int, y:Int, w:Int, h:Int) extends TWidget
glItemPre()

import mrtjp.projectred.core.lib.LabelBreaks._

label("b")
{
for (keystack <- displayList) label("c")
Expand Down
21 changes: 13 additions & 8 deletions src/mrtjp/projectred/core/libmc/gui/sideselectionwidget.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.collection.JavaConversions
import scala.collection.mutable.ListBuffer
import mrtjp.projectred.core.libmc.DirectionalRayTracer.HitCoord
import net.minecraft.client.renderer.{RenderBlocks, Tessellator}
import codechicken.lib.render.{Vertex5, CCModel}
import codechicken.lib.render.{CCRenderState, Vertex5, CCModel}
import codechicken.lib.vec.Rotation
import net.minecraft.block.Block
import net.minecraft.client.renderer.texture.TextureMap
Expand Down Expand Up @@ -125,7 +125,7 @@ trait TWidgetSidePicker extends WidgetSideSelect

trait TWidgetSideHighlight extends WidgetSideSelect
{
private var color = PRColors.LIME.rgb
private var color = PRColors.LIME.rgba
private var activeHighlight = false

def setColor(c:Int):this.type = {color = c; this}
Expand All @@ -147,17 +147,20 @@ trait TWidgetSideHighlight extends WidgetSideSelect

private def renderHighlight(side:Int)
{
val t = Tessellator.instance

GL11.glDisable(GL11.GL_LIGHTING)
GL11.glEnable(GL11.GL_BLEND)
GL11.glDisable(GL11.GL_DEPTH_TEST)
GL11.glDisable(GL11.GL_TEXTURE_2D)
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
t.startDrawingQuads()
t.setColorRGBA_I(color, 64)
TWidgetSideHighlight.highlights(side).render()
t.draw

CCRenderState.reset()
CCRenderState.pullLightmap()
CCRenderState.baseColour = color
CCRenderState.alphaOverride = 64
CCRenderState.startDrawing()
TWidgetSideHighlight.highlights(side).render(CCRenderState.colourAttrib)
CCRenderState.draw()

GL11.glEnable(GL11.GL_DEPTH_TEST)
GL11.glEnable(GL11.GL_TEXTURE_2D)
GL11.glDisable(GL11.GL_BLEND)
Expand All @@ -178,6 +181,8 @@ object TWidgetSideHighlight

for (s <- 1 until 6)
highlights(s) = model.copy.apply(Rotation.sideRotations(s))

highlights.foreach(_.computeNormals())
}

var highlights:Array[CCModel] = _
Expand Down
2 changes: 1 addition & 1 deletion src/mrtjp/projectred/core/libmc/gui/textboxwidget.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class WidgetTextBox(x:Int, y:Int, w:Int, h:Int, var text:String) extends TWidget
def this(x:Int, y:Int, w:Int, h:Int) = this(x, y, w, h, "")

var isFocused = false
private var isEnabled = false
private var isEnabled = true
private var cursorCounter = 0
private var action = ""

Expand Down
4 changes: 4 additions & 0 deletions src/mrtjp/projectred/core/libmc/itemident.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class ItemKey(val item:Item, val itemDamage:Int, val tag:NBTTagCompound) extends
case _ => false
}

override def toString = getName

def compare(that:ItemKey) =
{
val c = itemID-that.itemID
Expand Down Expand Up @@ -74,6 +76,8 @@ class ItemKeyStack(val key:ItemKey, var stackSize:Int) extends Ordered[ItemKeySt
case _ => false
}

override def toString = "["+key.toString+", "+stackSize+"]"

def makeStack = key.makeStack(stackSize)

def copy = new ItemKeyStack(key.copy, stackSize)
Expand Down
12 changes: 7 additions & 5 deletions src/mrtjp/projectred/core/proxies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import mrtjp.projectred.core.libmc.fx.{ParticleIconRegistry, ParticleManagement}
import codechicken.lib.packet.PacketCustom
import cpw.mods.fml.client.registry.RenderingRegistry
import mrtjp.projectred.core.libmc.BasicRenderUtils
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.common.FMLCommonHandler

class CoreProxy_server extends IProxy
{
def preinit()
{
MinecraftForge.EVENT_BUS.register(RetroactiveWorldGenerator.instance)
//TickRegistry.registerTickHandler(RetroactiveWorldGenerator.instance, Side.SERVER)
}

def init()
Expand All @@ -39,20 +40,21 @@ class CoreProxy_server extends IProxy
class CoreProxy_client extends CoreProxy_server
{
@SideOnly(Side.CLIENT)
override def preinit()
override def postinit()
{
super.preinit()
super.postinit()
MinecraftForge.EVENT_BUS.register(Messenger)
MinecraftForge.EVENT_BUS.register(ParticleManagement.instance)
FMLCommonHandler.instance().bus().register(ParticleManagement.instance)
MinecraftForge.EVENT_BUS.register(ParticleIconRegistry.instance)
//TickRegistry.registerTickHandler(ParticleManagement.instance, Side.CLIENT)
}

@SideOnly(Side.CLIENT)
override def init()
{
super.init()
MinecraftForge.EVENT_BUS.register(Messenger)
PacketCustom.assignHandler(CoreCPH.channel, CoreCPH)

BasicRenderUtils.coreRenderHandlerID = RenderingRegistry.getNextAvailableRenderId
RenderingRegistry.registerBlockHandler(BasicRenderUtils.MultiRenderHandler.instance)
}
Expand Down
2 changes: 2 additions & 0 deletions src/mrtjp/projectred/transmission/items.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ abstract class ItemWireCommon(name:String) extends ItemCore(name) with TItemMult

@SideOnly(Side.CLIENT)
override def getSpriteNumber = 0

override def registerIcons(reg:IIconRegister){}
}

object ItemPartWire
Expand Down
2 changes: 1 addition & 1 deletion src/mrtjp/projectred/transportation/GuiChipUpgrade.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack

class ChipUpgradeContainer(player:EntityPlayer) extends WidgetContainer
{
val upgradeInv = new SimpleInventory(1, "upBus", 1)
val upgradeInv = new SimpleInventory(7, "upBus", 1)
{
override def isItemValidForSlot(i:Int, stack:ItemStack) =
{
Expand Down
25 changes: 22 additions & 3 deletions src/mrtjp/projectred/transportation/RoutedCraftingPipePart.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mrtjp.projectred.transportation

import codechicken.lib.data.MCDataInput
import codechicken.lib.data.{MCDataOutput, MCDataInput}
import codechicken.lib.vec.BlockCoord
import java.util.UUID
import java.util.concurrent.DelayQueue
Expand All @@ -22,8 +22,7 @@ class RoutedCraftingPipePart extends RoutedJunctionPipePart with IWorldCrafter
{
override def markDirty()
{
super.markDirty()
refreshChips()
chipsNeedRefresh = true
}

override def isItemValidForSlot(i:Int, stack:ItemStack) =
Expand Down Expand Up @@ -54,7 +53,9 @@ class RoutedCraftingPipePart extends RoutedJunctionPipePart with IWorldCrafter
private var excess = Vector[Pair2[ItemKeyStack, IWorldRequester]]() //TODO can change to Vector[ItemKeyStack], IWR is always null
private val lost = new DelayQueue[PostponedWorkItem[ItemKeyStack]]

private var chipsNeedRefresh = true
private var extensionsNeedRefresh = true

private val extensionIPs = new Array[Int](9)

var priority = 0
Expand Down Expand Up @@ -100,10 +101,28 @@ class RoutedCraftingPipePart extends RoutedJunctionPipePart with IWorldCrafter
case _ => super.read(packet, key)
}

override def readDesc(packet:MCDataInput)
{
super.readDesc(packet)
priority = packet.readInt()
}

override def writeDesc(packet:MCDataOutput)
{
super.writeDesc(packet)
packet.writeInt(priority)
}

override def updateServer()
{
super.updateServer()

if (chipsNeedRefresh)
{
chipsNeedRefresh = false
refreshChips()
}

remainingDelay -= 1
if (remainingDelay <= 0)
{
Expand Down
12 changes: 10 additions & 2 deletions src/mrtjp/projectred/transportation/RoutedInterfacePipePart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class RoutedInterfacePipePart extends RoutedJunctionPipePart with IWorldBroadcas
{
override def markDirty()
{
super.markDirty()
refreshChips()
chipsNeedRefresh = true
}

override def isItemValidForSlot(i:Int, stack:ItemStack) =
Expand All @@ -28,6 +27,8 @@ class RoutedInterfacePipePart extends RoutedJunctionPipePart with IWorldBroadcas
}
val chips = new Array[RoutingChipset](4)

private var chipsNeedRefresh = true

override def save(tag:NBTTagCompound)
{
super.save(tag)
Expand All @@ -53,6 +54,13 @@ class RoutedInterfacePipePart extends RoutedJunctionPipePart with IWorldBroadcas
override def updateServer()
{
super.updateServer()

if (chipsNeedRefresh)
{
chipsNeedRefresh = false
refreshChips()
}

for (s <- chips) if (s != null) s.update()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import mrtjp.projectred.api.IScrewdriver
import mrtjp.projectred.core.{CoreSPH, Configurator}
import mrtjp.projectred.transportation.SendPriority.SendPriority
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory.IInventory
import net.minecraft.inventory.{ISidedInventory, IInventory}
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity
Expand Down Expand Up @@ -374,7 +374,8 @@ class RoutedJunctionPipePart extends BasicPipePart with IWorldRouter with TRoute
{
PRLib.getTileEntity(world, posOfStraight(s), classOf[TileEntity]) match
{
case inv:IInventoryProvider => true
case sinv:ISidedInventory => !sinv.getAccessibleSlotsFromSide(s^1).isEmpty
case inv:IInventory => true
case pow:TControllerLayer if s == 0 => true
case _ => false
}
Expand Down
7 changes: 3 additions & 4 deletions src/mrtjp/projectred/transportation/pipeguis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class GuiCraftingPipe(container:Container, pipe:RoutedCraftingPipePart) extends
var color = 0
ResourceLib.guiExtras.bind()

for ((x, 7) <- GuiLib.createSlotGrid(8, 108, 9, 1, 0, 0))
for ((x, y) <- GuiLib.createSlotGrid(8, 108, 9, 1, 0, 0))
{
GL11.glColor4f(1, 1, 1, 1)
drawTexturedModalRect(x, y, 1, 11, 16, 16)
Gui.drawRect(x, y, x+8, y+2, PRColors.get(color).argb)
Gui.drawRect(x+4, y-2, x+4+8, y, PRColors.get(color).argb)
color += 1
}
}
Expand Down Expand Up @@ -317,8 +317,7 @@ class GuiRequester(pipe:IWorldRequester) extends WidgetGui(280, 230)

def receiveContentList(content:Map[ItemKey, Int])
{
itemList.setDisplayList(
content.map(p => ItemKeyStack(p._1, p._2)).toVector.sorted)
itemList.setDisplayList(content.map(p => ItemKeyStack(p._1, p._2)).toVector.sorted)
}
}

Expand Down

0 comments on commit 7a1a91c

Please sign in to comment.