Fix some things

This commit is contained in:
PeytonPlayz595 2024-06-16 15:52:39 -04:00
parent 9817e91223
commit 444d395024
7 changed files with 84 additions and 110 deletions

View File

@ -0,0 +1,65 @@
package net.PeytonPlayz585.awt;
public class Color {
int value;
public Color(int rgb) {
value = 0xff000000 | rgb;
}
public static Color getHSBColor(float h, float s, float b) {
return new Color(HSBtoRGB(h, s, b));
}
public static int HSBtoRGB(float hue, float saturation, float brightness) {
int r = 0, g = 0, b = 0;
if (saturation == 0) {
r = g = b = (int)(brightness * 255.0f + 0.5f);
} else {
float h = (hue - (float) Math.floor(hue)) * 6.0f;
float f = h - (float) java.lang.Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
switch ((int) h) {
case 0:
r = (int)(brightness * 255.0f + 0.5f);
g = (int)(t * 255.0f + 0.5f);
b = (int)(p * 255.0f + 0.5f);
break;
case 1:
r = (int)(q * 255.0f + 0.5f);
g = (int)(brightness * 255.0f + 0.5f);
b = (int)(p * 255.0f + 0.5f);
break;
case 2:
r = (int)(p * 255.0f + 0.5f);
g = (int)(brightness * 255.0f + 0.5f);
b = (int)(t * 255.0f + 0.5f);
break;
case 3:
r = (int)(p * 255.0f + 0.5f);
g = (int)(q * 255.0f + 0.5f);
b = (int)(brightness * 255.0f + 0.5f);
break;
case 4:
r = (int)(t * 255.0f + 0.5f);
g = (int)(p * 255.0f + 0.5f);
b = (int)(brightness * 255.0f + 0.5f);
break;
case 5:
r = (int)(brightness * 255.0f + 0.5f);
g = (int)(p * 255.0f + 0.5f);
b = (int)(q * 255.0f + 0.5f);
break;
}
}
return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
}
public int getRGB() {
return value;
}
}

View File

