@@ -3,6 +3,7 @@
import java .awt .Color ;
import java .util .ArrayList ;
import java .util .List ;
import java .util .Random ;
import net .minecraft .client .Minecraft ;
import net .minecraft .client .entity .EntityOtherPlayerMP ;
@@ -25,8 +26,6 @@
import net .minecraftforge .fml .common .gameevent .TickEvent ;
import net .minecraftforge .fml .common .gameevent .TickEvent .ClientTickEvent ;
import org .lwjgl .opengl .GL11 ;
import com .biggestnerd .civradar .Config .NameLocation ;
public class RenderHandler extends Gui {
@@ -38,6 +37,8 @@ public class RenderHandler extends Gui {
private List entityList ;
private float radarScale ;
ArrayList <String > inRangePlayers ;
private Color dubstepColor = Color .BLACK ;
private long dubstepTimer = 0 ;
public RenderHandler () {
inRangePlayers = new ArrayList <String >();
@@ -47,6 +48,17 @@ public RenderHandler() {
public void renderRadar (RenderGameOverlayEvent event ) {
if (event .type != RenderGameOverlayEvent .ElementType .CROSSHAIRS )
return ;
if (config .isDubstepMode ()) {
GLUtils .glPushMatrix ();
GLUtils .glScalef (2.0f , 2.0f , 2.0f );
ScaledResolution res = new ScaledResolution (mc , mc .displayWidth , mc .displayHeight );
int halfWidth = res .getScaledWidth () / 4 ;
int stringWidth = mc .fontRendererObj .getStringWidth ("Dubstep Mode Enabled" );
int height = res .getScaledHeight () / 8 ;
mc .fontRendererObj .drawStringWithShadow ("Dubstep Mode Enabled" , halfWidth - (stringWidth / 2 ), height , dubstepColor .getRGB ());
GLUtils .glScalef (1.0f , 1.0f , 1.0f );
GLUtils .glPopMatrix ();
}
if (config .isEnabled ()) {
drawRadar ();
}
@@ -72,6 +84,15 @@ public void onTick(ClientTickEvent event) {
mc .theWorld .playSound (mc .thePlayer .posX , mc .thePlayer .posY , mc .thePlayer .posZ , "minecraft:note.pling" , config .getPingVolume (), 1.0F , false );
}
inRangePlayers = temp ;
if (config .isDubstepMode ()) {
Random rand = new Random ();
dubstepColor = new Color (rand .nextFloat (), rand .nextFloat (), rand .nextFloat ());
if ((System .currentTimeMillis () - 202000 ) >= dubstepTimer ) {
dubstepTimer = System .currentTimeMillis ();
mc .theWorld .playSoundAtEntity (mc .thePlayer , "civradar:dubstep" , 1 , 1 );
}
}
}
}
@@ -91,86 +112,89 @@ public void renderWaypoints(RenderWorldLastEvent event) {
private void drawRadar () {
radarColor = config .getRadarColor ();
if (config .isDubstepMode ()) {
radarColor = dubstepColor ;
}
radarScale = config .getRadarScale ();
ScaledResolution res = new ScaledResolution (mc , mc .displayWidth , mc .displayHeight );
int width = res .getScaledWidth ();
GL11 .glPushMatrix ();
GL11 .glTranslatef (width - (65 * radarScale ) + (config .getRadarX ()), (65 * radarScale ) + (config .getRadarY ()), 0.0F );
GL11 .glScalef (1.0F , 1.0F , 1.0F );
GLUtils .glPushMatrix ();
GLUtils .glTranslatef (width - (65 * radarScale ) + (config .getRadarX ()), (65 * radarScale ) + (config .getRadarY ()), 0.0F );
GLUtils .glScalef (1.0F , 1.0F , 1.0F );
if (config .isRenderCoordinates ()) {
String coords = "(" + (int ) mc .thePlayer .posX + "," + (int ) mc .thePlayer .posY + "," + (int ) mc .thePlayer .posZ + ")" ;
mc .fontRendererObj .drawStringWithShadow (coords , -(mc .fontRendererObj .getStringWidth (coords ) / 2 ), 65 * radarScale , 14737632 );
}
GL11 .glScalef (radarScale , radarScale , radarScale );
GL11 .glRotatef (-mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glScalef (radarScale , radarScale , radarScale );
GLUtils .glRotatef (-mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
drawCircle (0 , 0 , 63.0D , radarColor , true );
GL11 .glLineWidth (2.0F );
GLUtils .glLineWidth (2.0F );
drawCircle (0 , 0 , 63.0D , radarColor , false );
GL11 .glLineWidth (1.0F );
GLUtils .glLineWidth (1.0F );
if (pingDelay > 0 ) {
drawCircle (0 , 0 , 63.0D - pingDelay , radarColor , false );
}
GL11 .glLineWidth (2.0F );
GL11 .glDisable (GL11 .GL_TEXTURE_2D );
GL11 .glDisable (GL11 .GL_LIGHTING );
GL11 .glBegin (1 );
GL11 .glColor4f (radarColor .getRed () / 255.0F , radarColor .getGreen () / 255.0F , radarColor .getBlue () / 255.0F , config .getRadarOpacity () + 0.5F );
GL11 .glVertex2d (0.0D , -63.0D );
GL11 .glVertex2d (0.0D , 63.0D );
GL11 .glVertex2d (-63.0D , 0.0D );
GL11 .glVertex2d (63.0D , 0.0D );
GL11 .glVertex2d (-44.5D , -44.5D );
GL11 .glVertex2d (44.5D , 44.5D );
GL11 .glVertex2d (-44.5D , 44.5D );
GL11 .glVertex2d (44.5D , -44.5D );
GL11 .glEnd ();
GL11 .glDisable (GL11 .GL_BLEND );
GL11 .glEnable (GL11 .GL_TEXTURE_2D );
GLUtils .glLineWidth (2.0F );
GLUtils .glDisable (GLUtils .GL_TEXTURE_2D );
GLUtils .glDisable (GLUtils .GL_LIGHTING );
GLUtils .glBegin (1 );
GLUtils .glColor4f (radarColor .getRed () / 255.0F , radarColor .getGreen () / 255.0F , radarColor .getBlue () / 255.0F , config .getRadarOpacity () + 0.5F );
GLUtils .glVertex2d (0.0D , -63.0D );
GLUtils .glVertex2d (0.0D , 63.0D );
GLUtils .glVertex2d (-63.0D , 0.0D );
GLUtils .glVertex2d (63.0D , 0.0D );
GLUtils .glVertex2d (-44.5D , -44.5D );
GLUtils .glVertex2d (44.5D , 44.5D );
GLUtils .glVertex2d (-44.5D , 44.5D );
GLUtils .glVertex2d (44.5D , -44.5D );
GLUtils .glEnd ();
GLUtils .glDisable (GLUtils .GL_BLEND );
GLUtils .glEnable (GLUtils .GL_TEXTURE_2D );
drawRadarIcons ();
GL11 .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
drawTriangle (0 , 0 , Color .WHITE );
GL11 .glScalef (2.0F , 2.0F , 2.0F );
GL11 .glPopMatrix ();
GLUtils .glScalef (2.0F , 2.0F , 2.0F );
GLUtils .glPopMatrix ();
}
private void drawCircle (int x , int y , double radius , Color c , boolean filled ) {
GL11 .glEnable (3042 );
GL11 .glDisable (GL11 .GL_TEXTURE_2D );
GL11 .glEnable (2848 );
GL11 .glBlendFunc (770 , 771 );
GL11 .glColor4f (c .getRed () / 255.0F , c .getGreen () / 255.0F , c .getBlue () / 255.0F , filled ? config .getRadarOpacity () : config .getRadarOpacity () + 0.5F );
GL11 .glBegin (filled ? 6 : 2 );
GLUtils .glEnable (3042 );
GLUtils .glDisable (GLUtils .GL_TEXTURE_2D );
GLUtils .glEnable (2848 );
GLUtils .glBlendFunc (770 , 771 );
GLUtils .glColor4f (c .getRed () / 255.0F , c .getGreen () / 255.0F , c .getBlue () / 255.0F , filled ? config .getRadarOpacity () : config .getRadarOpacity () + 0.5F );
GLUtils .glBegin (filled ? 6 : 2 );
for (int i = 0 ; i <= 360 ; i ++) {
double x2 = Math .sin (i * Math .PI / 180.0D ) * radius ;
double y2 = Math .cos (i * Math .PI / 180.0D ) * radius ;
GL11 .glVertex2d (x + x2 , y + y2 );
GLUtils .glVertex2d (x + x2 , y + y2 );
}
GL11 .glEnd ();
GL11 .glDisable (2848 );
GL11 .glEnable (GL11 .GL_TEXTURE_2D );
GL11 .glDisable (3042 );
GLUtils .glEnd ();
GLUtils .glDisable (2848 );
GLUtils .glEnable (GLUtils .GL_TEXTURE_2D );
GLUtils .glDisable (3042 );
}
private void drawTriangle (int x , int y , Color c ) {
GL11 .glRotatef (180.0F , 0.0F , 0.0F , 1.0F );
GL11 .glColor4f (c .getRed () / 255.0F , c .getGreen () / 255.0F , c .getBlue () / 255.0F , 1.0F );
GL11 .glEnable (3042 );
GL11 .glDisable (3553 );
GL11 .glEnable (2848 );
GL11 .glBlendFunc (770 , 771 );
GL11 .glBegin (4 );
GL11 .glVertex2d (x , y + 3 );
GL11 .glVertex2d (x + 3 , y - 3 );
GL11 .glVertex2d (x - 3 , y - 3 );
GL11 .glEnd ();
GL11 .glDisable (2848 );
GL11 .glEnable (3553 );
GL11 .glDisable (3042 );
GL11 .glRotatef (-180.0F , 0.0F , 0.0F , 1.0F );
GLUtils .glRotatef (180.0F , 0.0F , 0.0F , 1.0F );
GLUtils .glColor4f (c .getRed () / 255.0F , c .getGreen () / 255.0F , c .getBlue () / 255.0F , 1.0F );
GLUtils .glEnable (3042 );
GLUtils .glDisable (3553 );
GLUtils .glEnable (2848 );
GLUtils .glBlendFunc (770 , 771 );
GLUtils .glBegin (4 );
GLUtils .glVertex2d (x , y + 3 );
GLUtils .glVertex2d (x + 3 , y - 3 );
GLUtils .glVertex2d (x - 3 , y - 3 );
GLUtils .glEnd ();
GLUtils .glDisable (2848 );
GLUtils .glEnable (3553 );
GLUtils .glDisable (3042 );
GLUtils .glRotatef (-180.0F , 0.0F , 0.0F , 1.0F );
}
private void drawRadarIcons () {
@@ -213,63 +237,63 @@ private void drawRadarIcons() {
}
private void renderItemIcon (int x , int y , ItemStack item ) {
GL11 .glPushMatrix ();
GL11 .glScalef (0.5F , 0.5F , 0.5F );
GL11 .glTranslatef (x +1 , y +1 , 0.0F );
GL11 .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GL11 .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glPushMatrix ();
GLUtils .glScalef (0.5F , 0.5F , 0.5F );
GLUtils .glTranslatef (x +1 , y +1 , 0.0F );
GLUtils .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GLUtils .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
mc .getRenderItem ().renderItemIntoGUI (item , -8 , -8 );
GL11 .glTranslatef (-x -1 , -y -1 , 0.0F );
GL11 .glScalef (2.0F , 2.0F , 2.0F );
GL11 .glDisable (2896 );
GL11 .glPopMatrix ();
GLUtils .glTranslatef (-x -1 , -y -1 , 0.0F );
GLUtils .glScalef (2.0F , 2.0F , 2.0F );
GLUtils .glDisable (2896 );
GLUtils .glPopMatrix ();
}
private void renderPlayerHeadIcon (int x , int y , EntityOtherPlayerMP player ) throws Exception {
GL11 .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GL11 .glEnable (3042 );
GL11 .glPushMatrix ();
GL11 .glScalef (0.5F , 0.5F , 0.5F );
GL11 .glTranslatef (x + 1 , y + 1 , 0.0F );
GL11 .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GLUtils .glEnable (3042 );
GLUtils .glPushMatrix ();
GLUtils .glScalef (0.5F , 0.5F , 0.5F );
GLUtils .glTranslatef (x + 1 , y + 1 , 0.0F );
GLUtils .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
mc .getTextureManager ().bindTexture (new ResourceLocation ("civRadar/icons/player.png" ));
drawModalRectWithCustomSizedTexture (-8 , -8 , 0 , 0 , 16 , 16 , 16 , 16 );
GL11 .glTranslatef (-x -1 , -y -1 , 0.0F );
GL11 .glScalef (2.0F , 2.0F , 2.0F );
GL11 .glDisable (2896 );
GL11 .glDisable (3042 );
GL11 .glPopMatrix ();
GLUtils .glTranslatef (-x -1 , -y -1 , 0.0F );
GLUtils .glScalef (2.0F , 2.0F , 2.0F );
GLUtils .glDisable (2896 );
GLUtils .glDisable (3042 );
GLUtils .glPopMatrix ();
if (config .isPlayerNames ()) {
GL11 .glPushMatrix ();
GL11 .glScalef (0.5F , 0.5F , 0.5F );
GL11 .glTranslatef (x , y , 0.0F );
GL11 .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GL11 .glTranslatef (-x , -y , 0.0F );
GLUtils .glPushMatrix ();
GLUtils .glScalef (0.5F , 0.5F , 0.5F );
GLUtils .glTranslatef (x , y , 0.0F );
GLUtils .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glTranslatef (-x , -y , 0.0F );
String playerName = player .getName ();
if (config .isExtraPlayerInfo ()) {
playerName += " (" + (int ) mc .thePlayer .getDistanceToEntity (player ) + "m)(Y" + (int ) player .posY + ")" ;
}
int yOffset = config .getNameLocation () == NameLocation .below ? 10 : -10 ;
drawCenteredString (mc .fontRendererObj , playerName , x + 8 , y + yOffset , Color .WHITE .getRGB ());
GL11 .glScalef (2.0F , 2.0F , 2.0F );
GL11 .glPopMatrix ();
GLUtils .glScalef (2.0F , 2.0F , 2.0F );
GLUtils .glPopMatrix ();
}
}
private void renderIcon (int x , int y , ResourceLocation resource ) {
mc .getTextureManager ().bindTexture (resource );
GL11 .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GL11 .glEnable (3042 );
GL11 .glPushMatrix ();
GL11 .glScalef (0.5F , 0.5F , 0.5F );
GL11 .glTranslatef (x + 1 , y + 1 , 0.0F );
GL11 .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
GLUtils .glColor4f (1.0F , 1.0F , 1.0F , config .getRadarOpacity () + 0.5F );
GLUtils .glEnable (3042 );
GLUtils .glPushMatrix ();
GLUtils .glScalef (0.5F , 0.5F , 0.5F );
GLUtils .glTranslatef (x + 1 , y + 1 , 0.0F );
GLUtils .glRotatef (mc .thePlayer .rotationYaw , 0.0F , 0.0F , 1.0F );
drawModalRectWithCustomSizedTexture (-8 , -8 , 0 , 0 , 16 , 16 , 16 , 16 );
GL11 .glTranslatef (-x -1 , -y -1 , 0.0F );
GL11 .glScalef (2.0F , 2.0F , 2.0F );
GL11 .glDisable (2896 );
GL11 .glDisable (3042 );
GL11 .glPopMatrix ();
GLUtils .glTranslatef (-x -1 , -y -1 , 0.0F );
GLUtils .glScalef (2.0F , 2.0F , 2.0F );
GLUtils .glDisable (2896 );
GLUtils .glDisable (3042 );
GLUtils .glPopMatrix ();
}
private void renderWaypoint (Waypoint point , RenderWorldLastEvent event ) {
@@ -293,22 +317,22 @@ private void renderWaypoint(Waypoint point, RenderWorldLastEvent event) {
float scale = (float ) (Math .max (2 , distance /5 ) * 0.0185f );
GL11 .glColor4f (1f , 1f , 1f , 1f );
GL11 .glPushMatrix ();
GL11 .glTranslatef (displayX , displayY , displayZ );
GL11 .glRotatef (-rm .playerViewY , 0.0F , 1.0F , 0.0F );
GL11 .glRotatef (rm .playerViewX , 1.0F , 0.0F , 0.0F );
GL11 .glScalef (-scale , -scale , scale );
GL11 .glDisable (GL11 .GL_LIGHTING );
GL11 .glDepthMask (false );
GL11 .glDisable (GL11 .GL_DEPTH_TEST );
GL11 .glEnable (GL11 .GL_BLEND );
GL11 .glBlendFunc (GL11 .GL_SRC_ALPHA , GL11 .GL_ONE_MINUS_SRC_ALPHA );
GLUtils .glColor4f (1f , 1f , 1f , 1f );
GLUtils .glPushMatrix ();
GLUtils .glTranslatef (displayX , displayY , displayZ );
GLUtils .glRotatef (-rm .playerViewY , 0.0F , 1.0F , 0.0F );
GLUtils .glRotatef (rm .playerViewX , 1.0F , 0.0F , 0.0F );
GLUtils .glScalef (-scale , -scale , scale );
GLUtils .glDisable (GLUtils .GL_LIGHTING );
GLUtils .glDepthMask (false );
GLUtils .glDisable (GLUtils .GL_DEPTH_TEST );
GLUtils .glEnable (GLUtils .GL_BLEND );
GLUtils .glBlendFunc (GLUtils .GL_SRC_ALPHA , GLUtils .GL_ONE_MINUS_SRC_ALPHA );
name += " (" + (int )distance + "m)" ;
int width = fr .getStringWidth (name );
int height = 10 ;
GL11 .glDisable (GL11 .GL_TEXTURE_2D );
GLUtils .glDisable (GLUtils .GL_TEXTURE_2D );
wr .startDrawingQuads ();
int stringMiddle = width / 2 ;
wr .setColorRGBA_F (c .getRed () / 255.0F , c .getGreen () / 255.0F , c .getBlue () / 255.0F , config .getWaypointOpcaity ());
@@ -317,13 +341,13 @@ private void renderWaypoint(Waypoint point, RenderWorldLastEvent event) {
wr .addVertex (stringMiddle + 1 , 1 + height , 0.0D );
wr .addVertex (stringMiddle + 1 , -1 , 0.0D );
tess .draw ();
GL11 .glEnable (GL11 .GL_TEXTURE_2D );
GLUtils .glEnable (GLUtils .GL_TEXTURE_2D );
fr .drawString (name , -width / 2 , 1 , Color .WHITE .getRGB ());
GL11 .glColor4f (1.0F , 1.0F , 1.0F , 1.0F );
GL11 .glDepthMask (true );
GL11 .glEnable (GL11 .GL_DEPTH_TEST );
GL11 .glPopMatrix ();
GLUtils .glColor4f (1.0F , 1.0F , 1.0F , 1.0F );
GLUtils .glDepthMask (true );
GLUtils .glEnable (GLUtils .GL_DEPTH_TEST );
GLUtils .glPopMatrix ();
}
}
}