Fix mob spawning, water and saving settings

This commit is contained in:
PeytonPlayz595 2024-02-09 20:43:26 -05:00
parent ce68e3168c
commit 412d394030
9 changed files with 2862 additions and 2662 deletions

5095
js/app.js

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -117,12 +117,7 @@ public class EaglerAdapterImpl2 {
} }
} }
public static void onWindowUnload() { @JSBody(params = { }, script = "window.addEventListener('beforeunload', (event) => {event.preventDefault(); return '';});")
LocalStorageManager.saveStorageG();
LocalStorageManager.saveStorageP();
}
@JSBody(params = { }, script = "window.onbeforeunload = function(){javaMethods.get('net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.onWindowUnload()V').invoke();return false;};")
private static native void onBeforeCloseRegister(); private static native void onBeforeCloseRegister();
public static final String[] fileContentsLines(String path) { public static final String[] fileContentsLines(String path) {

View File

@ -159,10 +159,6 @@ public class Minecraft implements Runnable {
} }
private void loadScreen() { private void loadScreen() {
int xx = displayWidth;
if(xx > displayHeight) {
xx = displayHeight;
}
GL11.glClear(16640); GL11.glClear(16640);
GL11.glMatrixMode(5889 /* GL_PROJECTION */); GL11.glMatrixMode(5889 /* GL_PROJECTION */);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
@ -187,12 +183,10 @@ public class Minecraft implements Runnable {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setColorOpaque_I(0xffffff); tessellator.setColorOpaque_I(0xffffff);
int marginX = (displayWidth - xx) / 2; tessellator.addVertexWithUV(0.0D, displayHeight, 0.0D, 0.0D, 1.0D);
int marginY = (displayHeight - xx) / 2; tessellator.addVertexWithUV(displayWidth, displayHeight, 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV(marginX, displayHeight - marginY, 0.0D, 0.0D, 1.0D); tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(displayWidth - marginX, displayHeight - marginY, 0.0D, 1.0D, 1.0D); tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
tessellator.addVertexWithUV(displayWidth - marginX, marginY, 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(marginX, marginY, 0.0D, 0.0D, 0.0D);
tessellator.draw(); tessellator.draw();
GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glDisable(2896 /* GL_LIGHTING */);
GL11.glDisable(2912 /* GL_FOG */); GL11.glDisable(2912 /* GL_FOG */);

View File

@ -371,24 +371,7 @@ public class EntityRenderer {
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
if(this.mc.gameSettings.fancyGraphics) { var3.func_943_a(var2, 1, (double)var1);
GL11.glColorMask(false, false, false, false);
int var13 = var3.func_943_a(var2, 1, (double)var1);
GL11.glColorMask(true, true, true, true);
if(this.mc.gameSettings.anaglyph) {
if(var11 == 0) {
GL11.glColorMask(false, true, true, false);
} else {
GL11.glColorMask(true, false, false, false);
}
}
if(var13 > 0) {
var3.func_944_a(1, (double)var1);
}
} else {
var3.func_943_a(var2, 1, (double)var1);
}
GL11.glDepthMask(true); GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);

View File

@ -5,6 +5,8 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import net.PeytonPlayz585.storage.LocalStorageManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -202,35 +204,30 @@ public class GameSettings {
} }
public void saveOptions() { public void saveOptions() {
try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PrintWriter var1 = new PrintWriter(byteArrayOutputStream);
PrintWriter var1 = new PrintWriter(byteArrayOutputStream); var1.println("music:" + this.musicVolume);
var1.println("music:" + this.musicVolume); var1.println("sound:" + this.soundVolume);
var1.println("sound:" + this.soundVolume); var1.println("invertYMouse:" + this.invertMouse);
var1.println("invertYMouse:" + this.invertMouse); var1.println("mouseSensitivity:" + this.mouseSensitivity);
var1.println("mouseSensitivity:" + this.mouseSensitivity); var1.println("viewDistance:" + this.renderDistance);
var1.println("viewDistance:" + this.renderDistance); var1.println("bobView:" + this.viewBobbing);
var1.println("bobView:" + this.viewBobbing); var1.println("anaglyph3d:" + this.anaglyph);
var1.println("anaglyph3d:" + this.anaglyph); var1.println("limitFramerate:" + this.limitFramerate);
var1.println("limitFramerate:" + this.limitFramerate); var1.println("difficulty:" + this.difficulty);
var1.println("difficulty:" + this.difficulty); var1.println("fancyGraphics:" + this.fancyGraphics);
var1.println("fancyGraphics:" + this.fancyGraphics); var1.println("skin:" + this.skin);
var1.println("skin:" + this.skin);
var1.println("lastServer:" + this.field_12259_z);
for(int var2 = 0; var2 < this.keyBindings.length; ++var2) { for(int var2 = 0; var2 < this.keyBindings.length; ++var2) {
var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode); var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
}
var1.flush();
byte[] fileData = byteArrayOutputStream.toByteArray();
GL11.writeFile("options.txt", fileData);
var1.close();
} catch (Exception var3) {
System.out.println("Failed to save options");
var3.printStackTrace();
} }
var1.flush();
byte[] fileData = byteArrayOutputStream.toByteArray();
GL11.writeFile("options.txt", fileData);
var1.close();
LocalStorageManager.saveStorageG();
LocalStorageManager.saveStorageP();
} }
} }

View File

@ -1,5 +1,11 @@
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.Minecraft;
public class MobSpawnerBase { public class MobSpawnerBase {
public static final MobSpawnerBase rainforest = (new MobSpawnerBase()).func_4123_b(588342).setBiomeName("Rainforest").func_4124_a(2094168); public static final MobSpawnerBase rainforest = (new MobSpawnerBase()).func_4123_b(588342).setBiomeName("Rainforest").func_4124_a(2094168);
public static final MobSpawnerBase swampland = (new MobSpawnerSwamp()).func_4123_b(522674).setBiomeName("Swampland").func_4124_a(9154376); public static final MobSpawnerBase swampland = (new MobSpawnerSwamp()).func_4123_b(522674).setBiomeName("Swampland").func_4124_a(9154376);
@ -18,8 +24,8 @@ public class MobSpawnerBase {
public byte topBlock = (byte)Block.grass.blockID; public byte topBlock = (byte)Block.grass.blockID;
public byte fillerBlock = (byte)Block.dirt.blockID; public byte fillerBlock = (byte)Block.dirt.blockID;
public int field_6502_q = 5169201; public int field_6502_q = 5169201;
protected Class[] biomeMonsters = new Class[]{EntitySpider.class, EntityZombie.class, EntitySkeleton.class, EntityCreeper.class}; protected List biomeMonsters = new ArrayList();
protected Class[] biomeCreatures = new Class[]{EntitySheep.class, EntityPig.class, EntityChicken.class, EntityCow.class}; protected List biomeCreatures = new ArrayList();
private static MobSpawnerBase[] biomeLookupTable = new MobSpawnerBase[4096]; private static MobSpawnerBase[] biomeLookupTable = new MobSpawnerBase[4096];
public static void generateBiomeLookup() { public static void generateBiomeLookup() {
@ -131,8 +137,34 @@ public class MobSpawnerBase {
return (255 << 24) | (red << 16) | (green << 8) | blue; return (255 << 24) | (red << 16) | (green << 8) | blue;
} }
public Class[] getEntitiesForType(EnumCreatureType var1) { public List getEntitiesForType(EnumCreatureType var1) {
return var1 == EnumCreatureType.monster ? this.biomeMonsters : (var1 == EnumCreatureType.creature ? this.biomeCreatures : null); if(var1 == EnumCreatureType.monster) {
if(this.biomeMonsters.isEmpty()) {
initBiomeMonsters();
}
return this.biomeMonsters;
} else if(var1 == EnumCreatureType.creature) {
if(this.biomeCreatures.isEmpty()) {
initBiomeCreatures();
}
return this.biomeCreatures;
} else {
return null;
}
}
public void initBiomeMonsters() {
biomeMonsters.add(new EntitySpider(Minecraft.getMinecraft().theWorld));
biomeMonsters.add(new EntityZombie(Minecraft.getMinecraft().theWorld));
biomeMonsters.add(new EntitySkeleton(Minecraft.getMinecraft().theWorld));
biomeMonsters.add(new EntityCreeper(Minecraft.getMinecraft().theWorld));
}
public void initBiomeCreatures() {
biomeCreatures.add(new EntitySheep(Minecraft.getMinecraft().theWorld));
biomeCreatures.add(new EntityPig(Minecraft.getMinecraft().theWorld));
biomeCreatures.add(new EntityChicken(Minecraft.getMinecraft().theWorld));
biomeCreatures.add(new EntityCow(Minecraft.getMinecraft().theWorld));
} }
static { static {

View File

@ -1,8 +1,25 @@
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
public class MobSpawnerHell extends MobSpawnerBase { public class MobSpawnerHell extends MobSpawnerBase {
public MobSpawnerHell() { public MobSpawnerHell() {
this.biomeMonsters = new Class[]{EntityGhast.class, EntityPigZombie.class}; biomeMonsters = new ArrayList();
this.biomeCreatures = new Class[0]; biomeCreatures = new ArrayList();
}
@Override
public void initBiomeMonsters() {
biomeMonsters.add(new EntityGhast(Minecraft.getMinecraft().theWorld));
biomeMonsters.add(new EntityPigZombie(Minecraft.getMinecraft().theWorld));
}
@Override
public void initBiomeCreatures() {
if(biomeCreatures != null) {
biomeCreatures.clear();
}
} }
} }

View File

@ -1,133 +1,188 @@
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.client.Minecraft;
public final class SpawnerAnimals { public final class SpawnerAnimals {
private static Set eligibleChunksForSpawning = new HashSet(); private static Set eligibleChunksForSpawning = new HashSet();
private static List entityList = new ArrayList();
protected static ChunkPosition getRandomSpawningPointInChunk(World var0, int var1, int var2) { protected static ChunkPosition getRandomSpawningPointInChunk(World var0, int var1, int var2) {
int var3 = var1 + var0.rand.nextInt(16); int var3 = var1 + var0.rand.nextInt(16);
int var4 = var0.rand.nextInt(128); int var4 = var0.rand.nextInt(128);
int var5 = var2 + var0.rand.nextInt(16); int var5 = var2 + var0.rand.nextInt(16);
return new ChunkPosition(var3, var4, var5); return new ChunkPosition(var3, var4, var5);
} }
public static final int performSpawning(World var0) { public static final int performSpawning(World var0) {
eligibleChunksForSpawning.clear(); eligibleChunksForSpawning.clear();
int var1; int var1;
for(var1 = 0; var1 < var0.playerEntities.size(); ++var1) { for(var1 = 0; var1 < var0.playerEntities.size(); ++var1) {
EntityPlayer var2 = (EntityPlayer)var0.playerEntities.get(var1); EntityPlayer var2 = (EntityPlayer)var0.playerEntities.get(var1);
int var3 = MathHelper.floor_double(var2.posX / 16.0D); int var3 = MathHelper.floor_double(var2.posX / 16.0D);
int var4 = MathHelper.floor_double(var2.posZ / 16.0D); int var4 = MathHelper.floor_double(var2.posZ / 16.0D);
byte var5 = 8; byte var5 = 8;
for(int var6 = -var5; var6 <= var5; ++var6) { for(int var6 = -var5; var6 <= var5; ++var6) {
for(int var7 = -var5; var7 <= var5; ++var7) { for(int var7 = -var5; var7 <= var5; ++var7) {
eligibleChunksForSpawning.add(new ChunkCoordIntPair(var6 + var3, var7 + var4)); eligibleChunksForSpawning.add(new ChunkCoordIntPair(var6 + var3, var7 + var4));
} }
} }
} }
var1 = 0; var1 = 0;
label113: label113:
for(int var28 = 0; var28 < EnumCreatureType.values().length; ++var28) { for(int var28 = 0; var28 < EnumCreatureType.values().length; ++var28) {
EnumCreatureType var29 = EnumCreatureType.values()[var28]; EnumCreatureType var29 = EnumCreatureType.values()[var28];
if(var0.countEntities(var29.field_4278_c) <= var29.maxNumberOfEntityType * eligibleChunksForSpawning.size() / 256) { if(var0.countEntities(var29.field_4278_c) <= var29.maxNumberOfEntityType * eligibleChunksForSpawning.size() / 256) {
Iterator var30 = eligibleChunksForSpawning.iterator(); Iterator var30 = eligibleChunksForSpawning.iterator();
label110: label110:
while(true) { while(true) {
int var8; int var8;
int var10; int var10;
int var11; int var11;
int var12; int var12;
Class[] var33; List var33;
do { do {
do { do {
ChunkCoordIntPair var31; ChunkCoordIntPair var31;
do { do {
do { do {
do { do {
if(!var30.hasNext()) { if(!var30.hasNext()) {
continue label113; continue label113;
} }
var31 = (ChunkCoordIntPair)var30.next(); var31 = (ChunkCoordIntPair)var30.next();
} while(var0.rand.nextInt(50) != 0); } while(var0.rand.nextInt(50) != 0);
MobSpawnerBase var32 = var0.func_4075_a().func_4074_a(var31); MobSpawnerBase var32 = var0.func_4075_a().func_4074_a(var31);
var33 = var32.getEntitiesForType(var29); var33 = var32.getEntitiesForType(var29);
} while(var33 == null); } while(var33 == null);
} while(var33.length == 0); } while(var33.size() == 0);
var8 = var0.rand.nextInt(var33.length); var8 = var0.rand.nextInt(var33.size());
ChunkPosition var9 = getRandomSpawningPointInChunk(var0, var31.chunkXPos * 16, var31.chunkZPos * 16); ChunkPosition var9 = getRandomSpawningPointInChunk(var0, var31.chunkXPos * 16, var31.chunkZPos * 16);
var10 = var9.x; var10 = var9.x;
var11 = var9.y; var11 = var9.y;
var12 = var9.z; var12 = var9.z;
} while(var0.isBlockOpaqueCube(var10, var11, var12)); } while(var0.isBlockOpaqueCube(var10, var11, var12));
} while(var0.getBlockMaterial(var10, var11, var12) != Material.air); } while(var0.getBlockMaterial(var10, var11, var12) != Material.air);
int var13 = 0; int var13 = 0;
for(int var14 = 0; var14 < 3; ++var14) { for(int var14 = 0; var14 < 3; ++var14) {
int var15 = var10; int var15 = var10;
int var16 = var11; int var16 = var11;
int var17 = var12; int var17 = var12;
byte var18 = 6; byte var18 = 6;
for(int var19 = 0; var19 < 4; ++var19) { for(int var19 = 0; var19 < 4; ++var19) {
var15 += var0.rand.nextInt(var18) - var0.rand.nextInt(var18); var15 += var0.rand.nextInt(var18) - var0.rand.nextInt(var18);
var16 += var0.rand.nextInt(1) - var0.rand.nextInt(1); var16 += var0.rand.nextInt(1) - var0.rand.nextInt(1);
var17 += var0.rand.nextInt(var18) - var0.rand.nextInt(var18); var17 += var0.rand.nextInt(var18) - var0.rand.nextInt(var18);
if(var0.isBlockOpaqueCube(var15, var16 - 1, var17) && !var0.isBlockOpaqueCube(var15, var16, var17) && !var0.getBlockMaterial(var15, var16, var17).getIsLiquid() && !var0.isBlockOpaqueCube(var15, var16 + 1, var17)) { if(var0.isBlockOpaqueCube(var15, var16 - 1, var17) && !var0.isBlockOpaqueCube(var15, var16, var17) && !var0.getBlockMaterial(var15, var16, var17).getIsLiquid() && !var0.isBlockOpaqueCube(var15, var16 + 1, var17)) {
float var20 = (float)var15 + 0.5F; float var20 = (float)var15 + 0.5F;
float var21 = (float)var16; float var21 = (float)var16;
float var22 = (float)var17 + 0.5F; float var22 = (float)var17 + 0.5F;
if(var0.getClosestPlayer((double)var20, (double)var21, (double)var22, 24.0D) == null) { if(var0.getClosestPlayer((double)var20, (double)var21, (double)var22, 24.0D) == null) {
float var23 = var20 - (float)var0.spawnX; float var23 = var20 - (float)var0.spawnX;
float var24 = var21 - (float)var0.spawnY; float var24 = var21 - (float)var0.spawnY;
float var25 = var22 - (float)var0.spawnZ; float var25 = var22 - (float)var0.spawnZ;
float var26 = var23 * var23 + var24 * var24 + var25 * var25; float var26 = var23 * var23 + var24 * var24 + var25 * var25;
if(var26 >= 576.0F) { if(var26 >= 576.0F) {
EntityLiving var34; EntityLiving var34;
try { try {
var34 = (EntityLiving)var33[var8].getConstructor(new Class[]{World.class}).newInstance(new Object[]{var0}); var34 = setEntity(var33, var8);
} catch (Exception var27) { } catch (Exception var27) {
var27.printStackTrace(); var27.printStackTrace();
return var1; return var1;
} }
var34.setLocationAndAngles((double)var20, (double)var21, (double)var22, var0.rand.nextFloat() * 360.0F, 0.0F); if(var34 == null) {
if(var34.getCanSpawnHere()) { return var1;
++var13; }
var0.entityJoinedWorld(var34);
if(var34 instanceof EntitySpider && var0.rand.nextInt(100) == 0) {
EntitySkeleton var35 = new EntitySkeleton(var0);
var35.setLocationAndAngles((double)var20, (double)var21, (double)var22, var34.rotationYaw, 0.0F);
var0.entityJoinedWorld(var35);
var35.mountEntity(var34);
}
if(var13 >= var34.func_6391_i()) { var34.setLocationAndAngles((double)var20, (double)var21, (double)var22, var0.rand.nextFloat() * 360.0F, 0.0F);
continue label110; if(var34.getCanSpawnHere()) {
} ++var13;
} var0.entityJoinedWorld(var34);
if(var34 instanceof EntitySpider && var0.rand.nextInt(100) == 0) {
EntitySkeleton var35 = new EntitySkeleton(var0);
var35.setLocationAndAngles((double)var20, (double)var21, (double)var22, var34.rotationYaw, 0.0F);
var0.entityJoinedWorld(var35);
var35.mountEntity(var34);
}
var1 += var13; if(var13 >= var34.func_6391_i()) {
} continue label110;
} }
} }
}
}
}
}
}
return var1; var1 += var13;
} }
}
}
}
}
}
}
}
return var1;
}
public static EntityLiving setEntity(List l, int i) {
EntityLiving e = (EntityLiving)l.get(i);
if(e instanceof EntitySpider) {
return new EntitySpider(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityZombie) {
return new EntityZombie(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntitySkeleton) {
return new EntitySkeleton(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityCreeper) {
return new EntityCreeper(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntitySheep) {
return new EntitySheep(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityPig) {
return new EntityPig(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityChicken) {
return new EntityChicken(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityCow) {
return new EntityCow(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityGhast) {
return new EntityGhast(Minecraft.getMinecraft().theWorld);
}
if(e instanceof EntityPigZombie) {
return new EntityPigZombie(Minecraft.getMinecraft().theWorld);
}
return null;
}
} }