Client-side multiplayer bugs, fix compass texture

This commit is contained in:
PeytonPlayz595 2024-04-27 14:50:15 -04:00
parent 39b23c9949
commit f734fb3059
12 changed files with 306 additions and 458 deletions

View File

@ -757,8 +757,7 @@ public class EaglerAdapterImpl2 {
try {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(data));
int[] pxls = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
IntBuffer buffer = IntBuffer.wrap(pxls);
return new EaglerImage(buffer, img.getWidth(), img.getHeight(), true);
return new EaglerImage(img.getWidth(), img.getHeight(), pxls, true);
} catch (IOException e) {
System.err.println("Could not load PNG file:");
e.printStackTrace();
@ -917,6 +916,10 @@ public class EaglerAdapterImpl2 {
}));
}
public static String forcedUser = null;
public static String forcedServer = null;
public static boolean joinServerOnLaunch = false;
public static final void destroyContext() {
Display.destroy();
Keyboard.destroy();

View File

@ -334,10 +334,10 @@ public class Tessellator {
*/
public void setNormal(float par1, float par2, float par3) {
this.hasNormals = true;
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
int var4 = (int) ((par1 / len) * 127.0F) + 127;
int var5 = (int) ((par2 / len) * 127.0F) + 127;
int var6 = (int) ((par3 / len) * 127.0F) + 127;
//float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
int var4 = (int) ((par1) * 127.0F) + 127;
int var5 = (int) ((par2) * 127.0F) + 127;
int var6 = (int) ((par3) * 127.0F) + 127;
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
}

View File

@ -580,6 +580,11 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
_wglBindTexture(_wGL_TEXTURE_2D, t);
}
public static final void glBindTexture(int p2) {
TextureGL t = texObjects.get(p2);
_wglBindTexture(_wGL_TEXTURE_2D, t);
}
public static final void glBindTexture(int p1, TextureGL p2) {
_wglBindTexture(_wGL_TEXTURE_2D, p2);
}

View File

@ -1,55 +1,59 @@
package net.lax1dude.eaglercraft;
import java.nio.IntBuffer;
public class EaglerImage {
public final IntBuffer data;
public final int[] data;
public final int w;
public final int h;
public final boolean alpha;
private final int wh;
public EaglerImage(int pw, int ph, boolean palpha) {
this.w = pw;
this.h = ph;
this.alpha = palpha;
this.data = IntBuffer.allocate(pw * ph);
this.wh = pw * ph;
public EaglerImage(int width, int height, int[] pixels, boolean alpha) {
this.w = width;
this.h = height;
this.data = pixels;
this.alpha = alpha;
}
public EaglerImage(IntBuffer pdata, int pw, int ph, boolean palpha) {
if (pdata.capacity() != pw * ph) {
throw new IllegalArgumentException("buffer capacity does not equal image size");
}
w = pw;
h = ph;
alpha = palpha;
wh = pw * ph;
if (!alpha) {
for (int i = 0; i < wh; ++i) {
pdata.put(i, pdata.get(i) | 0xFF000000);
}
pdata.rewind();
}
data = pdata;
public EaglerImage(int width, int height, boolean alpha) {
this.w = width;
this.h = height;
this.data = new int[width * height];
this.alpha = alpha;
}
public EaglerImage getSubImage(int x, int y, int pw, int ph) {
int start = y * w + x;
IntBuffer subBuffer = data.slice();
subBuffer.position(start);
subBuffer.limit(start + pw * ph);
int[] temp = new int[pw * ph];
subBuffer.get(temp);
IntBuffer newBuffer = IntBuffer.wrap(temp);
return new EaglerImage(newBuffer, pw, ph, alpha);
int[] img = new int[pw * ph];
for(int i = 0; i < ph; ++i) {
System.arraycopy(data, (i + y) * this.w + x, img, i * pw, pw);
}
return new EaglerImage(pw, ph, img, alpha);
}
public int[] data() {
int[] array = new int[wh];
data.rewind();
data.get(array);
return array;
return this.data;
}
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
if (startX < 0 || startY < 0 || w <= 0 || h <= 0 ||
startX + w > this.w || startY + h > this.h ||
rgbArray.length < offset + w * h) {
throw new IllegalArgumentException("Suck my dick nigga");
}
for (int y = startY; y < startY + h; y++) {
for (int x = startX; x < startX + w; x++) {
int imageDataIndex = y * this.w + x;
int argb = data[imageDataIndex];
int alpha = (argb >> 24) & 0xff;
int red = (argb >> 16) & 0xff;
int green = (argb >> 8) & 0xff;
int blue = argb & 0xff;
int rgb = (alpha << 24) | (red << 16) | (green << 8) | blue;
rgbArray[offset + (y - startY) * scansize + (x - startX)] = rgb;
}
}
return rgbArray;
}
}

View File

@ -1,17 +1,24 @@
package net.minecraft.src;
import net.PeytonPlayz585.opengl.GL11;
import net.lax1dude.eaglercraft.EaglerImage;
public class ColorizerFoliage {
private static int field_6529_a[] = null;
private static final int[] field_6529_a = new int[65536];
public static int func_4146_a(double var0, double var2) {
if(field_6529_a == null) {
field_6529_a = GL11.loadPNG(GL11.loadResourceBytes("/misc/foliagecolor.png")).data();
}
var2 *= var0;
int var4 = (int)((1.0D - var0) * 255.0D);
int var5 = (int)((1.0D - var2) * 255.0D);
return field_6529_a[var5 << 8 | var4];
}
static {
try {
EaglerImage var0 = GL11.loadPNG(GL11.loadResourceBytes("/misc/foliagecolor.png"));
var0.getRGB(0, 0, 256, 256, field_6529_a, 0, 256);
} catch (Exception var1) {
var1.printStackTrace();
}
}
}

View File

@ -1,17 +1,25 @@
package net.minecraft.src;
import net.PeytonPlayz585.opengl.GL11;
import net.lax1dude.eaglercraft.EaglerImage;
public class ColorizerGrass {
private static int[] field_6540_a = null;
private static final int[] field_6540_a = new int[65536];
public static int func_4147_a(double var0, double var2) {
if(field_6540_a == null) {
field_6540_a = GL11.loadPNG(GL11.loadResourceBytes("/misc/grasscolor.png")).data();
}
var2 *= var0;
int var4 = (int)((1.0D - var0) * 255.0D);
int var5 = (int)((1.0D - var2) * 255.0D);
return field_6540_a[var5 << 8 | var4];
}
static {
try {
EaglerImage var0 = GL11.loadPNG(GL11.loadResourceBytes("/misc/grasscolor.png"));
var0.getRGB(0, 0, 256, 256, field_6540_a, 0, 256);
} catch (Exception var1) {
var1.printStackTrace();
}
}
}

View File

@ -176,10 +176,14 @@ public class NetworkManager {
oldChunkBuffer = null;
}
} else {
}
if(this.timeSinceLastRead++ == 1200) {
this.networkShutdown("Timed out");
}
if(!isConnectionOpen() && !this.isTerminating) {
this.networkShutdown("Lost connection!");
}
if(this.isTerminating && this.readChunks.isEmpty()) {
@ -207,14 +211,14 @@ public class NetworkManager {
return var0.isRunning;
}
static boolean isConnectionOpen() {
return GL11.connectionOpen();
}
static boolean isServerTerminating(NetworkManager var0) {
return var0.isServerTerminating;
}
// static void readNetworkPacket(NetworkManager var0) {
// var0.readPacket();
// }
static void sendNetworkPacket(NetworkManager var0) {
var0.sendPacket();
}

View File

@ -18,7 +18,6 @@ public class RenderEngine {
textureNameToImageMap = new HashMap<Integer, EaglerImage>();
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000);
textureList = new ArrayList<TextureFX>();
clampTexture = false;
blurTexture = false;
@ -47,6 +46,7 @@ public class RenderEngine {
blurTexture = false;
} else {
setupTexture(readTextureImage(var2.func_6481_a(s)), i);
useMipmaps = false;
}
textureMap.put(s, Integer.valueOf(i));
return i;
@ -81,12 +81,13 @@ public class RenderEngine {
public void setupTexture(EaglerImage bufferedimage, int i) {
bindTexture(i);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4);
if (blurTexture) {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9729 /* GL_LINEAR */);
if (useMipmaps) {
GL11.glTexParameteri(3553, 10241, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL11.glTexParameteri(3553, 10240, GL11.GL_NEAREST);
GL11.glTexParameteri(3553, GL11.GL_TEXTURE_MAX_LEVEL, 4);
} else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
}
if (clampTexture) {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10496 /* GL_CLAMP */);
@ -122,28 +123,6 @@ public class RenderEngine {
imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
for (int i1 = 1; i1 <= 4; i1++) {
int k1 = j >> i1 - 1;
int i2 = j >> i1;
int k2 = k >> i1;
imageDataB2.clear();
for (int i3 = 0; i3 < i2; i3++) {
for (int k3 = 0; k3 < k2; k3++) {
int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4);
int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4);
int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4);
int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4);
int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5));
imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
}
}
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
ByteBuffer tmp = imageDataB1;
imageDataB1 = imageDataB2;
imageDataB2 = tmp;
}
}
public void deleteTexture(int i) {
@ -234,12 +213,12 @@ public class RenderEngine {
}
public static boolean useMipmaps = false;
private static HashMap<String, Integer> textureMap;
private TexturePackList field_6527_k;
private HashMap<Integer, EaglerImage> textureNameToImageMap;
public IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
private GameSettings options;
private boolean clampTexture;

View File

@ -1,87 +0,0 @@
//package net.minecraft.src;
//
//import java.awt.image.BufferedImage;
//import java.io.IOException;
//import java.util.Arrays;
//import javax.imageio.ImageIO;
//
//public class TerrainTextureManager {
// private float[] field_1181_a = new float[768];
// private int[] field_1180_b = new int[5120];
// private int[] field_1186_c = new int[5120];
// private int[] field_1185_d = new int[5120];
// private int[] field_1184_e = new int[5120];
// private int[] field_1183_f = new int[34];
// private int[] field_1182_g = new int[768];
//
// public TerrainTextureManager() {
// try {
// BufferedImage var1 = ImageIO.read(TerrainTextureManager.class.getResource("/terrain.png"));
// int[] var2 = new int[65536];
// var1.getRGB(0, 0, 256, 256, var2, 0, 256);
//
// for(int var3 = 0; var3 < 256; ++var3) {
// int var4 = 0;
// int var5 = 0;
// int var6 = 0;
// int var7 = var3 % 16 * 16;
// int var8 = var3 / 16 * 16;
// int var9 = 0;
//
// for(int var10 = 0; var10 < 16; ++var10) {
// for(int var11 = 0; var11 < 16; ++var11) {
// int var12 = var2[var11 + var7 + (var10 + var8) * 256];
// int var13 = var12 >> 24 & 255;
// if(var13 > 128) {
// var4 += var12 >> 16 & 255;
// var5 += var12 >> 8 & 255;
// var6 += var12 & 255;
// ++var9;
// }
// }
//
// if(var9 == 0) {
// ++var9;
// }
//
// this.field_1181_a[var3 * 3 + 0] = (float)(var4 / var9);
// this.field_1181_a[var3 * 3 + 1] = (float)(var5 / var9);
// this.field_1181_a[var3 * 3 + 2] = (float)(var6 / var9);
// }
// }
// } catch (IOException var14) {
// var14.printStackTrace();
// }
//
// for(int var15 = 0; var15 < 256; ++var15) {
// if(Block.blocksList[var15] != null) {
// this.field_1182_g[var15 * 3 + 0] = Block.blocksList[var15].getBlockTextureFromSide(1);
// this.field_1182_g[var15 * 3 + 1] = Block.blocksList[var15].getBlockTextureFromSide(2);
// this.field_1182_g[var15 * 3 + 2] = Block.blocksList[var15].getBlockTextureFromSide(3);
// }
// }
//
// }
//
// private void func_800_a() {
// for(int var1 = 0; var1 < 32; ++var1) {
// for(int var2 = 0; var2 < 160; ++var2) {
// int var3 = var1 + var2 * 32;
// if(this.field_1186_c[var3] == 0) {
// this.field_1180_b[var3] = 0;
// }
//
// if(this.field_1185_d[var3] > this.field_1186_c[var3]) {
// int var4 = this.field_1180_b[var3] >> 24 & 255;
// this.field_1180_b[var3] = ((this.field_1180_b[var3] & 16711422) >> 1) + this.field_1184_e[var3];
// if(var4 < 128) {
// this.field_1180_b[var3] = Integer.MIN_VALUE + this.field_1184_e[var3] * 2;
// } else {
// this.field_1180_b[var3] |= -16777216;
// }
// }
// }
// }
//
// }
//}

View File

@ -1,228 +1,140 @@
//package net.minecraft.src;
//
//import java.awt.image.BufferedImage;
//import java.io.IOException;
//import javax.imageio.ImageIO;
//import net.minecraft.client.Minecraft;
//
//public class TextureCompassFX extends TextureFX {
// private Minecraft mc;
// private int[] field_4230_h = new int[256];
// private double field_4229_i;
// private double field_4228_j;
//
// public TextureCompassFX(Minecraft var1) {
// super(Item.compass.getIconIndex((ItemStack)null));
// this.mc = var1;
// this.field_1128_f = 1;
//
// try {
// BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
// int var3 = this.field_1126_b % 16 * 16;
// int var4 = this.field_1126_b / 16 * 16;
// var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
// } catch (IOException var5) {
// var5.printStackTrace();
// }
//
// }
//
// public void func_783_a() {
// for(int var1 = 0; var1 < 256; ++var1) {
// int var2 = this.field_4230_h[var1] >> 24 & 255;
// int var3 = this.field_4230_h[var1] >> 16 & 255;
// int var4 = this.field_4230_h[var1] >> 8 & 255;
// int var5 = this.field_4230_h[var1] >> 0 & 255;
// if(this.field_1131_c) {
// int var6 = (var3 * 30 + var4 * 59 + var5 * 11) / 100;
// int var7 = (var3 * 30 + var4 * 70) / 100;
// int var8 = (var3 * 30 + var5 * 70) / 100;
// var3 = var6;
// var4 = var7;
// var5 = var8;
// }
//
// this.field_1127_a[var1 * 4 + 0] = (byte)var3;
// this.field_1127_a[var1 * 4 + 1] = (byte)var4;
// this.field_1127_a[var1 * 4 + 2] = (byte)var5;
// this.field_1127_a[var1 * 4 + 3] = (byte)var2;
// }
//
// double var20 = 0.0D;
// double var21;
// double var22;
// if(this.mc.theWorld != null && this.mc.thePlayer != null) {
// var21 = (double)this.mc.theWorld.spawnX - this.mc.thePlayer.posX;
// var22 = (double)this.mc.theWorld.spawnZ - this.mc.thePlayer.posZ;
// var20 = (double)(this.mc.thePlayer.rotationYaw - 90.0F) * Math.PI / 180.0D - Math.atan2(var22, var21);
// if(this.mc.theWorld.worldProvider.field_4220_c) {
// var20 = Math.random() * (double)((float)Math.PI) * 2.0D;
// }
// }
//
// for(var21 = var20 - this.field_4229_i; var21 < -Math.PI; var21 += Math.PI * 2.0D) {
// }
//
// while(var21 >= Math.PI) {
// var21 -= Math.PI * 2.0D;
// }
//
// if(var21 < -1.0D) {
// var21 = -1.0D;
// }
//
// if(var21 > 1.0D) {
// var21 = 1.0D;
// }
//
// this.field_4228_j += var21 * 0.1D;
// this.field_4228_j *= 0.8D;
// this.field_4229_i += this.field_4228_j;
// var22 = Math.sin(this.field_4229_i);
// double var23 = Math.cos(this.field_4229_i);
//
// int var9;
// int var10;
// int var11;
// int var12;
// int var13;
// int var14;
// int var15;
// short var16;
// int var17;
// int var18;
// int var19;
// for(var9 = -4; var9 <= 4; ++var9) {
// var10 = (int)(8.5D + var23 * (double)var9 * 0.3D);
// var11 = (int)(7.5D - var22 * (double)var9 * 0.3D * 0.5D);
// var12 = var11 * 16 + var10;
// var13 = 100;
// var14 = 100;
// var15 = 100;
// var16 = 255;
// if(this.field_1131_c) {
// var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
// var18 = (var13 * 30 + var14 * 70) / 100;
// var19 = (var13 * 30 + var15 * 70) / 100;
// var13 = var17;
// var14 = var18;
// var15 = var19;
// }
//
// this.field_1127_a[var12 * 4 + 0] = (byte)var13;
// this.field_1127_a[var12 * 4 + 1] = (byte)var14;
// this.field_1127_a[var12 * 4 + 2] = (byte)var15;
// this.field_1127_a[var12 * 4 + 3] = (byte)var16;
// }
//
// for(var9 = -8; var9 <= 16; ++var9) {
// var10 = (int)(8.5D + var22 * (double)var9 * 0.3D);
// var11 = (int)(7.5D + var23 * (double)var9 * 0.3D * 0.5D);
// var12 = var11 * 16 + var10;
// var13 = var9 >= 0 ? 255 : 100;
// var14 = var9 >= 0 ? 20 : 100;
// var15 = var9 >= 0 ? 20 : 100;
// var16 = 255;
// if(this.field_1131_c) {
// var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
// var18 = (var13 * 30 + var14 * 70) / 100;
// var19 = (var13 * 30 + var15 * 70) / 100;
// var13 = var17;
// var14 = var18;
// var15 = var19;
// }
//
// this.field_1127_a[var12 * 4 + 0] = (byte)var13;
// this.field_1127_a[var12 * 4 + 1] = (byte)var14;
// this.field_1127_a[var12 * 4 + 2] = (byte)var15;
// this.field_1127_a[var12 * 4 + 3] = (byte)var16;
// }
//
// }
//}
package net.minecraft.src;
import java.io.IOException;
import net.PeytonPlayz585.opengl.GL11;
import net.lax1dude.eaglercraft.EaglerImage;
import net.minecraft.client.Minecraft;
public class TextureCompassFX extends TextureFX {
private final int[] compassSpriteSheet;
private final int compassSpriteSheetLength;
private float angleDelta = 0.0f;
private float currentAngle = 0.0f;
private Minecraft mc;
private int[] field_4230_h = new int[256];
private double field_4229_i;
private double field_4228_j;
public TextureCompassFX(Minecraft var1) {
super(Item.compass.getIconIndex(null));
field_1128_f = 1;
this.compassSpriteSheet = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png")).data();
this.compassSpriteSheetLength = compassSpriteSheet.length / 256;
super(Item.compass.getIconIndex((ItemStack)null));
this.mc = var1;
this.field_1128_f = 1;
try {
EaglerImage var2 = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png"));
int var3 = this.field_1126_b % 16 * 16;
int var4 = this.field_1126_b / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
} catch (Exception var5) {
var5.printStackTrace();
}
}
public void func_783_a() {
Minecraft var1 = Minecraft.getMinecraft();
if (var1.theWorld != null && var1.thePlayer != null) {
this.updateCompass(var1.theWorld, var1.thePlayer.posX, var1.thePlayer.posZ, (double) var1.thePlayer.rotationYaw, false, false);
} else {
this.updateCompass((World) null, 0.0D, 0.0D, 0.0D, true, false);
for(int var1 = 0; var1 < 256; ++var1) {
int var2 = this.field_4230_h[var1] >> 24 & 255;
int var3 = this.field_4230_h[var1] >> 16 & 255;
int var4 = this.field_4230_h[var1] >> 8 & 255;
int var5 = this.field_4230_h[var1] >> 0 & 255;
if(this.field_1131_c) {
int var6 = (var3 * 30 + var4 * 59 + var5 * 11) / 100;
int var7 = (var3 * 30 + var4 * 70) / 100;
int var8 = (var3 * 30 + var5 * 70) / 100;
var3 = var6;
var4 = var7;
var5 = var8;
}
this.field_1127_a[var1 * 4 + 0] = (byte)var3;
this.field_1127_a[var1 * 4 + 1] = (byte)var4;
this.field_1127_a[var1 * 4 + 2] = (byte)var5;
this.field_1127_a[var1 * 4 + 3] = (byte)var2;
}
double var20 = 0.0D;
double var21;
double var22;
if(this.mc.theWorld != null && this.mc.thePlayer != null) {
var21 = (double)this.mc.theWorld.spawnX - this.mc.thePlayer.posX;
var22 = (double)this.mc.theWorld.spawnZ - this.mc.thePlayer.posZ;
var20 = (double)(this.mc.thePlayer.rotationYaw - 90.0F) * Math.PI / 180.0D - Math.atan2(var22, var21);
if(this.mc.theWorld.worldProvider.field_4220_c) {
var20 = Math.random() * (double)((float)Math.PI) * 2.0D;
}
}
public void updateCompass(World par1World, double par2, double par4, double par6, boolean par8, boolean par9) {
double var10 = 0.0D;
if (par1World != null && !par8) {
double var13 = (double)par1World.spawnX - par2;
double var15 = (double)par1World.spawnZ - par4;
par6 %= 360.0D;
var10 = -((par6 - 90.0D) * Math.PI / 180.0D - Math.atan2(var15, var13));
if (!par1World.worldProvider.field_4220_c) {
var10 = Math.random() * Math.PI * 2.0D;
}
for(var21 = var20 - this.field_4229_i; var21 < -Math.PI; var21 += Math.PI * 2.0D) {
}
if (par9) {
this.currentAngle = (float) var10;
} else {
double var17;
for (var17 = var10 - this.currentAngle; var17 < -Math.PI; var17 += (Math.PI * 2D)) {
;
while(var21 >= Math.PI) {
var21 -= Math.PI * 2.0D;
}
while (var17 >= Math.PI) {
var17 -= (Math.PI * 2D);
if(var21 < -1.0D) {
var21 = -1.0D;
}
if (var17 < -1.0D) {
var17 = -1.0D;
if(var21 > 1.0D) {
var21 = 1.0D;
}
if (var17 > 1.0D) {
var17 = 1.0D;
}
this.angleDelta += var17 * 0.1D;
this.angleDelta *= 0.8D;
this.currentAngle += this.angleDelta;
}
this.field_4228_j += var21 * 0.1D;
this.field_4228_j *= 0.8D;
this.field_4229_i += this.field_4228_j;
var22 = Math.sin(this.field_4229_i);
double var23 = Math.cos(this.field_4229_i);
int var9;
int var10;
int var11;
int var12;
int var13;
int var14;
int var15;
short var16;
int var17;
int var18;
for (var18 = (int) ((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double) compassSpriteSheetLength) % compassSpriteSheetLength; var18 < 0; var18 = (var18 + compassSpriteSheetLength) % compassSpriteSheetLength) {
;
int var19;
for(var9 = -4; var9 <= 4; ++var9) {
var10 = (int)(8.5D + var23 * (double)var9 * 0.3D);
var11 = (int)(7.5D - var22 * (double)var9 * 0.3D * 0.5D);
var12 = var11 * 16 + var10;
var13 = 100;
var14 = 100;
var15 = 100;
var16 = 255;
if(this.field_1131_c) {
var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
var18 = (var13 * 30 + var14 * 70) / 100;
var19 = (var13 * 30 + var15 * 70) / 100;
var13 = var17;
var14 = var18;
var15 = var19;
}
int offset = var18 * 256;
for(int i = 0; i < 256; ++i) {
this.field_1127_a[i * 4] = (byte)((compassSpriteSheet[offset + i] >> 16) & 0xFF);
this.field_1127_a[i * 4 + 1] = (byte)((compassSpriteSheet[offset + i] >> 8) & 0xFF);
this.field_1127_a[i * 4 + 2] = (byte)((compassSpriteSheet[offset + i]) & 0xFF);
this.field_1127_a[i * 4 + 3] = (byte)((compassSpriteSheet[offset + i] >> 24) & 0xFF);
this.field_1127_a[var12 * 4 + 0] = (byte)var13;
this.field_1127_a[var12 * 4 + 1] = (byte)var14;
this.field_1127_a[var12 * 4 + 2] = (byte)var15;
this.field_1127_a[var12 * 4 + 3] = (byte)var16;
}
for(var9 = -8; var9 <= 16; ++var9) {
var10 = (int)(8.5D + var22 * (double)var9 * 0.3D);
var11 = (int)(7.5D + var23 * (double)var9 * 0.3D * 0.5D);
var12 = var11 * 16 + var10;
var13 = var9 >= 0 ? 255 : 100;
var14 = var9 >= 0 ? 20 : 100;
var15 = var9 >= 0 ? 20 : 100;
var16 = 255;
if(this.field_1131_c) {
var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
var18 = (var13 * 30 + var14 * 70) / 100;
var19 = (var13 * 30 + var15 * 70) / 100;
var13 = var17;
var14 = var18;
var15 = var19;
}
this.field_1127_a[var12 * 4 + 0] = (byte)var13;
this.field_1127_a[var12 * 4 + 1] = (byte)var14;
this.field_1127_a[var12 * 4 + 2] = (byte)var15;
this.field_1127_a[var12 * 4 + 3] = (byte)var16;
}
}
}

View File

@ -5,81 +5,94 @@ import net.lax1dude.eaglercraft.EaglerImage;
import net.minecraft.client.Minecraft;
public class TextureWatchFX extends TextureFX {
private Minecraft field_4225_g;
private int[] field_4224_h = new int[256];
private int[] field_4223_i = new int[256];
private double field_4222_j;
private double field_4221_k;
public TextureWatchFX(Minecraft var1) {
super(Item.pocketSundial.getIconIndex((ItemStack)null));
this.field_4225_g = var1;
this.field_1128_f = 1;
try {
EaglerImage var2 = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png"));
int var3 = this.field_1126_b % 16 * 16;
int var4 = this.field_1126_b / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.field_4224_h, 0, 16);
var2 = GL11.loadPNG(GL11.loadResourceBytes("/misc/dial.png"));
var2.getRGB(0, 0, 16, 16, this.field_4223_i, 0, 16);
} catch (Exception var5) {
var5.printStackTrace();
}
public TextureWatchFX(Minecraft minecraft) {
super(Item.pocketSundial.getIconIndex(null));
field_4224_h = new int[256];
field_4223_i = new int[256];
field_4225_g = minecraft;
field_1128_f = 1;
EaglerImage bufferedimage = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png"));
int i = (field_1126_b % 16) * 16;
int j = (field_1126_b / 16) * 16;
field_4224_h = bufferedimage.getSubImage(i, j, 16, 16).data();
field_4223_i = GL11.loadPNG(GL11.loadResourceBytes("/misc/dial.png")).data();
}
public void func_783_a() {
double d = 0.0D;
if (field_4225_g.theWorld != null && field_4225_g.thePlayer != null) {
float f = field_4225_g.theWorld.getCelestialAngle(1.0F);
d = -f * 3.141593F * 2.0F;
if (field_4225_g.theWorld.worldProvider.field_4220_c) {
d = Math.random() * 3.1415927410125732D * 2D;
double var1 = 0.0D;
if(this.field_4225_g.theWorld != null && this.field_4225_g.thePlayer != null) {
float var3 = this.field_4225_g.theWorld.getCelestialAngle(1.0F);
var1 = (double)(-var3 * (float)Math.PI * 2.0F);
if(this.field_4225_g.theWorld.worldProvider.field_4220_c) {
var1 = Math.random() * (double)((float)Math.PI) * 2.0D;
}
}
double d1;
for (d1 = d - field_4222_j; d1 < -3.1415926535897931D; d1 += 6.2831853071795862D) {
double var22;
for(var22 = var1 - this.field_4222_j; var22 < -Math.PI; var22 += Math.PI * 2.0D) {
}
for (; d1 >= 3.1415926535897931D; d1 -= 6.2831853071795862D) {
while(var22 >= Math.PI) {
var22 -= Math.PI * 2.0D;
}
if (d1 < -1D) {
d1 = -1D;
if(var22 < -1.0D) {
var22 = -1.0D;
}
if (d1 > 1.0D) {
d1 = 1.0D;
if(var22 > 1.0D) {
var22 = 1.0D;
}
field_4221_k += d1 * 0.10000000000000001D;
field_4221_k *= 0.80000000000000004D;
field_4222_j += field_4221_k;
double d2 = Math.sin(field_4222_j);
double d3 = Math.cos(field_4222_j);
for (int i = 0; i < 256; i++) {
int j = field_4224_h[i] >> 24 & 0xff;
int k = field_4224_h[i] >> 16 & 0xff;
int l = field_4224_h[i] >> 8 & 0xff;
int i1 = field_4224_h[i] >> 0 & 0xff;
if (k == i1 && l == 0 && i1 > 0) {
double d4 = -((double) (i % 16) / 15D - 0.5D);
double d5 = (double) (i / 16) / 15D - 0.5D;
int i2 = k;
int j2 = (int) ((d4 * d3 + d5 * d2 + 0.5D) * 16D);
int k2 = (int) (((d5 * d3 - d4 * d2) + 0.5D) * 16D);
int l2 = (j2 & 0xf) + (k2 & 0xf) * 16;
j = field_4223_i[l2] >> 24 & 0xff;
k = ((field_4223_i[l2] >> 16 & 0xff) * i2) / 255;
l = ((field_4223_i[l2] >> 8 & 0xff) * i2) / 255;
i1 = ((field_4223_i[l2] >> 0 & 0xff) * i2) / 255;
this.field_4221_k += var22 * 0.1D;
this.field_4221_k *= 0.8D;
this.field_4222_j += this.field_4221_k;
double var5 = Math.sin(this.field_4222_j);
double var7 = Math.cos(this.field_4222_j);
for(int var9 = 0; var9 < 256; ++var9) {
int var10 = this.field_4224_h[var9] >> 24 & 255;
int var11 = this.field_4224_h[var9] >> 16 & 255;
int var12 = this.field_4224_h[var9] >> 8 & 255;
int var13 = this.field_4224_h[var9] >> 0 & 255;
if(var11 == var13 && var12 == 0 && var13 > 0) {
double var14 = -((double)(var9 % 16) / 15.0D - 0.5D);
double var16 = (double)(var9 / 16) / 15.0D - 0.5D;
int var18 = var11;
int var19 = (int)((var14 * var7 + var16 * var5 + 0.5D) * 16.0D);
int var20 = (int)((var16 * var7 - var14 * var5 + 0.5D) * 16.0D);
int var21 = (var19 & 15) + (var20 & 15) * 16;
var10 = this.field_4223_i[var21] >> 24 & 255;
var11 = (this.field_4223_i[var21] >> 16 & 255) * var11 / 255;
var12 = (this.field_4223_i[var21] >> 8 & 255) * var18 / 255;
var13 = (this.field_4223_i[var21] >> 0 & 255) * var18 / 255;
}
if (field_1131_c) {
int j1 = (k * 30 + l * 59 + i1 * 11) / 100;
int k1 = (k * 30 + l * 70) / 100;
int l1 = (k * 30 + i1 * 70) / 100;
k = j1;
l = k1;
i1 = l1;
if(this.field_1131_c) {
int var23 = (var11 * 30 + var12 * 59 + var13 * 11) / 100;
int var15 = (var11 * 30 + var12 * 70) / 100;
int var24 = (var11 * 30 + var13 * 70) / 100;
var11 = var23;
var12 = var15;
var13 = var24;
}
field_1127_a[i * 4 + 0] = (byte) k;
field_1127_a[i * 4 + 1] = (byte) l;
field_1127_a[i * 4 + 2] = (byte) i1;
field_1127_a[i * 4 + 3] = (byte) j;
this.field_1127_a[var9 * 4 + 0] = (byte)var11;
this.field_1127_a[var9 * 4 + 1] = (byte)var12;
this.field_1127_a[var9 * 4 + 2] = (byte)var13;
this.field_1127_a[var9 * 4 + 3] = (byte)var10;
}
}
private Minecraft field_4225_g;
private int field_4224_h[];
private int field_4223_i[];
private double field_4222_j;
private double field_4221_k;
}