Made the world actually load

This commit is contained in:
PeytonPlayz595 2023-10-11 17:53:49 -04:00
parent 31d09f3c50
commit 5f2acc6c46
14 changed files with 275 additions and 253 deletions

View File

@ -62,7 +62,7 @@ public class Client {
}
public static void run0() {
instance = new Minecraft(Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), false);
instance = new Minecraft(Display.getWidth(), Display.getHeight(), false);
instance.session = new Session("Player", "fuckmojang123");
instance.session.mpPassParameter = "randpasslol";
mcThread = new Thread(instance, "Minecraft main thread");

View File

@ -1,7 +1,6 @@
package net.PeytonPlayz585.io;
import java.util.Collection;
import java.util.List;
import net.PeytonPlayz585.opengl.LWJGLMain;
@ -26,11 +25,11 @@ public class File {
}
public boolean exists() {
if(LWJGLMain.directoryExists(path) || LWJGLMain.fileExists(path)) {
return true;
} else {
byte[] data = LWJGLMain.readFile(path);
if(data == null) {
return false;
}
return true;
}
public boolean mkdirs() {
@ -76,7 +75,9 @@ public class File {
}
public void delete() {
LWJGLMain.writeFile(path, null);
if(exists()) {
LWJGLMain.deleteFile(path);
}
}
public File[] listFiles() {
@ -89,10 +90,6 @@ public class File {
return files;
}
public boolean isDirectory() {
return LWJGLMain.directoryExists(path);
}
public void renameTo(File var4) {
LWJGLMain.renameFile(path, var4.getPath());
}

View File

@ -725,4 +725,22 @@ public abstract class Entity {
var1.riddenByEntity = this;
}
}
public void turn(float var1, float var2) {
float var3 = this.rotationPitch;
float var4 = this.rotationYaw;
this.rotationYaw = (float)((double)this.rotationYaw + (double)var1 * 0.15D);
this.rotationPitch = (float)((double)this.rotationPitch - (double)var2 * 0.15D);
if(this.rotationPitch < -90.0F) {
this.rotationPitch = -90.0F;
}
if(this.rotationPitch > 90.0F) {
this.rotationPitch = 90.0F;
}
this.prevRotationPitch += this.rotationPitch - var3;
this.prevRotationYaw += this.rotationYaw - var4;
}
}

View File

@ -255,40 +255,52 @@ public class EntityRenderer {
int var3;
int var9;
int var10;
if(this.mc.inGameHasFocus) {
int var2 = Mouse.getDX() * 0;
var3 = Mouse.getDY() * 0;
this.mc.mouseHelper.mouseXYChange();
byte var4 = 1;
// if(this.mc.inGameHasFocus) {
// int var2 = Mouse.getDX() * 0;
// var3 = Mouse.getDY() * 0;
// this.mc.mouseHelper.mouseXYChange();
// byte var4 = 1;
// if(this.mc.gameSettings.invertMouse) {
// var4 = -1;
// }
//
// boolean var5 = false;
// boolean var6 = false;
// var9 = var2 + this.mc.mouseHelper.deltaX;
// var10 = var3 - this.mc.mouseHelper.deltaY;
// if(var2 != 0 || this.mouseDX != 0) {
// System.out.println("xxo: " + var2 + ", " + this.mouseDX + ": " + this.mouseDX + ", xo: " + var9);
// }
//
// if(this.mouseDX != 0) {
// this.mouseDX = 0;
// }
//
// if(this.mouseDY != 0) {
// this.mouseDY = 0;
// }
//
// if(var2 != 0) {
// this.mouseDX = var2;
// }
//
// if(var3 != 0) {
// this.mouseDY = var3;
// }
//
// this.mc.thePlayer.setAngles((float)var9, (float)(var10 * var4));
// }
int var5 = Mouse.getDX();
int var6 = Mouse.getDY();
byte var91 = 1;
if(this.mc.gameSettings.invertMouse) {
var4 = -1;
var91 = -1;
}
boolean var5 = false;
boolean var6 = false;
var9 = var2 + this.mc.mouseHelper.deltaX;
var10 = var3 - this.mc.mouseHelper.deltaY;
if(var2 != 0 || this.mouseDX != 0) {
System.out.println("xxo: " + var2 + ", " + this.mouseDX + ": " + this.mouseDX + ", xo: " + var9);
}
if(this.mouseDX != 0) {
this.mouseDX = 0;
}
if(this.mouseDY != 0) {
this.mouseDY = 0;
}
if(var2 != 0) {
this.mouseDX = var2;
}
if(var3 != 0) {
this.mouseDY = var3;
}
this.mc.thePlayer.setAngles((float)var9, (float)(var10 * var4));
if(this.mc.inGameHasFocus) {
this.mc.thePlayer.turn((float)var5, (float)(var6 & var91));
}
if(!this.mc.skipRenderWorld) {

View File

@ -29,9 +29,9 @@ public class GuiIngame extends Gui {
FontRenderer var8 = this.mc.fontRenderer;
this.mc.entityRenderer.setupOverlayRendering();
GL11.glEnable(GL11.GL_BLEND);
if(this.mc.gameSettings.fancyGraphics) {
this.renderVignette(this.mc.thePlayer.getEntityBrightness(var1), var6, var7);
}
// if(this.mc.gameSettings.fancyGraphics) {
// this.renderVignette(this.mc.thePlayer.getEntityBrightness(var1), var6, var7);
// }
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/gui.png"));

View File

@ -232,7 +232,6 @@ public class Minecraft implements Runnable {
return;
}
try {
long var1 = System.currentTimeMillis();
int var3 = 0;
@ -258,7 +257,6 @@ public class Minecraft implements Runnable {
this.timer.renderPartialTicks = 1.0F;
}
//this.sndManager.setListener(this.thePlayer, this.timer.renderPartialTicks);
GL11.glEnable(GL11.GL_TEXTURE_2D);
if(this.theWorld != null) {
while(this.theWorld.updatingLighting()) {
@ -278,7 +276,7 @@ public class Minecraft implements Runnable {
Thread.yield();
Display.update();
if(LWJGLMain.canvas.getWidth() != this.displayWidth || LWJGLMain.canvas.getHeight() != this.displayHeight) {
if(Display.getWidth() != this.displayWidth || Display.getHeight() != this.displayHeight) {
this.displayWidth = LWJGLMain.canvas.getWidth();
this.displayHeight = LWJGLMain.canvas.getHeight();
if(this.displayWidth <= 0) {
@ -293,7 +291,11 @@ public class Minecraft implements Runnable {
}
if(this.gameSettings.limitFramerate) {
try {
Thread.sleep(5L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
this.checkGLError("Post render");
@ -305,14 +307,6 @@ public class Minecraft implements Runnable {
var1 += 1000L;
}
}
} catch (MinecraftError var11) {
} catch (Exception var12) {
var12.printStackTrace();
new UnexpectedThrowable("Unexpected error", var12);
} finally {
this.shutdownMinecraftApplet();
}
}
private void displayDebugInfo() {

View File

@ -8,8 +8,8 @@ public class PlayerControllerSP extends PlayerController {
private float prevBlockDamage = 0.0F;
private float blockDestroySoundCounter = 0.0F;
private int blockHitWait = 0;
private SpawnerAnimals monsterSpawner = new SpawnerMonsters(this, 100, EntityMonster.class, new Class[]{EntityZombie.class, EntitySkeleton.class, EntityCreeper.class, EntitySpider.class});
private SpawnerAnimals animalSpawner = new SpawnerAnimals(20, EntityAnimal.class, new Class[]{EntitySheep.class, EntityPig.class});
//private SpawnerAnimals monsterSpawner = new SpawnerMonsters(this, 100, EntityMonster.class, new Class[]{EntityZombie.class, EntitySkeleton.class, EntityCreeper.class, EntitySpider.class});
//private SpawnerAnimals animalSpawner = new SpawnerAnimals(20, EntityAnimal.class, new Class[]{EntitySheep.class, EntityPig.class});
public PlayerControllerSP(Minecraft var1) {
super(var1);
@ -118,7 +118,7 @@ public class PlayerControllerSP extends PlayerController {
public void onUpdate() {
this.prevBlockDamage = this.curBlockDamage;
this.monsterSpawner.onUpdate(this.mc.theWorld);
this.animalSpawner.onUpdate(this.mc.theWorld);
//this.monsterSpawner.onUpdate(this.mc.theWorld);
//this.animalSpawner.onUpdate(this.mc.theWorld);
}
}

View File

@ -161,7 +161,7 @@ public class RenderEngine {
}
public int getTextureForDownloadableImage(String s, String s1) {
return getTexture("/mob/char.png");
return getTexture("/char.png");
}
public void registerTextureFX(TextureFX texturefx) {
@ -190,7 +190,7 @@ public class RenderEngine {
}
public static boolean useMipmaps = false;
private HashMap<String, Integer> textureMap;
private static HashMap<String, Integer> textureMap;
private HashMap<Integer, MinecraftImageData> textureNameToImageMap;
private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;

View File

@ -509,6 +509,7 @@ public class RenderGlobal implements IWorldAccess {
double var20 = var19.lastTickPosX + (var19.posX - var19.lastTickPosX) * var4;
double var10 = var19.lastTickPosY + (var19.posY - var19.lastTickPosY) * var4;
double var12 = var19.lastTickPosZ + (var19.posZ - var19.lastTickPosZ) * var4;
int var14 = 0;
int var15;

View File

@ -1,97 +1,96 @@
package net.minecraft.src;
public class SpawnerAnimals {
private int maxSpawns;
private Class entityType;
private Class[] entities;
public SpawnerAnimals(int var1, Class var2, Class[] var3) {
this.maxSpawns = var1;
this.entityType = var2;
this.entities = var3;
}
public void onUpdate(World var1) {
int var2 = var1.countEntities(this.entityType);
if(var2 < this.maxSpawns) {
for(int var3 = 0; var3 < 10; ++var3) {
this.performSpawning(var1, 1, var1.playerEntity, (IProgressUpdate)null);
}
}
}
protected ChunkPosition getRandomSpawningPointInChunk(World var1, int var2, int var3) {
int var4 = var2 + var1.rand.nextInt(256) - 128;
int var5 = var1.rand.nextInt(128);
int var6 = var3 + var1.rand.nextInt(256) - 128;
return new ChunkPosition(var4, var5, var6);
}
private int performSpawning(World var1, int var2, Entity var3, IProgressUpdate var4) {
int var5 = 0;
int var6 = MathHelper.floor_double(var3.posX);
int var7 = MathHelper.floor_double(var3.posZ);
int var8 = var1.rand.nextInt(this.entities.length);
ChunkPosition var9 = this.getRandomSpawningPointInChunk(var1, var6, var7);
int var10 = var9.x;
int var11 = var9.y;
int var12 = var9.z;
if(var1.isBlockNormalCube(var10, var11, var12)) {
return 0;
} else if(var1.getBlockMaterial(var10, var11, var12) != Material.air) {
return 0;
} else {
for(int var13 = 0; var13 < 3; ++var13) {
int var14 = var10;
int var15 = var11;
int var16 = var12;
byte var17 = 6;
for(int var18 = 0; var18 < 3; ++var18) {
var14 += var1.rand.nextInt(var17) - var1.rand.nextInt(var17);
var15 += var1.rand.nextInt(1) - var1.rand.nextInt(1);
var16 += var1.rand.nextInt(var17) - var1.rand.nextInt(var17);
if(var1.isBlockNormalCube(var14, var15 - 1, var16) && !var1.isBlockNormalCube(var14, var15, var16) && !var1.getBlockMaterial(var14, var15, var16).getIsLiquid() && !var1.isBlockNormalCube(var14, var15 + 1, var16)) {
float var19 = (float)var14 + 0.5F;
float var20 = (float)var15 + 1.0F;
float var21 = (float)var16 + 0.5F;
if(var3 != null) {
double var22 = (double)var19 - var3.posX;
double var24 = (double)var20 - var3.posY;
double var26 = (double)var21 - var3.posZ;
double var28 = var22 * var22 + var24 * var24 + var26 * var26;
if(var28 < 1024.0D) {
continue;
}
} else {
float var31 = var19 - (float)var1.spawnX;
float var23 = var20 - (float)var1.spawnY;
float var33 = var21 - (float)var1.spawnZ;
float var25 = var31 * var31 + var23 * var23 + var33 * var33;
if(var25 < 1024.0F) {
continue;
}
}
EntityLiving var32;
try {
var32 = (EntityLiving)this.entities[var8].getConstructor(new Class[]{World.class}).newInstance(new Object[]{var1});
} catch (Exception var30) {
var30.printStackTrace();
return var5;
}
var32.setPositionAndRotation((double)var19, (double)var20, (double)var21, var1.rand.nextFloat() * 360.0F, 0.0F);
if(var32.getCanSpawnHere((double)var19, (double)var20, (double)var21)) {
++var5;
var1.spawnEntityInWorld(var32);
}
}
}
}
return var5;
}
}
}
//package net.minecraft.src;
//
//public class SpawnerAnimals {
// private int maxSpawns;
// private Class entityType;
// private Class[] entities;
//
// public SpawnerAnimals(int var1, Class var2, Class[] var3) {
// this.maxSpawns = var1;
// this.entityType = var2;
// this.entities = var3;
// }
//
// public void onUpdate(World var1) {
// int var2 = var1.countEntities(this.entityType);
// if(var2 < this.maxSpawns) {
// for(int var3 = 0; var3 < 10; ++var3) {
// this.performSpawning(var1, 1, var1.playerEntity, (IProgressUpdate)null);
// }
// }
//
// }
//
// protected ChunkPosition getRandomSpawningPointInChunk(World var1, int var2, int var3) {
// int var4 = var2 + var1.rand.nextInt(256) - 128;
// int var5 = var1.rand.nextInt(128);
// int var6 = var3 + var1.rand.nextInt(256) - 128;
// return new ChunkPosition(var4, var5, var6);
// }
//
// private int performSpawning(World var1, int var2, Entity var3, IProgressUpdate var4) {
// int var5 = 0;
// int var6 = MathHelper.floor_double(var3.posX);
// int var7 = MathHelper.floor_double(var3.posZ);
// int var8 = var1.rand.nextInt(this.entities.length);
// ChunkPosition var9 = this.getRandomSpawningPointInChunk(var1, var6, var7);
// int var10 = var9.x;
// int var11 = var9.y;
// int var12 = var9.z;
// if(var1.isBlockNormalCube(var10, var11, var12)) {
// return 0;
// } else if(var1.getBlockMaterial(var10, var11, var12) != Material.air) {
// return 0;
// } else {
// for(int var13 = 0; var13 < 3; ++var13) {
// int var14 = var10;
// int var15 = var11;
// int var16 = var12;
// byte var17 = 6;
//
// for(int var18 = 0; var18 < 3; ++var18) {
// var14 += var1.rand.nextInt(var17) - var1.rand.nextInt(var17);
// var15 += var1.rand.nextInt(1) - var1.rand.nextInt(1);
// var16 += var1.rand.nextInt(var17) - var1.rand.nextInt(var17);
// if(var1.isBlockNormalCube(var14, var15 - 1, var16) && !var1.isBlockNormalCube(var14, var15, var16) && !var1.getBlockMaterial(var14, var15, var16).getIsLiquid() && !var1.isBlockNormalCube(var14, var15 + 1, var16)) {
// float var19 = (float)var14 + 0.5F;
// float var20 = (float)var15 + 1.0F;
// float var21 = (float)var16 + 0.5F;
// if(var3 != null) {
// double var22 = (double)var19 - var3.posX;
// double var24 = (double)var20 - var3.posY;
// double var26 = (double)var21 - var3.posZ;
// double var28 = var22 * var22 + var24 * var24 + var26 * var26;
// if(var28 < 1024.0D) {
// continue;
// }
// } else {
// float var31 = var19 - (float)var1.spawnX;
// float var23 = var20 - (float)var1.spawnY;
// float var33 = var21 - (float)var1.spawnZ;
// float var25 = var31 * var31 + var23 * var23 + var33 * var33;
// if(var25 < 1024.0F) {
// continue;
// }
// }
//
// EntityLiving var32;
// try {
// var32 = (EntityLiving)this.entities[var8].getConstructor(new Class[]{World.class}).newInstance(new Object[]{var1});
// } catch (Exception var30) {
// return var5;
// }
//
// var32.setPositionAndRotation((double)var19, (double)var20, (double)var21, var1.rand.nextFloat() * 360.0F, 0.0F);
// if(var32.getCanSpawnHere((double)var19, (double)var20, (double)var21)) {
// ++var5;
// var1.spawnEntityInWorld(var32);
// }
// }
// }
// }
//
// return var5;
// }
// }
//}

View File

@ -1,17 +1,17 @@
package net.minecraft.src;
class SpawnerMonsters extends SpawnerAnimals {
final PlayerControllerSP playerController;
SpawnerMonsters(PlayerControllerSP var1, int var2, Class var3, Class[] var4) {
super(var2, var3, var4);
this.playerController = var1;
}
protected ChunkPosition getRandomSpawningPointInChunk(World var1, int var2, int var3) {
int var4 = var2 + var1.rand.nextInt(256) - 128;
int var5 = var1.rand.nextInt(var1.rand.nextInt(var1.rand.nextInt(112) + 8) + 8);
int var6 = var3 + var1.rand.nextInt(256) - 128;
return new ChunkPosition(var4, var5, var6);
}
}
//package net.minecraft.src;
//
//class SpawnerMonsters extends SpawnerAnimals {
// final PlayerControllerSP playerController;
//
// SpawnerMonsters(PlayerControllerSP var1, int var2, Class var3, Class[] var4) {
// super(var2, var3, var4);
// this.playerController = var1;
// }
//
// protected ChunkPosition getRandomSpawningPointInChunk(World var1, int var2, int var3) {
// int var4 = var2 + var1.rand.nextInt(256) - 128;
// int var5 = var1.rand.nextInt(var1.rand.nextInt(var1.rand.nextInt(112) + 8) + 8);
// int var6 = var3 + var1.rand.nextInt(256) - 128;
// return new ChunkPosition(var4, var5, var6);
// }
//}

View File

@ -79,7 +79,7 @@ public class World implements IBlockAccess {
private static void deleteWorldFiles(File[] var0) {
for(int var1 = 0; var1 < var0.length; ++var1) {
if(var0[var1].isDirectory()) {
if(var0[var1].exists()) {
deleteWorldFiles(var0[var1].listFiles());
}

View File

@ -74,9 +74,13 @@ public class WorldRenderer {
}
}
private void setupGLTranslation() {
GL11.glTranslatef((float)this.posXClip, (float)this.posYClip, (float)this.posZClip);
}
// private void setupGLTranslation() {
// float var19 = 1.000001F;
// GL11.glTranslatef((float)posXClip * var19, (float)posYClip * var19, (float)posZClip * var19);
// for(int var2000 = 0; var2000 < 4; var2000++) {
// tessellator.addVertex(posX * var19, posY * var19, posZ * var19);
// }
// }
public void updateRenderer() {
if(this.needsUpdate) {
@ -113,14 +117,8 @@ public class WorldRenderer {
if(!var14) {
var14 = true;
GL11.glNewList(this.glRenderList + var11, GL11.GL_COMPILE);
GL11.glPushMatrix();
this.setupGLTranslation();
float var19 = 1.000001F;
GL11.glTranslatef((float)(-this.sizeDepth) / 2.0F, (float)(-this.sizeHeight) / 2.0F, (float)(-this.sizeDepth) / 2.0F);
GL11.glScalef(var19, var19, var19);
GL11.glTranslatef((float)this.sizeDepth / 2.0F, (float)this.sizeHeight / 2.0F, (float)this.sizeDepth / 2.0F);
tessellator.startDrawingQuads();
tessellator.setTranslationD((double)(-this.posX), (double)(-this.posY), (double)(-this.posZ));
tessellator.setTranslationD((double) (this.posXClip-this.posX), (double) (this.posYClip-this.posY), (double) (this.posZClip-this.posZ));
}
if(var11 == 0 && Block.blocksList[var18] instanceof BlockContainer) {
@ -144,7 +142,6 @@ public class WorldRenderer {
if(var14) {
tessellator.draw();
GL11.glPopMatrix();
GL11.glEndList();
tessellator.setTranslationD(0.0D, 0.0D, 0.0D);
} else {

View File

@ -13,7 +13,11 @@ public class Display {
LWJGLMain.updateDisplay();
}
public static HTMLCanvasElement getDisplayMode() {
return LWJGLMain.canvas;
public static int getWidth() {
return LWJGLMain.getCanvasWidth();
}
public static int getHeight() {
return LWJGLMain.getCanvasHeight();
}
}