@ -3,6 +3,8 @@ package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import net.PeytonPlayz585.awt.Color;
public class BiomeGenBase {
public static final BiomeGenBase rainforest = (new BiomeGenRainforest()).setColor(588342).setBiomeName("Rainforest").func_4124_a(2094168);
public static final BiomeGenBase swampland = (new BiomeGenSwamp()).setColor(522674).setBiomeName("Swampland").func_4124_a(9154376);
@ -103,7 +105,7 @@ public class BiomeGenBase {
var1 = 1.0F;
}
return getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F);
return Color.getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F).getRGB();
}
public List getSpawnableList(EnumCreatureType var1) {
@ -118,61 +120,6 @@ public class BiomeGenBase {
return this.enableSnow ? false : this.enableRain;
}
public static int getHSBColor(float hue, float saturation, float brightness) {
float r, g, b;
if (saturation == 0) {
r = g = b = brightness;
} else {
float h = (hue - (float) Math.floor(hue)) * 6.0f;
float f = h - (float) Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
int hi = (int) h;
switch (hi) {
case 0:
r = brightness;
g = t;
b = p;
break;
case 1:
r = q;
g = brightness;
b = p;
break;
case 2:
r = p;
g = brightness;
b = t;
break;
case 3:
r = p;
g = q;
b = brightness;
break;
case 4:
r = t;
g = p;
b = brightness;
break;
case 5:
r = brightness;
g = p;
b = q;
break;
default:
r = g = b = brightness;
break;
}
}
int red = Math.round(r * 255);
int green = Math.round(g * 255);
int blue = Math.round(b * 255);
return (255 << 24) | (red << 16) | (green << 8) | blue;
}
static {
generateBiomeLookup();
}

View File

@ -1,7 +1,9 @@
package net.minecraft.src;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
@ -160,8 +162,8 @@ public class FontRenderer {
this.buffer.flip();
while (buffer.hasRemaining()) {
int i = buffer.get();
if(colorList.containsKey(i)) {
Color3f color = colorList.get(i);
Color3f color = colorList.get(i);
if(color != null) {
GL11.glColor3f(color.r, color.g, color.b);
}
GL11.glCallList(i);
@ -181,8 +183,8 @@ public class FontRenderer {
this.buffer.flip();
while (buffer.hasRemaining()) {
int i = buffer.get();
if(colorList.containsKey(i)) {
Color3f color = colorList.get(i);
Color3f color = colorList.get(i);
if(color != null) {
GL11.glColor3f(color.r, color.g, color.b);
}
GL11.glCallList(i);
@ -194,8 +196,8 @@ public class FontRenderer {
this.buffer.flip();
while (buffer.hasRemaining()) {
int i = buffer.get();
if(colorList.containsKey(i)) {
Color3f color = colorList.get(i);
Color3f color = colorList.get(i);
if(color != null) {
GL11.glColor3f(color.r, color.g, color.b);
}
GL11.glCallList(i);

View File

@ -3,6 +3,7 @@ package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import net.PeytonPlayz585.awt.Color;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@ -193,7 +194,7 @@ public class GuiIngame extends Gui {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
var17 = 16777215;
if(this.field_22065_l) {
var17 = HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
var17 = Color.HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
}
var8.drawString(this.recordPlaying, -var8.getStringWidth(this.recordPlaying) / 2, -4, var17 + (var16 << 24));
@ -398,48 +399,6 @@ public class GuiIngame extends Gui {
this.addChatMessage(var3);
}
public static int HSBtoRGB(float hue, float saturation, float brightness) {
hue = (hue % 1f) + 1f;
saturation = Math.min(1f, Math.max(0f, saturation));
brightness = Math.min(1f, Math.max(0f, brightness));
float q = brightness < 0.5f ? brightness * (1f + saturation) : brightness + saturation - brightness * saturation;
float p = 2f * brightness - q;
float r, g, b;
if (hue < 1f/6f) {
r = q;
g = p + (q - p) * 6f * hue;
b = p;
} else if (hue < 2f/6f) {
r = p - (q - p) * 6f * (hue - 1f/6f);
g = q;
b = p;
} else if (hue < 3f/6f) {
r = p;
g = q - (q - p) * 6f * (hue - 2f/6f);
b = p - (q - p) * 6f * (hue - 2f/6f);
} else if (hue < 4f/6f) {
r = p;
g = p;
b = q - (q - p) * 6f * (hue - 3f/6f);
} else if (hue < 5f/6f) {
r = p + (q - p) * 6f * (hue - 4f/6f);
g = p;
b = q;
} else {
r = q;
g = p - (q - p) * 6f * (hue - 5f/6f);
b = p;
}
int red = (int) Math.max(0f, Math.min(255f, r * 255f));
int green = (int) Math.max(0f, Math.min(255f, g * 255f));
int blue = (int) Math.max(0f, Math.min(255f, b * 255f));
return (red << 16) | (green << 8) | blue;
}
public void renderCrossHairs(int w, int h) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/icons.png"));
GL11.glEnable(GL11.GL_TEXTURE_2D);

View File

@ -536,7 +536,7 @@ public class RenderGlobal implements IWorldAccess {
var14 = (float)var20 * (float)Math.PI * 2.0F / (float)var19;
float var15 = MathHelper.sin(var14);
float var16 = MathHelper.cos(var14);
var17.addVertex((double)(var15 * 120.0F), (double)(var16 * 120.0F), (double)(var16 * 40.0F * var18[3]));
var17.addVertex((double)(var15 * 120.0F), (double)(var16 * 120.0F), (double)(-var16 * 40.0F * var18[3]));
}
var17.draw();

View File

@ -59,8 +59,9 @@ public abstract class WorldProvider {
public float[] calcSunriseSunsetColors(float var1, float var2) {
float var3 = 0.4F;
float var4 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) - 0.0F;
if (var4 >= -var3 && var4 <= var3) {
float var6 = (var4 / var3) * 0.5F + 0.5F;
float var5 = 0F;
if(var4 >= var5 - var3 && var4 <= var5 + var3) {
float var6 = (var4 - var5) / var3 * 0.5F + 0.5F;
float var7 = 1.0F - (1.0F - MathHelper.sin(var6 * (float)Math.PI)) * 0.99F;
var7 *= var7;
this.colorsSunriseSunset[0] = var6 * 0.3F + 0.7F;