mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-28 07:55:50 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33ce6e6997 | ||
|
|
7bd29d0f8f | ||
|
|
4cb138b088 | ||
|
|
d4a5ac7367 | ||
|
|
4e50508172 | ||
|
|
0cf00925ca | ||
|
|
9c15f47c10 |
No files matched your search
@@ -1,10 +1,14 @@
|
||||
syntax: glob
|
||||
*.orig
|
||||
.gradle
|
||||
build
|
||||
syntax: glob
|
||||
*.orig
|
||||
.gradle
|
||||
gradle
|
||||
build
|
||||
eclipse
|
||||
out
|
||||
*.iml
|
||||
*.ipr
|
||||
run
|
||||
out
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
src/main/java/net/*
|
||||
*.bat
|
||||
gradlew
|
||||
src/main/java/net/*
|
||||
+25
-72
@@ -1,27 +1,25 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
configurations {
|
||||
deployerJars
|
||||
//packed
|
||||
//compile.extendsFrom packed
|
||||
}
|
||||
|
||||
//add dependency repositories
|
||||
/*
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -29,90 +27,46 @@ repositories {
|
||||
name = "chickenbones"
|
||||
url = "http://chickenbones.net/maven/"
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'maven'
|
||||
|
||||
version = "1.5.11-RC3_1.8"
|
||||
group= "mcp.mobius.waila" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
version = "${waila_version}_${mc_version}"
|
||||
group= "mcp.mobius.waila"
|
||||
archivesBaseName = "Waila"
|
||||
|
||||
// Define properties file
|
||||
ext.configFile = file "build.properties"
|
||||
|
||||
configFile.withReader {
|
||||
// Load config. It shall from now be referenced as simply config or project.config
|
||||
def prop = new Properties()
|
||||
prop.load(it)
|
||||
project.ext.config = new ConfigSlurper().parse prop
|
||||
minecraft {
|
||||
version = "${mc_version}-${forge_version}"
|
||||
mappings = "snapshot_20151129"
|
||||
runDir = "run"
|
||||
|
||||
replace "@VERSION@", project.waila_version
|
||||
replaceIn "Waila.java"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:dev"
|
||||
compile "codechicken:CodeChickenCore:${config.mc_version}-${config.ccc_version}:dev"
|
||||
compile "codechicken:NotEnoughItems:${config.mc_version}-${config.nei_version}:dev"
|
||||
//deobfCompile "codechicken:CodeChickenLib:${mc_version}-${ccl_version}:dev"
|
||||
//deobfCompile "codechicken:CodeChickenCore:${mc_version}-${ccc_version}:dev"
|
||||
//deobfCompile "codechicken:NotEnoughItems:${mc_version}-${nei_version}:dev"
|
||||
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = "1.8-${config.forge_version}"
|
||||
mappings = "snapshot_20141130"
|
||||
runDir = "eclipse"
|
||||
}
|
||||
|
||||
def root = project.projectDir.parentFile
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir new File(root, "src")
|
||||
}
|
||||
resources {
|
||||
srcDir new File(root, "resources")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
processResources{
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
expand 'version':project.waila_version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
//def commonManifest = {
|
||||
// attributes 'FMLCorePlugin': 'mcp.mobius.wailacore.asm.CoreDescription'
|
||||
// attributes 'FMLCorePluginContainsFMLMod': 'mcp.mobius.waila.Waila'
|
||||
//}
|
||||
|
||||
jar {
|
||||
exclude "**/client/gui/inventory/GuiContainer.class"
|
||||
exclude "**/client/gui/inventory/GuiContainer.java"
|
||||
|
||||
// manifest commonManifest
|
||||
|
||||
// from {
|
||||
// configurations.packed.collect {
|
||||
// it.isDirectory() ? it : zipTree(it).matching {
|
||||
// exclude "META-INF", "META-INF/**", "*META-INF*", "meta-inf"
|
||||
// exclude "**.jar", "**/*.jar", "*.jar"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
task devJar(type: Jar) {
|
||||
@@ -121,7 +75,7 @@ task devJar(type: Jar) {
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourceJar, devJar
|
||||
archives devJar
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
@@ -144,5 +98,4 @@ uploadArchives {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
mc_version=1.8
|
||||
forge_version=11.14.3.1521
|
||||
ccl_version=1.1.2.139
|
||||
ccc_version=1.0.5.36
|
||||
nei_version=1.0.5.82
|
||||
mod_version=1.0
|
||||
waila_version=1.5.2a
|
||||
@@ -0,0 +1,6 @@
|
||||
mc_version=1.8.8
|
||||
forge_version=11.15.0.1618-1.8.8
|
||||
ccl_version=1.1.2.139
|
||||
ccc_version=1.0.5.36
|
||||
nei_version=1.0.5.82
|
||||
waila_version=1.6.1
|
||||
@@ -28,13 +28,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Mod(modid="Waila", name="Waila", version="1.5.11", dependencies="after:NotEnoughItems@[1.0.5.0,)", acceptableRemoteVersions="*")
|
||||
/*
|
||||
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
|
||||
packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)")
|
||||
//packetHandler = WailaPacketHandler.class)
|
||||
*/
|
||||
|
||||
@Mod(modid="Waila", name="Waila", version="@VERSION@", dependencies = "required-after:Forge@[11.15.0,)", acceptableRemoteVersions="*")
|
||||
public class Waila {
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("Waila")
|
||||
@@ -65,11 +59,10 @@ public class Waila {
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
|
||||
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
|
||||
FMLCommonHandler.instance().bus().register(new KeyEvent());
|
||||
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new KeyEvent());
|
||||
MinecraftForge.EVENT_BUS.register(WailaTickHandler.instance());
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new NetworkHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new NetworkHandler());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -1,81 +1,77 @@
|
||||
package mcp.mobius.waila.addons.vanillamc;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDDecoratorVanilla implements IWailaBlockDecorator {
|
||||
|
||||
@Override
|
||||
public void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@Override
|
||||
public void decorateBlock(ItemStack stack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
//UIHelper.drawBillboardText(stack.getDisplayName(), accessor.getRenderingPosition(), 0.5F, 1.5F, 0.5F, accessor.getPartialFrame());
|
||||
UIHelper.drawFloatingText("IN", accessor.getRenderingPosition(), 0.5F, 0.2F, -0.2F, 90F, 0F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), -0.2F, 0.2F, 0.5F, 90F, 90F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 1.2F, 0.2F, 0.5F, 90F, -90F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 0.5F, 0.2F, 1.2F, 90F, -180F, 0F);
|
||||
|
||||
//UIHelper.drawBillboardText(itemStack.getDisplayName(), accessor.getRenderingPosition(), 0.5F, 1.5F, 0.5F, accessor.getPartialFrame());
|
||||
UIHelper.drawFloatingText("IN", accessor.getRenderingPosition(), 0.5F, 0.2F, -0.2F, 90F, 0F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), -0.2F, 0.2F, 0.5F, 90F, 90F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 1.2F, 0.2F, 0.5F, 90F, -90F, 0F);
|
||||
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 0.5F, 0.2F, 1.2F, 90F, -180F, 0F);
|
||||
double offset = 0.1;
|
||||
double delta = 1 + 2 * offset;
|
||||
|
||||
double offset = 0.1;
|
||||
double delta = 1 + 2 * offset;
|
||||
double x = accessor.getRenderingPosition().xCoord - offset;
|
||||
double y = accessor.getRenderingPosition().yCoord - offset;
|
||||
double z = accessor.getRenderingPosition().zCoord - offset;
|
||||
|
||||
double x = accessor.getRenderingPosition().xCoord - offset;
|
||||
double y = accessor.getRenderingPosition().yCoord - offset;
|
||||
double z = accessor.getRenderingPosition().zCoord - offset;
|
||||
t.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
|
||||
|
||||
t.startDrawingQuads();
|
||||
t.pos(x, y + 0.2, z).endVertex();
|
||||
t.pos(x, y + 0.2, z + delta / 2 - 0.1).endVertex();
|
||||
t.pos(x + offset, y + 0.2, z + delta / 2 - 0.1).endVertex();
|
||||
t.pos(x + offset, y + 0.2, z).endVertex();
|
||||
|
||||
t.setColorRGBA(255, 255, 255, 150);
|
||||
t.pos(x, y + 0.2, z + delta / 2 + 0.1).endVertex();
|
||||
t.pos(x, y + 0.2, z + delta).endVertex();
|
||||
t.pos(x + offset, y + 0.2, z + delta).endVertex();
|
||||
t.pos(x + offset, y + 0.2, z + delta / 2 + 0.1).endVertex();
|
||||
|
||||
t.addVertex(x, y + 0.2 , z);
|
||||
t.addVertex(x, y + 0.2 , z + delta/2 - 0.1);
|
||||
t.addVertex(x + offset, y + 0.2, z + delta/2 - 0.1);
|
||||
t.addVertex(x + offset, y + 0.2, z);
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + 0.1).endVertex();
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + delta / 2 - 0.1).endVertex();
|
||||
t.pos(x + delta + offset - 0.1, y + 0.2, z + delta / 2 - 0.1).endVertex();
|
||||
t.pos(x + delta + offset - 0.1, y + 0.2, z + 0.1).endVertex();
|
||||
|
||||
t.addVertex(x, y + 0.2 , z + delta/2 + 0.1);
|
||||
t.addVertex(x, y + 0.2 , z + delta);
|
||||
t.addVertex(x + offset, y + 0.2, z + delta);
|
||||
t.addVertex(x + offset, y + 0.2, z + delta/2 + 0.1);
|
||||
|
||||
t.addVertex(x + delta - 0.1, y + 0.2 , z + 0.1);
|
||||
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 - 0.1);
|
||||
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 - 0.1);
|
||||
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + 0.1);
|
||||
|
||||
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 + 0.1);
|
||||
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta);
|
||||
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta);
|
||||
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 + 0.1);
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + delta / 2 + 0.1).endVertex();
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + delta).endVertex();
|
||||
t.pos(x + delta + offset - 0.1, y + 0.2, z + delta).endVertex();
|
||||
t.pos(x + delta + offset - 0.1, y + 0.2, z + delta / 2 + 0.1).endVertex();
|
||||
|
||||
|
||||
t.addVertex(x+ 0.1, y + 0.2, z);
|
||||
t.addVertex(x+ 0.1, y + 0.2, z+ offset);
|
||||
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset);
|
||||
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z);
|
||||
t.pos(x + 0.1, y + 0.2, z).endVertex();
|
||||
t.pos(x + 0.1, y + 0.2, z + offset).endVertex();
|
||||
t.pos(x + delta / 2 - 0.1, y + 0.2, z + offset).endVertex();
|
||||
t.pos(x + delta / 2 - 0.1, y + 0.2, z).endVertex();
|
||||
|
||||
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z);
|
||||
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset);
|
||||
t.addVertex(x+ delta, y + 0.2, z+ offset);
|
||||
t.addVertex(x+ delta, y + 0.2, z);
|
||||
t.pos(x + delta / 2 + 0.1, y + 0.2, z).endVertex();
|
||||
t.pos(x + delta / 2 + 0.1, y + 0.2, z + offset).endVertex();
|
||||
t.pos(x + delta, y + 0.2, z + offset).endVertex();
|
||||
t.pos(x + delta, y + 0.2, z).endVertex();
|
||||
|
||||
t.addVertex(x + 0.1, y + 0.2, z+ delta - 0.1);
|
||||
t.addVertex(x + 0.1, y + 0.2, z+ offset+ delta - 0.1);
|
||||
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset+ delta - 0.1);
|
||||
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ delta - 0.1);
|
||||
t.pos(x + 0.1, y + 0.2, z + delta - 0.1).endVertex();
|
||||
t.pos(x + 0.1, y + 0.2, z + offset + delta - 0.1).endVertex();
|
||||
t.pos(x + delta / 2 - 0.1, y + 0.2, z + offset + delta - 0.1).endVertex();
|
||||
t.pos(x + delta / 2 - 0.1, y + 0.2, z + delta - 0.1).endVertex();
|
||||
|
||||
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ delta - 0.1);
|
||||
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset+ delta - 0.1);
|
||||
t.addVertex(x+ delta - 0.1, y + 0.2, z+ offset+ delta - 0.1);
|
||||
t.addVertex(x+ delta - 0.1, y + 0.2, z+ delta - 0.1);
|
||||
t.pos(x + delta / 2 + 0.1, y + 0.2, z + delta - 0.1).endVertex();
|
||||
t.pos(x + delta / 2 + 0.1, y + 0.2, z + offset + delta - 0.1).endVertex();
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + offset + delta - 0.1).endVertex();
|
||||
t.pos(x + delta - 0.1, y + 0.2, z + delta - 0.1).endVertex();
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.command.ICommandSender;
|
||||
public class CommandDumpHandlers extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getCommandName() {
|
||||
return "dumphandlers";
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CommandDumpHandlers extends CommandBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] string) {
|
||||
public void processCommand(ICommandSender sender, String[] string) {
|
||||
|
||||
System.out.printf("\n\n== HEAD BLOCK PROVIDERS ==\n");
|
||||
for (Class clazz : ModuleRegistrar.instance().headBlockProviders.keySet()){
|
||||
@@ -99,9 +99,9 @@ public class CommandDumpHandlers extends CommandBase {
|
||||
public int getRequiredPermissionLevel(){ return 3; }
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUse(ICommandSender sender){
|
||||
public boolean canCommandSenderUseCommand(ICommandSender sender){
|
||||
//if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
|
||||
return super.canCommandSenderUse(sender);
|
||||
return super.canCommandSenderUseCommand(sender);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +1,87 @@
|
||||
package mcp.mobius.waila.gui.helpers;
|
||||
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class UIHelper {
|
||||
|
||||
public static void drawTexture(int posX, int posY, int sizeX, int sizeY)
|
||||
{
|
||||
UIHelper.drawTexture(posX, posY, sizeX, sizeY, 0, 0, 256, 256);
|
||||
}
|
||||
|
||||
public static void drawTexture(int posX, int posY, int sizeX, int sizeY, int texU, int texV, int texSizeU, int texSizeV)
|
||||
{
|
||||
|
||||
public static void drawTexture(int posX, int posY, int sizeX, int sizeY) {
|
||||
UIHelper.drawTexture(posX, posY, sizeX, sizeY, 0, 0, 256, 256);
|
||||
}
|
||||
|
||||
public static void drawTexture(int posX, int posY, int sizeX, int sizeY, int texU, int texV, int texSizeU, int texSizeV) {
|
||||
float zLevel = 0.0F;
|
||||
float f = 0.00390625F;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV((double)(posX + 0), (double)(posY + sizeY), (double)zLevel, texU*f, (texV + texSizeV)*f);
|
||||
t.addVertexWithUV((double) (posX + sizeX), (double) (posY + sizeY), (double) zLevel, (texU + texSizeU) * f, (texV + texSizeV) * f);
|
||||
t.addVertexWithUV((double)(posX + sizeX), (double)(posY + 0), (double)zLevel, (texU + texSizeU)*f, texV*f);
|
||||
t.addVertexWithUV((double)(posX + 0), (double)(posY + 0), (double)zLevel, texU*f, texV*f);
|
||||
t.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
t.pos((double) (posX + 0), (double) (posY + sizeY), (double) zLevel).tex((double) ((float) texU * f), (double) ((float) (texV + texSizeV) * f)).endVertex();
|
||||
t.pos((double) (posX + sizeX), (double) (posY + sizeY), (double) zLevel).tex((double) ((float) (texU + texSizeU) * f), (double) ((float) (texV + texSizeV) * f)).endVertex();
|
||||
t.pos((double) (posX + sizeX), (double) (posY + 0), (double) zLevel).tex((double) ((float) (texU + texSizeU) * f), (double) ((float) texV * f)).endVertex();
|
||||
t.pos((double) (posX + 0), (double) (posY + 0), (double) zLevel).tex((double) ((float) texU * f), (double) ((float) texV * f)).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int minx, int miny, int maxx, int maxy, int zlevel, int color1, int color2)
|
||||
{
|
||||
float alpha1 = (float)(color1 >> 24 & 255) / 255.0F;
|
||||
float red1 = (float)(color1 >> 16 & 255) / 255.0F;
|
||||
float green1 = (float)(color1 >> 8 & 255) / 255.0F;
|
||||
float blue1 = (float)(color1 & 255) / 255.0F;
|
||||
float alpha2 = (float)(color2 >> 24 & 255) / 255.0F;
|
||||
float red2 = (float)(color2 >> 16 & 255) / 255.0F;
|
||||
float green2 = (float)(color2 >> 8 & 255) / 255.0F;
|
||||
float blue2 = (float)(color2 & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int left, int top, int right, int bottom, int zLevel, int startColor, int endColor) {
|
||||
float alpha1 = (float) (startColor >> 24 & 255) / 255.0F;
|
||||
float red1 = (float) (startColor >> 16 & 255) / 255.0F;
|
||||
float green1 = (float) (startColor >> 8 & 255) / 255.0F;
|
||||
float blue1 = (float) (startColor & 255) / 255.0F;
|
||||
float alpha2 = (float) (endColor >> 24 & 255) / 255.0F;
|
||||
float red2 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float green2 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float blue2 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.startDrawingQuads();
|
||||
t.setColorRGBA_F(red1, green1, blue1, alpha1);
|
||||
t.addVertex((double)maxx, (double)miny, (double)zlevel);
|
||||
t.addVertex((double)minx, (double)miny, (double)zlevel);
|
||||
t.setColorRGBA_F(red2, green2, blue2, alpha2);
|
||||
t.addVertex((double)minx, (double)maxy, (double)zlevel);
|
||||
t.addVertex((double)maxx, (double)maxy, (double)zlevel);
|
||||
t.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
t.pos((double) right, (double) top, (double) zLevel).color(red1, green1, blue1, alpha1).endVertex();
|
||||
t.pos((double) left, (double) top, (double) zLevel).color(red1, green1, blue1, alpha1).endVertex();
|
||||
t.pos((double) left, (double) bottom, (double) zLevel).color(red2, green2, blue2, alpha2).endVertex();
|
||||
t.pos((double) right, (double) bottom, (double) zLevel).color(red2, green2, blue2, alpha2).endVertex();
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawBillboard(Vec3 pos, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame){
|
||||
UIHelper.drawBillboard((float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, x1, y1, x2, y2, r, g, b, a, partialFrame);
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame){
|
||||
|
||||
public static void drawBillboard(Vec3 pos, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame) {
|
||||
UIHelper.drawBillboard((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord, offX, offY, offZ, x1, y1, x2, y2, r, g, b, a, partialFrame);
|
||||
}
|
||||
|
||||
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame) {
|
||||
Entity player = Minecraft.getMinecraft().getRenderViewEntity();
|
||||
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float)partialFrame;
|
||||
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float)partialFrame;
|
||||
|
||||
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float) partialFrame;
|
||||
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float) partialFrame;
|
||||
|
||||
UIHelper.drawBillboard(posX, posY, posZ, offX, offY, offZ, playerViewX, playerViewY * -1.0F, 0.0F, x1, y1, x2, y2, r, g, b, a);
|
||||
}
|
||||
|
||||
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, float rotX, float rotY, float rotZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a){
|
||||
}
|
||||
|
||||
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, float rotX, float rotY, float rotZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a) {
|
||||
float f = 1.6F;
|
||||
float f1 = 0.016666668F * f;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
|
||||
GL11.glTranslatef(posX + offX, posY + offY, posZ + offZ);
|
||||
|
||||
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(rotY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(rotX, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(rotZ, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glRotatef(rotZ, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
//GL11.glScalef(-f1, -f1, f1);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
@@ -97,45 +92,45 @@ public class UIHelper {
|
||||
//GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
drawRectangle(x1, y1, 0, x2, y2, 0, r, g, b, a);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void drawBillboardText(String text, Vec3 pos, float offX, float offY, float offZ, double partialFrame){
|
||||
UIHelper.drawBillboardText(text, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, partialFrame);
|
||||
|
||||
public static void drawBillboardText(String text, Vec3 pos, float offX, float offY, float offZ, double partialFrame) {
|
||||
UIHelper.drawBillboardText(text, (float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord, offX, offY, offZ, partialFrame);
|
||||
}
|
||||
|
||||
public static void drawBillboardText(String text, float posX, float posY, float posZ, float offX, float offY, float offZ, double partialFrame){
|
||||
|
||||
public static void drawBillboardText(String text, float posX, float posY, float posZ, float offX, float offY, float offZ, double partialFrame) {
|
||||
Entity player = Minecraft.getMinecraft().getRenderViewEntity();
|
||||
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float)partialFrame;
|
||||
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float)partialFrame;
|
||||
|
||||
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float) partialFrame;
|
||||
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float) partialFrame;
|
||||
|
||||
UIHelper.drawFloatingText(text, posX, posY, posZ, offX, offY, offZ, playerViewX, playerViewY * -1.0F, 0.0F);
|
||||
}
|
||||
|
||||
public static void drawFloatingText(String text, Vec3 pos, float offX, float offY, float offZ, float rotX, float rotY, float rotZ){
|
||||
UIHelper.drawFloatingText(text, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, rotX, rotY, rotZ);
|
||||
public static void drawFloatingText(String text, Vec3 pos, float offX, float offY, float offZ, float rotX, float rotY, float rotZ) {
|
||||
UIHelper.drawFloatingText(text, (float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord, offX, offY, offZ, rotX, rotY, rotZ);
|
||||
}
|
||||
|
||||
public static void drawFloatingText(String text, float posX, float posY, float posZ, float offX, float offY, float offZ, float rotX, float rotY, float rotZ){
|
||||
|
||||
if (text.isEmpty()) return;
|
||||
|
||||
|
||||
public static void drawFloatingText(String text, float posX, float posY, float posZ, float offX, float offY, float offZ, float rotX, float rotY, float rotZ) {
|
||||
|
||||
if (text.isEmpty()) return;
|
||||
|
||||
FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
|
||||
|
||||
|
||||
float f = 1.6F;
|
||||
float f1 = 0.016666668F * f;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
//GL11.glTranslatef((float)accessor.getPosition().blockX + 0.0F, (float)accessor.getPosition().blockY + 0.5F, (float)accessor.getPosition().blockZ);
|
||||
GL11.glTranslatef(posX + offX, posY + offY, posZ + offZ);
|
||||
|
||||
|
||||
//GL11.glTranslatef(posX, posY, posZ);
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(rotY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(rotX, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(rotZ, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(rotZ, 0.0F, 0.0F, 1.0F);
|
||||
//GL11.glTranslatef(offX, offY, offZ);
|
||||
|
||||
|
||||
GL11.glScalef(-f1, -f1, f1);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
@@ -146,8 +141,8 @@ public class UIHelper {
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
int j = fontRendererObj.getStringWidth(text) / 2;
|
||||
drawRectangle((double)(-j - 1), (double)(8 + b0), 0.0, (double)(j + 1), (double)(-1 + b0), 0.0, 0, 0, 0, 64);
|
||||
|
||||
drawRectangle((double) (-j - 1), (double) (8 + b0), 0.0, (double) (j + 1), (double) (-1 + b0), 0.0, 0, 0, 0, 64);
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
fontRendererObj.drawString(text, -fontRendererObj.getStringWidth(text) / 2, b0, 553648127);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
@@ -157,39 +152,30 @@ public class UIHelper {
|
||||
//GL11.glDisable(GL11.GL_BLEND);
|
||||
//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
public static void drawRectangle(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
|
||||
t.startDrawingQuads();
|
||||
t.setColorRGBA(r, g, b, a);
|
||||
|
||||
t.addVertex(x1, y2, z1);
|
||||
t.addVertex(x1, y1, z2);
|
||||
t.addVertex(x2, y1, z2);
|
||||
t.addVertex(x2, y2, z1);
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void drawRectangleEW(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
|
||||
|
||||
public static void drawRectangle(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
|
||||
t.startDrawingQuads();
|
||||
t.setColorRGBA(r, g, b, a);
|
||||
|
||||
t.addVertex(x1, y1, z1);
|
||||
t.addVertex(x1, y1, z2);
|
||||
t.addVertex(x2, y2, z2);
|
||||
t.addVertex(x2, y2, z1);
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
t.pos(x1, y2, z1).color(r, g, b, a).endVertex();
|
||||
t.pos(x1, y1, z2).color(r, g, b, a).endVertex();
|
||||
t.pos(x2, y1, z2).color(r, g, b, a).endVertex();
|
||||
t.pos(x2, y2, z1).color(r, g, b, a).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawRectangleEW(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
|
||||
t.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
t.pos(x1, y1, z1).color(r, g, b, a).endVertex();
|
||||
t.pos(x1, y1, z2).color(r, g, b, a).endVertex();
|
||||
t.pos(x2, y2, z2).color(r, g, b, a).endVertex();
|
||||
t.pos(x2, y2, z1).color(r, g, b, a).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class ScreenModuleChoice extends ScreenBase {
|
||||
|
||||
this.getRoot().addWidget("ButtonContainer", new ButtonContainer(this.getRoot(), 3, 100, 25.0));
|
||||
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(50.0, 20.0, 400.0, 60.0, CType.RELXY, CType.REL_Y, WAlign.CENTER, WAlign.TOP));
|
||||
|
||||
|
||||
ButtonContainer buttonContainer = ((ButtonContainer)this.getRoot().getWidget("ButtonContainer"));
|
||||
|
||||
for (String key : ConfigHandler.instance().getModuleNames())
|
||||
|
||||
@@ -8,7 +8,6 @@ import mcp.mobius.waila.gui.widgets.LayoutBase;
|
||||
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfigRemote;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
@@ -24,7 +23,7 @@ public class ScreenModuleConfig extends ScreenBase {
|
||||
this.modName = modname;
|
||||
|
||||
this.getRoot().addWidget("ButtonContainer", new ButtonContainerLabel(this.getRoot(), 2, 100, 25.0));
|
||||
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(0.0, 20.0, 100.0, 60.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
|
||||
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(0.0, 20.0, 100.0, 60.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
|
||||
|
||||
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel)this.getRoot().getWidget("ButtonContainer"));
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ScreenWailaConfig extends ScreenBase {
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showhideidmeta");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showliquids");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTBLOCK, true, false,"screen.button.no", "screen.button.yes"), "choice.shifttoggledblock");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, true, false,"screen.button.no", "screen.button.yes"), "choice.shifttoggledents");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, true, false,"screen.button.no", "screen.button.yes"), "choice.shifttoggledents");
|
||||
|
||||
|
||||
this.getRoot().addWidget("LayoutConfigPos", new LayoutBase(this.getRoot()));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class FontHelper {
|
||||
|
||||
public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY, float rotationZ, float... rgba){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
if(mc.gameSettings.hideGUI){
|
||||
return;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class FontHelper {
|
||||
|
||||
private static void set2DMode(FloatBuffer matrixData) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
mc.entityRenderer.setupOverlayRendering();
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@@ -2,6 +2,7 @@ package mcp.mobius.waila.gui.truetyper;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
@@ -28,71 +29,76 @@ import java.util.Map;
|
||||
|
||||
public class TrueTypeFont {
|
||||
public final static int
|
||||
ALIGN_LEFT = 0,
|
||||
ALIGN_RIGHT = 1,
|
||||
ALIGN_CENTER = 2;
|
||||
/** Array that holds necessary information about the font characters */
|
||||
ALIGN_LEFT = 0,
|
||||
ALIGN_RIGHT = 1,
|
||||
ALIGN_CENTER = 2;
|
||||
/**
|
||||
* Array that holds necessary information about the font characters
|
||||
*/
|
||||
private FloatObject[] charArray = new FloatObject[256];
|
||||
|
||||
/** Map of user defined font characters (Character <-> IntObject) */
|
||||
/**
|
||||
* Map of user defined font characters (Character <-> IntObject)
|
||||
*/
|
||||
private Map customChars = new HashMap();
|
||||
|
||||
/** Boolean flag on whether AntiAliasing is enabled or not */
|
||||
/**
|
||||
* Boolean flag on whether AntiAliasing is enabled or not
|
||||
*/
|
||||
protected boolean antiAlias;
|
||||
|
||||
/** Font's size */
|
||||
/**
|
||||
* Font's size
|
||||
*/
|
||||
private float fontSize = 0;
|
||||
|
||||
/** Font's height */
|
||||
/**
|
||||
* Font's height
|
||||
*/
|
||||
private float fontHeight = 0;
|
||||
|
||||
/** Texture used to cache the font 0-255 characters */
|
||||
/**
|
||||
* Texture used to cache the font 0-255 characters
|
||||
*/
|
||||
private int fontTextureID;
|
||||
|
||||
/** Default font texture width */
|
||||
/**
|
||||
* Default font texture width
|
||||
*/
|
||||
private int textureWidth = 1024;
|
||||
|
||||
/** Default font texture height */
|
||||
/**
|
||||
* Default font texture height
|
||||
*/
|
||||
private int textureHeight = 1024;
|
||||
|
||||
/** A reference to Java's AWT Font that we create our font texture from */
|
||||
/**
|
||||
* A reference to Java's AWT Font that we create our font texture from
|
||||
*/
|
||||
protected Font font;
|
||||
|
||||
/** The font metrics for our Java AWT font */
|
||||
/**
|
||||
* The font metrics for our Java AWT font
|
||||
*/
|
||||
private FontMetrics fontMetrics;
|
||||
|
||||
|
||||
|
||||
private int correctL = 9, correctR = 8;
|
||||
|
||||
|
||||
private class FloatObject {
|
||||
/** Character's width */
|
||||
public float width;
|
||||
|
||||
/** Character's height */
|
||||
public float height;
|
||||
|
||||
/** Character's stored x position */
|
||||
public float storedX;
|
||||
|
||||
/** Character's stored y position */
|
||||
public float storedY;
|
||||
}
|
||||
|
||||
|
||||
public TrueTypeFont(Font font, boolean antiAlias, char[] additionalChars) {
|
||||
this.font = font;
|
||||
this.fontSize = font.getSize()+3;
|
||||
this.fontSize = font.getSize() + 3;
|
||||
this.antiAlias = antiAlias;
|
||||
|
||||
createSet( additionalChars );
|
||||
System.out.println("TrueTypeFont loaded: "+font+" - AntiAlias = "+antiAlias);
|
||||
createSet(additionalChars);
|
||||
System.out.println("TrueTypeFont loaded: " + font + " - AntiAlias = " + antiAlias);
|
||||
fontHeight -= 1;
|
||||
if (fontHeight <= 0) fontHeight = 1;
|
||||
}
|
||||
|
||||
public TrueTypeFont(Font font, boolean antiAlias) {
|
||||
this( font, antiAlias, null );
|
||||
this(font, antiAlias, null);
|
||||
}
|
||||
|
||||
public void setCorrection(boolean on) {
|
||||
if (on) {
|
||||
correctL = 2;
|
||||
@@ -102,7 +108,7 @@ public class TrueTypeFont {
|
||||
correctR = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BufferedImage getFontImage(char ch) {
|
||||
// Create a temporary image to extract the character's size
|
||||
BufferedImage tempfontImage = new BufferedImage(1, 1,
|
||||
@@ -114,19 +120,19 @@ public class TrueTypeFont {
|
||||
}
|
||||
g.setFont(font);
|
||||
fontMetrics = g.getFontMetrics();
|
||||
float charwidth = fontMetrics.charWidth(ch)+8;
|
||||
float charwidth = fontMetrics.charWidth(ch) + 8;
|
||||
|
||||
if (charwidth <= 0) {
|
||||
charwidth = 7;
|
||||
}
|
||||
float charheight = fontMetrics.getHeight()+3;
|
||||
float charheight = fontMetrics.getHeight() + 3;
|
||||
if (charheight <= 0) {
|
||||
charheight = fontSize;
|
||||
}
|
||||
|
||||
// Create another image holding the character we are creating
|
||||
BufferedImage fontImage;
|
||||
fontImage = new BufferedImage((int)charwidth,(int)charheight,
|
||||
fontImage = new BufferedImage((int) charwidth, (int) charheight,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D gt = (Graphics2D) fontImage.getGraphics();
|
||||
if (antiAlias == true) {
|
||||
@@ -145,35 +151,35 @@ public class TrueTypeFont {
|
||||
|
||||
}
|
||||
|
||||
private void createSet( char[] customCharsArray ) {
|
||||
private void createSet(char[] customCharsArray) {
|
||||
// If there are custom chars then I expand the font texture twice
|
||||
if (customCharsArray != null && customCharsArray.length > 0) {
|
||||
if (customCharsArray != null && customCharsArray.length > 0) {
|
||||
textureWidth *= 2;
|
||||
}
|
||||
|
||||
|
||||
// In any case this should be done in other way. Texture with size 512x512
|
||||
// can maintain only 256 characters with resolution of 32x32. The texture
|
||||
// size should be calculated dynamicaly by looking at character sizes.
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
BufferedImage imgTemp = new BufferedImage(textureWidth, textureHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g = (Graphics2D) imgTemp.getGraphics();
|
||||
|
||||
g.setColor(new Color(0,0,0,1));
|
||||
g.fillRect(0,0,textureWidth,textureHeight);
|
||||
|
||||
g.setColor(new Color(0, 0, 0, 1));
|
||||
g.fillRect(0, 0, textureWidth, textureHeight);
|
||||
|
||||
float rowHeight = 0;
|
||||
float positionX = 0;
|
||||
float positionY = 0;
|
||||
|
||||
int customCharsLength = ( customCharsArray != null ) ? customCharsArray.length : 0;
|
||||
|
||||
int customCharsLength = (customCharsArray != null) ? customCharsArray.length : 0;
|
||||
|
||||
for (int i = 0; i < 256 + customCharsLength; i++) {
|
||||
|
||||
|
||||
// get 0-255 characters and then custom characters
|
||||
char ch = ( i < 256 ) ? (char) i : customCharsArray[i-256];
|
||||
|
||||
char ch = (i < 256) ? (char) i : customCharsArray[i - 256];
|
||||
|
||||
BufferedImage fontImage = getFontImage(ch);
|
||||
|
||||
FloatObject newIntObject = new FloatObject();
|
||||
@@ -199,36 +205,35 @@ public class TrueTypeFont {
|
||||
}
|
||||
|
||||
// Draw it here
|
||||
g.drawImage(fontImage, (int)positionX, (int)positionY, null);
|
||||
g.drawImage(fontImage, (int) positionX, (int) positionY, null);
|
||||
|
||||
positionX += newIntObject.width;
|
||||
|
||||
if( i < 256 ) { // standard characters
|
||||
if (i < 256) { // standard characters
|
||||
charArray[i] = newIntObject;
|
||||
} else { // custom characters
|
||||
customChars.put( new Character( ch ), newIntObject );
|
||||
customChars.put(new Character(ch), newIntObject);
|
||||
}
|
||||
|
||||
fontImage = null;
|
||||
}
|
||||
|
||||
fontTextureID = loadImage(imgTemp);
|
||||
|
||||
|
||||
|
||||
//.getTexture(font.toString(), imgTemp);
|
||||
//.getTexture(font.toString(), imgTemp);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create font.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawQuad(float drawX, float drawY, float drawX2, float drawY2,
|
||||
float srcX, float srcY, float srcX2, float srcY2) {
|
||||
float srcX, float srcY, float srcX2, float srcY2) {
|
||||
float DrawWidth = drawX2 - drawX;
|
||||
float DrawHeight = drawY2 - drawY;
|
||||
float TextureSrcX= srcX / textureWidth;
|
||||
float TextureSrcX = srcX / textureWidth;
|
||||
float TextureSrcY = srcY / textureHeight;
|
||||
float SrcWidth = srcX2 - srcX;
|
||||
float SrcHeight = srcY2 - srcY;
|
||||
@@ -236,22 +241,22 @@ public class TrueTypeFont {
|
||||
float RenderHeight = (SrcHeight / textureHeight);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
|
||||
|
||||
//t.setColorRGBA_F(0f, 0f, 0f, 1f);
|
||||
|
||||
t.addVertexWithUV(drawX, drawY, 0, TextureSrcX, TextureSrcY);
|
||||
|
||||
t.pos((double) drawX, (double) drawY, 0).tex((double) ((float) TextureSrcX), (double) ((float) TextureSrcY)).endVertex();
|
||||
//GL11.glTexCoord2f(TextureSrcX, TextureSrcY);
|
||||
//GL11.glVertex2f(drawX, drawY);
|
||||
|
||||
t.addVertexWithUV(drawX, drawY + DrawHeight, 0, TextureSrcX, TextureSrcY + RenderHeight);
|
||||
|
||||
t.pos((double) drawX, (double) (drawY + DrawHeight), 0).tex((double) ((float) TextureSrcX), (double) ((float) (TextureSrcY + RenderHeight))).endVertex();
|
||||
//GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight);
|
||||
//GL11.glVertex2f(drawX, drawY + DrawHeight);
|
||||
|
||||
t.addVertexWithUV(drawX + DrawWidth, drawY + DrawHeight, 0, TextureSrcX + RenderWidth, TextureSrcY + RenderHeight);
|
||||
|
||||
t.pos((double) drawX + DrawWidth, (double) (drawY + DrawHeight), 0).tex((double) ((float) (TextureSrcX + RenderWidth)), (double) ((float) (TextureSrcY + RenderHeight))).endVertex();
|
||||
//GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight);
|
||||
//GL11.glVertex2f(drawX + DrawWidth, drawY + DrawHeight);
|
||||
|
||||
t.addVertexWithUV(drawX + DrawWidth, drawY, 0, TextureSrcX + RenderWidth, TextureSrcY);
|
||||
|
||||
t.pos((double) (drawX + DrawWidth), (double) drawY, 0).tex((double) ((float) (TextureSrcX + RenderWidth)), (double) ((float) TextureSrcY)).endVertex();
|
||||
//GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY);
|
||||
//GL11.glVertex2f(drawX + DrawWidth, drawY);
|
||||
}
|
||||
@@ -266,11 +271,11 @@ public class TrueTypeFont {
|
||||
if (currentChar < 256) {
|
||||
floatObject = charArray[currentChar];
|
||||
} else {
|
||||
floatObject = (FloatObject)customChars.get( new Character( (char) currentChar ) );
|
||||
floatObject = (FloatObject) customChars.get(new Character((char) currentChar));
|
||||
}
|
||||
|
||||
if( floatObject != null ){
|
||||
totalwidth += floatObject.width/2;
|
||||
|
||||
if (floatObject != null) {
|
||||
totalwidth += floatObject.width / 2;
|
||||
lastWidth = floatObject.width;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +288,6 @@ public class TrueTypeFont {
|
||||
return fontHeight;
|
||||
}
|
||||
|
||||
|
||||
public float getHeight(String HeightString) {
|
||||
return fontHeight;
|
||||
}
|
||||
@@ -293,36 +297,34 @@ public class TrueTypeFont {
|
||||
}
|
||||
|
||||
public void drawString(float x, float y, String whatchars, float scaleX, float scaleY, float... rgba) {
|
||||
if(rgba.length == 0) rgba = new float[]{1f,1f,1f,1f};
|
||||
drawString(x,y,whatchars, 0, whatchars.length()-1, scaleX, scaleY, ALIGN_LEFT, rgba);
|
||||
if (rgba.length == 0) rgba = new float[]{1f, 1f, 1f, 1f};
|
||||
drawString(x, y, whatchars, 0, whatchars.length() - 1, scaleX, scaleY, ALIGN_LEFT, rgba);
|
||||
}
|
||||
public void drawString(float x, float y, String whatchars, float scaleX, float scaleY, int format, float... rgba) {
|
||||
if(rgba.length == 0) rgba = new float[]{1f,1f,1f,1f};
|
||||
|
||||
drawString(x,y,whatchars, 0, whatchars.length()-1, scaleX, scaleY, format, rgba);
|
||||
public void drawString(float x, float y, String whatchars, float scaleX, float scaleY, int format, float... rgba) {
|
||||
if (rgba.length == 0) rgba = new float[]{1f, 1f, 1f, 1f};
|
||||
|
||||
drawString(x, y, whatchars, 0, whatchars.length() - 1, scaleX, scaleY, format, rgba);
|
||||
}
|
||||
|
||||
|
||||
public void drawString(float x, float y, String whatchars, int startIndex, int endIndex, float scaleX, float scaleY, int format, float... rgba) {
|
||||
if(rgba.length == 0) rgba = new float[]{1f,1f,1f,1f};
|
||||
if (rgba.length == 0) rgba = new float[]{1f, 1f, 1f, 1f};
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef (scaleX, scaleY, 1.0f);
|
||||
|
||||
GL11.glScalef(scaleX, scaleY, 1.0f);
|
||||
|
||||
FloatObject floatObject = null;
|
||||
int charCurrent;
|
||||
|
||||
|
||||
float totalwidth = 0;
|
||||
int i = startIndex, d, c;
|
||||
float startY = 0;
|
||||
|
||||
|
||||
|
||||
switch (format) {
|
||||
case ALIGN_RIGHT: {
|
||||
d = -1;
|
||||
c = correctR;
|
||||
|
||||
|
||||
while (i < endIndex) {
|
||||
if (whatchars.charAt(i) == '\n') startY -= fontHeight;
|
||||
i++;
|
||||
@@ -336,9 +338,9 @@ public class TrueTypeFont {
|
||||
if (charCurrent < 256) {
|
||||
floatObject = charArray[charCurrent];
|
||||
} else {
|
||||
floatObject = (FloatObject)customChars.get( new Character( (char) charCurrent ) );
|
||||
floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
|
||||
}
|
||||
totalwidth += floatObject.width-correctL;
|
||||
totalwidth += floatObject.width - correctL;
|
||||
}
|
||||
totalwidth /= -2;
|
||||
}
|
||||
@@ -348,147 +350,149 @@ public class TrueTypeFont {
|
||||
c = correctL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.startDrawingQuads();
|
||||
// GL11.glBegin(GL11.GL_QUADS);
|
||||
if(rgba.length == 4)
|
||||
t.setColorRGBA_F(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
while (i >= startIndex && i <= endIndex) {
|
||||
|
||||
charCurrent = whatchars.charAt(i);
|
||||
if (charCurrent < 256) {
|
||||
floatObject = charArray[charCurrent];
|
||||
} else {
|
||||
floatObject = (FloatObject)customChars.get( new Character( (char) charCurrent ) );
|
||||
}
|
||||
|
||||
if( floatObject != null ) {
|
||||
if (d < 0) totalwidth += (floatObject.width-c) * d;
|
||||
t.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
// GL11.glBegin(GL11.GL_QUADS);
|
||||
if (rgba.length == 4)
|
||||
t.putColorRGB_F(rgba[0], rgba[1], rgba[2], (int) rgba[3]);
|
||||
while (i >= startIndex && i <= endIndex) {
|
||||
|
||||
charCurrent = whatchars.charAt(i);
|
||||
if (charCurrent < 256) {
|
||||
floatObject = charArray[charCurrent];
|
||||
} else {
|
||||
floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
|
||||
}
|
||||
|
||||
if (floatObject != null) {
|
||||
if (d < 0) totalwidth += (floatObject.width - c) * d;
|
||||
if (charCurrent == '\n') {
|
||||
startY -= fontHeight * d;
|
||||
totalwidth = 0;
|
||||
if (format == ALIGN_CENTER) {
|
||||
for (int l = i+1; l <= endIndex; l++) {
|
||||
for (int l = i + 1; l <= endIndex; l++) {
|
||||
charCurrent = whatchars.charAt(l);
|
||||
if (charCurrent == '\n') break;
|
||||
if (charCurrent < 256) {
|
||||
floatObject = charArray[charCurrent];
|
||||
} else {
|
||||
floatObject = (FloatObject)customChars.get( new Character( (char) charCurrent ) );
|
||||
floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
|
||||
}
|
||||
totalwidth += floatObject.width-correctL;
|
||||
totalwidth += floatObject.width - correctL;
|
||||
}
|
||||
totalwidth /= -2;
|
||||
}
|
||||
//if center get next lines total width/2;
|
||||
}
|
||||
else {
|
||||
drawQuad((totalwidth + floatObject.width) + x/scaleX,
|
||||
startY + y/scaleY,
|
||||
totalwidth + x/scaleX,
|
||||
(startY + floatObject.height) + y/scaleY,
|
||||
floatObject.storedX + floatObject.width,
|
||||
floatObject.storedY + floatObject.height,
|
||||
floatObject.storedX,
|
||||
floatObject.storedY);
|
||||
if (d > 0) totalwidth += (floatObject.width-c) * d ;
|
||||
} else {
|
||||
drawQuad((totalwidth + floatObject.width) + x / scaleX,
|
||||
startY + y / scaleY,
|
||||
totalwidth + x / scaleX,
|
||||
(startY + floatObject.height) + y / scaleY,
|
||||
floatObject.storedX + floatObject.width,
|
||||
floatObject.storedY + floatObject.height,
|
||||
floatObject.storedX,
|
||||
floatObject.storedY);
|
||||
if (d > 0) totalwidth += (floatObject.width - c) * d;
|
||||
}
|
||||
i += d;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
tessellator.draw();
|
||||
// GL11.glEnd();
|
||||
|
||||
// GL11.glEnd();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static int loadImage(BufferedImage bufferedImage) {
|
||||
try {
|
||||
short width = (short)bufferedImage.getWidth();
|
||||
short height = (short)bufferedImage.getHeight();
|
||||
//textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
|
||||
int bpp = (byte)bufferedImage.getColorModel().getPixelSize();
|
||||
ByteBuffer byteBuffer;
|
||||
DataBuffer db = bufferedImage.getData().getDataBuffer();
|
||||
if (db instanceof DataBufferInt) {
|
||||
int intI[] = ((DataBufferInt)(bufferedImage.getData().getDataBuffer())).getData();
|
||||
byte newI[] = new byte[intI.length * 4];
|
||||
for (int i = 0; i < intI.length; i++) {
|
||||
byte b[] = intToByteArray(intI[i]);
|
||||
int newIndex = i*4;
|
||||
|
||||
newI[newIndex] = b[1];
|
||||
newI[newIndex+1] = b[2];
|
||||
newI[newIndex+2] = b[3];
|
||||
newI[newIndex+3] = b[0];
|
||||
}
|
||||
|
||||
byteBuffer = ByteBuffer.allocateDirect(
|
||||
width*height*(bpp/8))
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.put(newI);
|
||||
} else {
|
||||
byteBuffer = ByteBuffer.allocateDirect(
|
||||
width*height*(bpp/8))
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.put(((DataBufferByte)(bufferedImage.getData().getDataBuffer())).getData());
|
||||
}
|
||||
byteBuffer.flip();
|
||||
|
||||
|
||||
int internalFormat = GL11.GL_RGBA8,
|
||||
format = GL11.GL_RGBA;
|
||||
IntBuffer textureId = BufferUtils.createIntBuffer(1);;
|
||||
try {
|
||||
short width = (short) bufferedImage.getWidth();
|
||||
short height = (short) bufferedImage.getHeight();
|
||||
//textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
|
||||
int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
|
||||
ByteBuffer byteBuffer;
|
||||
DataBuffer db = bufferedImage.getData().getDataBuffer();
|
||||
if (db instanceof DataBufferInt) {
|
||||
int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
|
||||
byte newI[] = new byte[intI.length * 4];
|
||||
for (int i = 0; i < intI.length; i++) {
|
||||
byte b[] = intToByteArray(intI[i]);
|
||||
int newIndex = i * 4;
|
||||
|
||||
newI[newIndex] = b[1];
|
||||
newI[newIndex + 1] = b[2];
|
||||
newI[newIndex + 2] = b[3];
|
||||
newI[newIndex + 3] = b[0];
|
||||
}
|
||||
|
||||
byteBuffer = ByteBuffer.allocateDirect(
|
||||
width * height * (bpp / 8))
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.put(newI);
|
||||
} else {
|
||||
byteBuffer = ByteBuffer.allocateDirect(
|
||||
width * height * (bpp / 8))
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
|
||||
}
|
||||
byteBuffer.flip();
|
||||
|
||||
|
||||
int internalFormat = GL11.GL_RGBA8,
|
||||
format = GL11.GL_RGBA;
|
||||
IntBuffer textureId = BufferUtils.createIntBuffer(1);
|
||||
GL11.glGenTextures(textureId);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));
|
||||
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
|
||||
|
||||
|
||||
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
||||
//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||
//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
|
||||
|
||||
|
||||
//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
|
||||
//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
|
||||
//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);
|
||||
|
||||
|
||||
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
|
||||
|
||||
GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
|
||||
return textureId.get(0);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
//System.exit(-1);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
//System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSupported(String fontname) {
|
||||
Font font[] = getFonts();
|
||||
for (int i = font.length-1; i >= 0; i--) {
|
||||
for (int i = font.length - 1; i >= 0; i--) {
|
||||
if (font[i].getName().equalsIgnoreCase(fontname))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Font[] getFonts() {
|
||||
return GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
|
||||
}
|
||||
|
||||
public static byte[] intToByteArray(int value) {
|
||||
return new byte[] {
|
||||
(byte)(value >>> 24),
|
||||
(byte)(value >>> 16),
|
||||
(byte)(value >>> 8),
|
||||
(byte)value};
|
||||
return new byte[]{
|
||||
(byte) (value >>> 24),
|
||||
(byte) (value >>> 16),
|
||||
(byte) (value >>> 8),
|
||||
(byte) value};
|
||||
}
|
||||
|
||||
|
||||
public void destroy() {
|
||||
IntBuffer scratch = BufferUtils.createIntBuffer(1);
|
||||
scratch.put(0, fontTextureID);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class LayoutCanvas extends LayoutBase{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
this.rez = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
this.rez = new ScaledResolution(mc);
|
||||
this.setGeometry(0, 0, this.rez.getScaledWidth(), this.rez.getScaledHeight(), CType.ABSXY, CType.ABSXY);
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,7 @@ public class LayoutCropping extends LayoutBase {
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
this.rez = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
this.rez = new ScaledResolution(mc);
|
||||
this.saveGLState();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class WidgetBase implements IWidget {
|
||||
public WidgetBase(){
|
||||
this.setParent(null);
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.rez = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
this.rez = new ScaledResolution(mc);
|
||||
this.texManager = this.mc.renderEngine;
|
||||
this.setGeometry(new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY));
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public abstract class WidgetBase implements IWidget {
|
||||
public WidgetBase(IWidget parent){
|
||||
this.setParent(parent);
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.rez = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
this.rez = new ScaledResolution(mc);
|
||||
this.texManager = this.mc.renderEngine;
|
||||
this.setGeometry(new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY));
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public abstract class WidgetBase implements IWidget {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, this.alpha);
|
||||
|
||||
|
||||
this.draw(this.getPos());
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
||||
for (IWidget widget : this.widgets.values())
|
||||
if (widget instanceof LabelFixedFont)
|
||||
if (this.mouseOver)
|
||||
@@ -42,10 +42,10 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
|
||||
if (this.mouseOver)
|
||||
texOffset = 1;
|
||||
|
||||
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
|
||||
|
||||
|
||||
this.loadGLState();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package mcp.mobius.waila.handlers;
|
||||
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
/*
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
@@ -131,4 +131,4 @@ public class HandlerEnchants implements IContainerInputHandler {
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer guiContainer, int mouseX, int mouseY, int button, long heldTime) {}
|
||||
}
|
||||
}*/
|
||||
@@ -1,5 +1,5 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -45,4 +45,5 @@ public class ModNameFilter implements ISearchProvider{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/*
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
@@ -85,3 +85,4 @@ public class NEIHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
/*
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -45,3 +45,4 @@ public class OreDictFilter implements ISearchProvider{
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -28,3 +28,4 @@ public class TooltipHandlerWaila implements IContainerTooltipHandler {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -1,13 +1,5 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
@@ -15,55 +7,59 @@ import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DecoratorRenderer {
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderWorldLast(RenderWorldLastEvent event) {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderWorldLast(RenderWorldLastEvent event) {
|
||||
if (RayTracing.instance().getTarget() == null || RayTracing.instance().getTargetStack() == null) return;
|
||||
|
||||
|
||||
double partialTicks = event.partialTicks;
|
||||
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
Entity viewEntity = Minecraft.getMinecraft().getRenderViewEntity();
|
||||
|
||||
if (world == null || player == null || viewEntity == null) return;
|
||||
|
||||
accessor.set(world, player, RayTracing.instance().getTarget(), viewEntity, partialTicks);
|
||||
|
||||
Block block = accessor.getBlock();
|
||||
if (world == null || player == null || viewEntity == null) return;
|
||||
|
||||
accessor.set(world, player, RayTracing.instance().getTarget(), viewEntity, partialTicks);
|
||||
|
||||
Block block = accessor.getBlock();
|
||||
|
||||
if (!ModuleRegistrar.instance().hasBlockDecorator(block)) return;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
if (ModuleRegistrar.instance().hasBlockDecorator(block)){
|
||||
for (List<IWailaBlockDecorator> decoratorsList : ModuleRegistrar.instance().getBlockDecorators(block).values()){
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
if (ModuleRegistrar.instance().hasBlockDecorator(block)) {
|
||||
for (List<IWailaBlockDecorator> decoratorsList : ModuleRegistrar.instance().getBlockDecorators(block).values()) {
|
||||
for (IWailaBlockDecorator decorator : decoratorsList)
|
||||
try{
|
||||
try {
|
||||
GL11.glPushMatrix();
|
||||
decorator.decorateBlock(RayTracing.instance().getTargetStack(), accessor, ConfigHandler.instance());
|
||||
GL11.glPopMatrix();
|
||||
} catch (Throwable e){
|
||||
GL11.glPopMatrix();
|
||||
} catch (Throwable e) {
|
||||
GL11.glPopMatrix();
|
||||
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -23,161 +24,159 @@ import java.util.regex.Matcher;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class DisplayUtil {
|
||||
private static FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
|
||||
protected static RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
private static FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
|
||||
protected static RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
|
||||
public static int getDisplayWidth(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return 0;
|
||||
public static int getDisplayWidth(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return 0;
|
||||
|
||||
int width = 0;
|
||||
int width = 0;
|
||||
|
||||
Matcher renderMatcher = patternRender.matcher(s);
|
||||
while (renderMatcher.find()) {
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
}
|
||||
Matcher renderMatcher = patternRender.matcher(s);
|
||||
while (renderMatcher.find()) {
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
}
|
||||
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
while (iconMatcher.find())
|
||||
width += 8;
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
while (iconMatcher.find())
|
||||
width += 8;
|
||||
|
||||
width += fontRendererObj.getStringWidth(stripSymbols(s));
|
||||
return width;
|
||||
}
|
||||
width += fontRendererObj.getStringWidth(stripSymbols(s));
|
||||
return width;
|
||||
}
|
||||
|
||||
public static Dimension displaySize() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
|
||||
}
|
||||
public static Dimension displaySize() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution res = new ScaledResolution(mc);
|
||||
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
|
||||
}
|
||||
|
||||
public static String stripSymbols(String s) {
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternMinecraft.matcher(result).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
public static String stripSymbols(String s) {
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternMinecraft.matcher(result).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String stripWailaSymbols(String s) {
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
public static String stripWailaSymbols(String s) {
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void renderStack(int x, int y, ItemStack stack) {
|
||||
enable3DRender();
|
||||
try {
|
||||
renderItem.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
renderItem.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, null);
|
||||
} catch (Exception e) {
|
||||
String stackStr = stack != null ? stack.toString() : "NullStack";
|
||||
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
|
||||
}
|
||||
enable2DRender();
|
||||
}
|
||||
public static void renderStack(int x, int y, ItemStack stack) {
|
||||
enable3DRender();
|
||||
try {
|
||||
renderItem.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
renderItem.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, null);
|
||||
} catch (Exception e) {
|
||||
String stackStr = stack != null ? stack.toString() : "NullStack";
|
||||
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
|
||||
}
|
||||
enable2DRender();
|
||||
}
|
||||
|
||||
public static void enable3DRender() {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
public static void enable3DRender() {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public static void enable2DRender() {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
public static void enable2DRender() {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int x, int y, int w, int h, int grad1, int grad2) {
|
||||
float zLevel = 0.0f;
|
||||
public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) {
|
||||
float zLevel = 0.0F;
|
||||
|
||||
float f = (float) (grad1 >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (grad1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (grad1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (grad1 & 255) / 255.0F;
|
||||
float f4 = (float) (grad2 >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (grad2 >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (grad2 >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (grad2 & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.startDrawingQuads();
|
||||
t.setColorRGBA_F(f1, f2, f3, f);
|
||||
t.addVertex((double) (x + w), (double) y, (double) zLevel);
|
||||
t.addVertex((double) x, (double) y, (double) zLevel);
|
||||
t.setColorRGBA_F(f5, f6, f7, f4);
|
||||
t.addVertex((double) x, (double) (y + h), (double) zLevel);
|
||||
t.addVertex((double) (x + w), (double) (y + h), (double) zLevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
float f = (float) (startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (startColor & 255) / 255.0F;
|
||||
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
t.pos((double) (left + right), (double) top, (double) zLevel).color(f1, f2, f3, f).endVertex();
|
||||
t.pos((double) left, (double) top, (double) zLevel).color(f1, f2, f3, f).endVertex();
|
||||
t.pos((double) left, (double) (top + bottom), (double) zLevel).color(f5, f6, f7, f4).endVertex();
|
||||
t.pos((double) (left + right), (double) (top + bottom), (double) zLevel).color(f5, f6, f7, f4).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th) {
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.startDrawingQuads();
|
||||
t.setColorOpaque_F(1, 1, 1);
|
||||
t.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
|
||||
t.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
|
||||
t.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
|
||||
t.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
|
||||
tessellator.draw();
|
||||
}
|
||||
public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height, int tw, int th) {
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer t = tessellator.getWorldRenderer();
|
||||
t.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
t.pos((double) (x + 0), (double) (y + height), (double) zLevel).tex((double) ((float) (textureX + 0) * f), (double) ((float) (textureY + th) * f1)).endVertex();
|
||||
t.pos((double) (x + width), (double) (y + height), (double) zLevel).tex((double) ((float) (textureX + tw) * f), (double) ((float) (textureY + th) * f1)).endVertex();
|
||||
t.pos((double) (x + width), (double) (y + 0), (double) zLevel).tex((double) ((float) (textureX + tw) * f), (double) ((float) (textureY + 0) * f1)).endVertex();
|
||||
t.pos((double) (x + 0), (double) (y + 0), (double) zLevel).tex((double) ((float) (textureX + 0) * f), (double) ((float) (textureY + 0) * f1)).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawString(String text, int x, int y, int colour, boolean shadow) {
|
||||
if (shadow)
|
||||
fontRendererObj.drawStringWithShadow(text, x, y, colour);
|
||||
else
|
||||
fontRendererObj.drawString(text, x, y, colour);
|
||||
}
|
||||
public static void drawString(String text, int x, int y, int colour, boolean shadow) {
|
||||
if (shadow)
|
||||
fontRendererObj.drawStringWithShadow(text, x, y, colour);
|
||||
else
|
||||
fontRendererObj.drawString(text, x, y, colour);
|
||||
}
|
||||
|
||||
public static List<String> itemDisplayNameMultiline(ItemStack itemstack) {
|
||||
List<String> namelist = null;
|
||||
try {
|
||||
namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
public static List<String> itemDisplayNameMultiline(ItemStack itemstack) {
|
||||
List<String> namelist = null;
|
||||
try {
|
||||
namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
if (namelist == null)
|
||||
namelist = new ArrayList<String>();
|
||||
if (namelist == null)
|
||||
namelist = new ArrayList<String>();
|
||||
|
||||
if (namelist.size() == 0)
|
||||
namelist.add("Unnamed");
|
||||
if (namelist.size() == 0)
|
||||
namelist.add("Unnamed");
|
||||
|
||||
if (namelist.get(0) == null || namelist.get(0).equals(""))
|
||||
namelist.set(0, "Unnamed");
|
||||
if (namelist.get(0) == null || namelist.get(0).equals(""))
|
||||
namelist.set(0, "Unnamed");
|
||||
|
||||
namelist.set(0, itemstack.getRarity().rarityColor.toString() + namelist.get(0));
|
||||
for (int i = 1; i < namelist.size(); i++)
|
||||
namelist.set(i, "\u00a77" + namelist.get(i));
|
||||
namelist.set(0, itemstack.getRarity().rarityColor.toString() + namelist.get(0));
|
||||
for (int i = 1; i < namelist.size(); i++)
|
||||
namelist.set(i, "\u00a77" + namelist.get(i));
|
||||
|
||||
return namelist;
|
||||
}
|
||||
return namelist;
|
||||
}
|
||||
|
||||
public static String itemDisplayNameShort(ItemStack itemstack) {
|
||||
List<String> list = itemDisplayNameMultiline(itemstack);
|
||||
return list.get(0);
|
||||
}
|
||||
public static String itemDisplayNameShort(ItemStack itemstack) {
|
||||
List<String> list = itemDisplayNameMultiline(itemstack);
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
|
||||
if (icon == null)
|
||||
return;
|
||||
if (icon == null)
|
||||
return;
|
||||
|
||||
if (icon.bu != -1)
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
}
|
||||
if (icon.bu != -1)
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
}
|
||||
@@ -79,26 +79,22 @@ public class OverlayRenderer {
|
||||
}
|
||||
|
||||
public static void saveGLState(){
|
||||
//hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
|
||||
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
|
||||
//hasLight0 = GL11.glGetBoolean(GL11.GL_LIGHT0);
|
||||
//hasLight1 = GL11.glGetBoolean(GL11.GL_LIGHT1);
|
||||
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
|
||||
//hasRescaleNormal = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
|
||||
//hasColorMaterial = GL11.glGetBoolean(GL11.GL_COLOR_MATERIAL);
|
||||
//boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
|
||||
}
|
||||
|
||||
public static void loadGLState(){
|
||||
//if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
|
||||
if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
|
||||
//if (hasLight0) GL11.glEnable(GL11.GL_LIGHT0); else GL11.glDisable(GL11.GL_LIGHT0);
|
||||
//if (hasLight1) GL11.glEnable(GL11.GL_LIGHT1); else GL11.glDisable(GL11.GL_LIGHT1);
|
||||
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST); else GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
//if (hasRescaleNormal) GL11.glEnable(GL12.GL_RESCALE_NORMAL); else GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
//if (hasColorMaterial) GL11.glEnable(GL11.GL_COLOR_MATERIAL); else GL11.glDisable(GL11.GL_COLOR_MATERIAL);
|
||||
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
|
||||
GL11.glPopAttrib();
|
||||
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class RayTracing {
|
||||
return items;
|
||||
|
||||
try{
|
||||
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, pos);
|
||||
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, pos, player);
|
||||
if(pick != null)
|
||||
items.add(pick);
|
||||
}catch(Exception e){}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TTRenderStack implements IWailaTooltipRenderer{
|
||||
|
||||
@@ -26,9 +27,9 @@ public class TTRenderStack implements IWailaTooltipRenderer{
|
||||
|
||||
ItemStack stack = null;
|
||||
if (type == 0)
|
||||
stack = new ItemStack((Block)Block.blockRegistry.getObject(name), amount, meta);
|
||||
stack = new ItemStack((Block)Block.blockRegistry.getObject(new ResourceLocation(name)), amount, meta);
|
||||
if (type == 1)
|
||||
stack = new ItemStack((Item)Item.itemRegistry.getObject(name), amount, meta);
|
||||
stack = new ItemStack((Item)Item.itemRegistry.getObject(new ResourceLocation(name)), amount, meta);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
DisplayUtil.renderStack(0, 0, stack);
|
||||
|
||||
@@ -49,6 +49,7 @@ public class ModIdentification {
|
||||
modSource_ID.put("1.6.4.jar", "Minecraft");
|
||||
modSource_ID.put("1.7.2.jar", "Minecraft");
|
||||
modSource_ID.put("1.8.0.jar", "Minecraft");
|
||||
modSource_ID.put("1.8.8.jar", "Minecraft");
|
||||
modSource_ID.put("Forge", "Minecraft");
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
[
|
||||
{
|
||||
"modid": "waila",
|
||||
"modid": "Waila",
|
||||
"name": "Waila",
|
||||
"description": "All your data are belong to us.",
|
||||
"description": "",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authors": ["ProfMobius"],
|
||||
"credits": "The Forge and FML guys, for making this example",
|
||||
"authorList": [
|
||||
"ProfMobius"
|
||||
],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
"screenshots": [
|
||||
],
|
||||
"parent":"",
|
||||
"dependencies": [
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
Reference in new issue
Block a user