fixed some crash cases and instability in cosmetic gui

This commit is contained in:
MachineMuse 2013-08-03 12:41:43 -06:00
parent f3b95dbfd6
commit 6d1f594058
6 changed files with 23 additions and 8 deletions

View file

@ -4,6 +4,9 @@ import net.minecraft.entity.player.EntityPlayer
import net.machinemuse.general.gui.frame.{ColourPickerFrame, ItemModelViewFrame, PartManipContainer, ItemSelectionFrame}
import net.machinemuse.general.geometry.{MuseRect, Colour, MusePoint2D}
import net.minecraft.item.ItemStack
import net.machinemuse.utils.render.GlowBuffer
import net.minecraft.client.gui.ScaledResolution
import net.machinemuse.powersuits.common.Config
/**
* Author: MachineMuse (Claire Semple)
@ -62,5 +65,14 @@ class CosmeticGui(val player: EntityPlayer) extends MuseGui {
super.update()
}
override def drawScreen(x: Int, y: Int, z: Float) {
if (Config.canUseShaders) {
GlowBuffer.clear()
}
super.drawScreen(x, y, z)
if (Config.canUseShaders) {
val screen: ScaledResolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight)
GlowBuffer.drawFullScreen(screen)
}
}
}

View file

@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11._
import net.machinemuse.utils.{MuseMathUtils, MuseItemUtils}
import net.minecraft.nbt.NBTTagCompound
import net.machinemuse.powersuits.item.ItemPowerArmor
import net.machinemuse.utils.render.MuseRenderer
/**
* Author: MachineMuse (Claire Semple)
@ -69,15 +70,17 @@ class ItemModelViewFrame(itemSelector: ItemSelectionFrame, topleft: MusePoint2D,
anchorx = mousex
anchory = mousey
}
case _ => None
}
}
def draw() {
val mc: Minecraft = Minecraft.getMinecraft
border.draw()
if (itemSelector.getSelectedItem == null || !getSelectedItem.getItem.getItem.isInstanceOf[ItemPowerArmor]) return
glPushMatrix()
ArmorModel.instance.renderSpec = MuseItemUtils.getMuseRenderTag(getSelectedItem.getItem, getArmorSlot)
ArmorModel.instance.visible = getArmorSlot
ArmorModel.instance.visibleSection = getArmorSlot
glTranslated(border.centerx + offsetx, border.centery + offsety, 0)
glScaled(zoom, zoom, zoom)
glClear(GL_DEPTH_BUFFER_BIT)
@ -85,7 +88,7 @@ class ItemModelViewFrame(itemSelector: ItemSelectionFrame, topleft: MusePoint2D,
glRotatef(rotx.toFloat, 1, 0, 0)
glRotatef(roty.toFloat, 0, 1, 0)
glTranslated(0, -getArmorSlot / 2.0, 0)
ArmorModel.instance.render(Minecraft.getMinecraft.thePlayer, 0, 0, 0, 0, 0, 0.0625f)
ArmorModel.instance.render(mc.thePlayer, 0, 0, 0, 0, 0, 0.0625f)
glPopMatrix()
}

View file

@ -81,7 +81,7 @@ class PartManipSubFrame(val model: ModelSpec, val colourframe: ColourPickerFrame
val tagdata = getOrDontGetSpecTag(spec)
tagdata.map(e => {
val oldindex = spec.getColourIndex(e)
if (oldindex >= index) {
if (oldindex >= index && oldindex > 0) {
spec.setColourIndex(e, oldindex - 1)
if (player.worldObj.isRemote) player.sendQueue.addToSendQueue(new MusePacketCosmeticInfo(player.asInstanceOf[Player], getSelectedItem.inventorySlot, tagname, e).getPacket250)
}

View file

@ -16,7 +16,7 @@ object ArmorModel {
trait ArmorModel extends ModelBiped {
var renderSpec: NBTTagCompound = null
var visible: Int = 0
var visibleSection: Int = 0
def clearAndAddChildWithInitialOffsets(mr: ModelRenderer, xo: Float, yo: Float, zo: Float) {
mr.cubeList.clear()

View file

@ -23,7 +23,7 @@ class RenderPart(base: ModelBase, val parent: ModelRenderer) extends ModelRender
for {
nbt <- NBTTagAccessor.getValues(renderSpec).asScala
part <- ModelRegistry.getPart(nbt)
if part.slot == ArmorModel.instance.visible
if part.slot == ArmorModel.instance.visibleSection
if part.morph.apply(ArmorModel.instance) == parent
} {
withMaybeGlow(part, nbt) {
@ -33,7 +33,7 @@ class RenderPart(base: ModelBase, val parent: ModelRenderer) extends ModelRender
Minecraft.getMinecraft.renderEngine.bindTexture(part.getTexture(nbt))
applyTransform
val ix = part.getColourIndex(nbt)
if (ix < colours.size) {
if (ix < colours.size && ix >= 0) {
Colour.doGLByInt(colours(ix))
}
part.modelSpec.applyOffsetAndRotation // not yet implemented

View file

@ -65,7 +65,7 @@ abstract class ItemPowerArmor(id: Int, renderIndex: Int, armorType: Int)
override def getArmorModel(entityLiving: EntityLiving, itemstack: ItemStack, armorSlot: Int): ModelBiped = {
val model: ArmorModel = ArmorModel.instance
model.visible = armorSlot
model.visibleSection = armorSlot
if (itemstack != null) {
if (entityLiving.isInstanceOf[EntityPlayer]) {