transitioned render tick handler to use scissors test instead of weird inefficient partial icon drawing stuff
This commit is contained in:
parent
1a67d392b9
commit
8e3488c4dd
6 changed files with 70 additions and 34 deletions
|
@ -20,22 +20,18 @@ with RadiationArmor {
|
|||
}
|
||||
|
||||
trait ApiaristArmor extends IArmorApiarist {
|
||||
|
||||
def protectPlayer(player: EntityPlayer, armor: ItemStack, cause: String, doProtect: Boolean): Boolean = {
|
||||
if (MuseItemUtils.itemHasActiveModule(armor, ApiaristArmorModule.MODULE_APIARIST_ARMOR)) {
|
||||
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(armor, ApiaristArmorModule.APIARIST_ARMOR_ENERGY_CONSUMPTION))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
true
|
||||
} else false
|
||||
}
|
||||
}
|
||||
|
||||
trait RadiationArmor extends IAntiPoisonArmor {
|
||||
def isProtectedFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison): Boolean = {
|
||||
return MuseItemUtils.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
|
||||
}
|
||||
|
||||
def onProtectFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison) {
|
||||
MuseItemUtils.itemHasActiveModule(itemStack, HazmatModule.MODULE_HAZMAT)
|
||||
}
|
||||
|
||||
def onProtectFromPoison(itemStack: ItemStack, entityLiving: EntityLiving, `type`: Poison) {}
|
||||
}
|
|
@ -16,9 +16,8 @@ import java.net.URL
|
|||
object ModelSpecXMLReader {
|
||||
def parseFile(file: URL) = {
|
||||
val xml = XML.load(file)
|
||||
(xml \\ "model").foreach {
|
||||
modelnode =>
|
||||
parseModel(modelnode)
|
||||
(xml \\ "model") foreach {
|
||||
modelnode => parseModel(modelnode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,10 +35,7 @@ object ModelSpecXMLReader {
|
|||
bindingnode => parseBinding(bindingnode, existingspec)
|
||||
}
|
||||
}
|
||||
case None => {
|
||||
MuseLogger.logError("Model file " + file + " not found! D:")
|
||||
None
|
||||
}
|
||||
case None => MuseLogger logError "Model file " + file + " not found! D:"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package net.machinemuse.powersuits.item
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 7:29 PM, 5/13/13
|
||||
*/
|
||||
class ItemMagic {
|
||||
|
||||
}
|
|
@ -73,4 +73,9 @@ public class ChunkProviderEntity implements IChunkProvider {
|
|||
public void recreateStructures(int i, int j) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_104112_b() {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||
* Called before and after the 3D world is rendered (tickEnd is called BEFORE
|
||||
* the 2D gui is drawn... I think?).
|
||||
*
|
||||
* @param float tickData[0] the amount of time (0.0f-1.0f) since the last tick.
|
||||
* @author MachineMuse
|
||||
*/
|
||||
public class RenderTickHandler implements ITickHandler {
|
||||
|
@ -52,7 +51,7 @@ public class RenderTickHandler implements ITickHandler {
|
|||
ScaledResolution screen = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
drawMeters(player, screen);
|
||||
drawGogglesHUD(player, mc, ((Float) tickData[0]));
|
||||
drawActiveMode(player,screen);
|
||||
drawActiveMode(player, screen);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -118,25 +117,29 @@ public class RenderTickHandler implements ITickHandler {
|
|||
}
|
||||
}
|
||||
double prevX, prevY, currX, currY, nextX, nextY;
|
||||
double sw = screen.getScaledWidth_double();
|
||||
double baroffset = screen.getScaledHeight_double() - 40;
|
||||
int sw = screen.getScaledWidth();
|
||||
int sh = screen.getScaledHeight();
|
||||
int baroffset = 22;
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
baroffset -= 16;
|
||||
baroffset += 16;
|
||||
if (ForgeHooks.getTotalArmorValue(player) > 0) {
|
||||
baroffset -= 8;
|
||||
baroffset += 8;
|
||||
}
|
||||
}
|
||||
MuseRenderer.scissorsOn(0, 0, sw, sh - baroffset);
|
||||
|
||||
baroffset = screen.getScaledHeight() - baroffset;
|
||||
// Root locations of the mode list
|
||||
prevX = sw / 2.0 - 105.0 + 20.0 * i;
|
||||
prevY = baroffset + 10;
|
||||
prevY = baroffset - 8;
|
||||
currX = sw / 2.0 - 89.0 + 20.0 * i;
|
||||
currY = baroffset;
|
||||
currY = baroffset - 18;
|
||||
nextX = sw / 2.0 - 73.0 + 20.0 * i;
|
||||
nextY = baroffset + 10;
|
||||
nextY = baroffset - 8;
|
||||
if (swapTime == SWAPTIME || lastSwapDirection == 0) {
|
||||
drawIcon(prevX, prevY, prevMode, 0.4, 0, 0, 16, baroffset - prevY + 16);
|
||||
drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
|
||||
drawIcon(nextX, nextY, nextMode, 0.4, 0, 0, 16, baroffset - nextY + 16);
|
||||
drawIcon(prevX, prevY, prevMode, 0.4);
|
||||
drawIcon(currX, currY, currentMode, 0.8);
|
||||
drawIcon(nextX, nextY, nextMode, 0.4);
|
||||
} else {
|
||||
double r1 = 1 - swapTime / (double) SWAPTIME;
|
||||
double r2 = swapTime / (double) SWAPTIME;
|
||||
|
@ -145,8 +148,8 @@ public class RenderTickHandler implements ITickHandler {
|
|||
nextY = (currY * r1 + nextY * r2);
|
||||
currX = (prevX * r1 + currX * r2);
|
||||
currY = (prevY * r1 + currY * r2);
|
||||
drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
|
||||
drawIcon(nextX, nextY, nextMode, 0.8, 0, 0, 16, baroffset - nextY + 16);
|
||||
drawIcon(currX, currY, currentMode, 0.8);
|
||||
drawIcon(nextX, nextY, nextMode, 0.8);
|
||||
|
||||
} else {
|
||||
prevX = (currX * r1 + prevX * r2);
|
||||
|
@ -154,11 +157,12 @@ public class RenderTickHandler implements ITickHandler {
|
|||
currX = (nextX * r1 + currX * r2);
|
||||
currY = (nextY * r1 + currY * r2);
|
||||
// MuseRenderer
|
||||
drawIcon(prevX, prevY, prevMode, 0.8, 0, 0, 16, baroffset - prevY + 16);
|
||||
drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
|
||||
drawIcon(prevX, prevY, prevMode, 0.8);
|
||||
drawIcon(currX, currY, currentMode, 0.8);
|
||||
|
||||
}
|
||||
}
|
||||
MuseRenderer.scissorsOff();
|
||||
MuseRenderer.blendingOff();
|
||||
Colour.WHITE.doGL();
|
||||
}
|
||||
|
@ -171,9 +175,8 @@ public class RenderTickHandler implements ITickHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void drawIcon(double x, double y, Icon icon, double alpha, int u1, int v1, int u2, double v2) {
|
||||
MuseRenderer.drawIconPartial(x, y, icon, Colour.WHITE.withAlpha(alpha), u1, v1, u2, v2);
|
||||
|
||||
private void drawIcon(double x, double y, Icon icon, double alpha) {
|
||||
MuseRenderer.drawIconAt(x, y, icon, Colour.WHITE.withAlpha(alpha));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.machinemuse.general.gui.clickable.IClickable;
|
|||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
|
@ -242,6 +243,32 @@ public abstract class MuseRenderer {
|
|||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
public static void scissorsOn(int x, int y, int w, int h) {
|
||||
// GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT);
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glPushMatrix();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
int dw = mc.displayWidth;
|
||||
int dh = mc.displayHeight;
|
||||
ScaledResolution res = new ScaledResolution(mc.gameSettings, dw, dh);
|
||||
|
||||
int newx = x * res.getScaleFactor();
|
||||
int newy = dh - h * res.getScaleFactor() - y*res.getScaleFactor();
|
||||
int neww = w * res.getScaleFactor();
|
||||
int newh = h * res.getScaleFactor();
|
||||
|
||||
// GL11.glTranslated(-x, -y, 0);
|
||||
// GL11.glScaled(dw/(double)neww, dh/(double)newh, 1);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glScissor(newx, newy, neww, newh);
|
||||
}
|
||||
|
||||
public static void scissorsOff() {
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the appropriate openGL calls and draws an item and overlay using the default icon
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue