Performance patch, add some features

Changes:
- Fix some of Notch's shit code
- Add Optifine's smooth updates (limits entity updates)
- Limit chunk updates
- Fix jittery movement
- Add singleplayer commands
- Use EaglercraftX Random implementation
- Added Optifine zoom
-Fixed some chunks not rendering
This commit is contained in:
PeytonPlayz595 2024-09-04 17:47:19 -07:00
parent acbb1a3c2c
commit d5c8ad3a77
32 changed files with 701 additions and 223 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/.gradle/
/output/
build/*

BIN
jars/jzlib-1.1.3.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
jars/teavm-jso-0.6.1.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +1,14 @@
package net.PeytonPlayz585.awt.image;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.lwjgl.opengl.GL11;
public class ImageIO {
public static BufferedImage read(InputStream var1) {
public static BufferedImage read(InputStream var1) throws IOException {
ByteArrayInputStream bais = (ByteArrayInputStream)var1;
byte[] data = bais.readAllBytes();

View File

@ -0,0 +1,22 @@
package net.PeytonPlayz585.logger;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public interface ILogRedirector {
void log(String txt, boolean err);
}

View File

@ -0,0 +1,43 @@
package net.PeytonPlayz585.logger;
import java.io.PrintStream;
/**
* Copyright (c) 2022 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public enum Level {
TRACE(0, "TRACE", false), DEBUG(1, "DEBUG", false), INFO(2, "INFO", false),
WARN(3, "WARN", false), ERROR(4, "ERROR", true), FATAL(5, "FATAL", true),
FINER(6, "FINER", false), SEVERE(7, "SEVERE", true), FINE(8, "FINE", false),
OFF(Integer.MAX_VALUE, "DISABLED", false);
public final int levelInt;
public final String levelName;
public final PrintStream stdout;
public final boolean isErr;
private Level(int levelInt, String levelName, boolean stderr) {
this.levelInt = levelInt;
this.levelName = levelName;
this.stdout = stderr ? System.err : System.out;
this.isErr = stderr;
}
PrintStream getPrintStream() {
return stdout;
}
}

View File

@ -0,0 +1,48 @@
package net.PeytonPlayz585.logger;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class LogManager {
private static final Map<String,Logger> loggerInstances = new HashMap();
public static final Object logLock = new Object();
public static Level logLevel = Level.DEBUG;
public static ILogRedirector logRedirector = null;
public static Logger getLogger() {
return getLogger("Minecraft");
}
public static Logger getLogger(String name) {
Logger ret;
synchronized(loggerInstances) {
ret = loggerInstances.get(name);
if(ret == null) {
ret = new Logger(name);
}
}
return ret;
}
public static void setLevel(Level lv) {
logLevel = lv;
}
}

View File

@ -0,0 +1,193 @@
package net.PeytonPlayz585.logger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class Logger {
public final String loggerName;
Logger(String name) {
this.loggerName = name;
}
public void trace(String msg) {
log(Level.TRACE, msg);
}
public void trace(String msg, Object... args) {
log(Level.TRACE, msg, args);
}
public void trace(Throwable msg) {
log(Level.WARN, msg);
}
public void debug(String msg) {
log(Level.DEBUG, msg);
}
public void debug(String msg, Object... args) {
log(Level.DEBUG, msg, args);
}
public void debug(Throwable msg) {
log(Level.DEBUG, msg);
}
public void info(String msg) {
log(Level.INFO, msg);
}
public void info(String msg, Object... args) {
log(Level.INFO, msg, args);
}
public void info(Throwable msg) {
log(Level.INFO, msg);
}
public void warn(String msg) {
log(Level.WARN, msg);
}
public void warn(String msg, Object... args) {
log(Level.WARN, msg, args);
}
public void warn(Throwable msg) {
log(Level.WARN, msg);
}
public void error(String msg) {
log(Level.ERROR, msg);
}
public void error(String msg, Object... args) {
log(Level.ERROR, msg, args);
}
public void error(Throwable msg) {
log(Level.ERROR, msg);
}
public void fatal(String msg) {
log(Level.FATAL, msg);
}
public void fatal(String msg, Object... args) {
log(Level.FATAL, msg, args);
}
public void fatal(Throwable msg) {
log(Level.FATAL, msg);
}
private static final SimpleDateFormat fmt = fixDateFormat(new SimpleDateFormat("hh:mm:ss+SSS"));
private static final Date dateInstance = new Date();
public void log(Level level, String msg) {
if(level.levelInt >= LogManager.logLevel.levelInt) {
synchronized(LogManager.logLock) {
dateInstance.setTime(System.currentTimeMillis());
String line = "[" + fmt.format(dateInstance) + "]" +
"[" + "main" + "/" + level.levelName + "]" +
"[" + loggerName + "]: " + msg;
level.getPrintStream().println(line);
if(LogManager.logRedirector != null) {
LogManager.logRedirector.log(line, level.isErr);
}
}
}
}
public void log(Level level, String msg, Object... args) {
if(level.levelInt >= LogManager.logLevel.levelInt) {
synchronized(LogManager.logLock) {
dateInstance.setTime(System.currentTimeMillis());
String line = "[" + fmt.format(dateInstance) + "]" +
"[" + "main" + "/" + level.levelName + "]" +
"[" + loggerName + "]: " + formatParams(msg, args);
level.getPrintStream().println(line);
if(LogManager.logRedirector != null) {
LogManager.logRedirector.log(line, level.isErr);
}
}
}
}
public static String formatParams(String msg, Object... args) {
if(args.length > 0) {
StringBuilder builtString = new StringBuilder();
for(int i = 0; i < args.length; ++i) {
int idx = msg.indexOf("{}");
if(idx != -1) {
builtString.append(msg.substring(0, idx));
builtString.append(args[i]);
msg = msg.substring(idx + 2);
}else {
break;
}
}
builtString.append(msg);
return builtString.toString();
}else {
return msg;
}
}
public void log(Level level, Throwable msg) {
logExcp(level, "Exception Thrown", msg);
}
private void logExcp(final Level level, String h, Throwable msg) {
log(level, "{}: {}", h, msg.toString());
Throwable cause = msg.getCause();
if(cause != null) {
logExcp(level, "Caused By", cause);
}
}
public void finer(String format, Object... params) {
log(Level.FINER, format, params);
}
public boolean isDebugEnabled() {
return LogManager.logLevel.levelInt <= Level.DEBUG.levelInt;
}
private static Calendar getLocaleCalendar() {
return Calendar.getInstance();
}
private static <T extends DateFormat> T fixDateFormat(T input) {
input.setCalendar(getLocaleCalendar());
return input;
}
public void severe(String format, Object... params) {
log(Level.SEVERE, format, params);
}
public void fine(String format, Object... params) {
log(Level.FINE, format, params);
}
}

View File

@ -0,0 +1,183 @@
package net.lax1dude.eaglercraft.beta;
import java.util.HashMap;
import java.util.Map.Entry;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Block;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityList;
import net.minecraft.src.FontRenderer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.WorldInfo;
public class SingleplayerCommands {
public static final HashMap<String, Command> singleplayerCommands;
static {
singleplayerCommands = new HashMap();
singleplayerCommands.put("help", new CommandHelp());
singleplayerCommands.put("give", new CommandGiveItem());
singleplayerCommands.put("summon", new CommandSummon());
singleplayerCommands.put("time", new CommandTime());
}
public static interface Command {
void processCommand(Minecraft mc, String[] args) throws Throwable;
String getDescription();
}
public static class CommandException extends RuntimeException {
public CommandException() { super(); }
public CommandException(String message, Throwable cause) { super(message, cause); }
public CommandException(String message) { super(message); }
}
public static void processCommand(Minecraft mc, String cmd) {
String[] args = cmd.split("\\s+");
if(args.length > 0) {
Command command = singleplayerCommands.get(args[0]);
if(command != null) {
String[] passArgs = new String[args.length - 1];
System.arraycopy(args, 1, passArgs, 0, passArgs.length);
try {
command.processCommand(mc, passArgs);
}catch(CommandException t) {
mc.displayErrorChat("Command Error: " + FontRenderer.formatChar + "r" + t.getMessage() + (t.getCause() != null ? " (caused by: " + t.getCause().toString() + ")" : ""));
//t.printStackTrace();
}catch(Throwable t) {
mc.displayErrorChat("Command Error: " + FontRenderer.formatChar + "r" + t.toString());
//t.printStackTrace();
}
}else {
mc.displayErrorChat("Command '" + args[0] + "' does not exist");
}
}
}
public static class CommandHelp implements Command {
@Override
public void processCommand(Minecraft mc, String[] args) {
mc.displayChat(FontRenderer.formatChar + "aAvailable Singleplayer Commands:");
for(Entry<String, Command> cmd : singleplayerCommands.entrySet()) {
mc.displayChat(" " + FontRenderer.formatChar + "e/" + cmd.getKey() + FontRenderer.formatChar + "r - " + cmd.getValue().getDescription());
}
}
@Override
public String getDescription() {
return "list all available commands";
}
}
public static class CommandGiveItem implements Command {
@Override
public void processCommand(Minecraft mc, String[] args) throws Throwable {
if(args.length != 1 && args.length != 2 && args.length != 3) {
throw new CommandException("arguments must be: <id> [count] [damage]");
}
int id = Integer.parseInt(args[0]);
boolean exists = id < 256 ? Block.blocksList[id] != null : Item.itemsList[id] != null;
if(exists) {
ItemStack stack = new ItemStack(id, args.length == 2 ? Integer.parseInt(args[1]) : 1, args.length == 3 ? Integer.parseInt(args[2]) : 0);
mc.thePlayer.inventory.addItemStackToInventory(stack);
if(id < 256) {
mc.displayChat("Gave player block '" + id + "'");
}else {
mc.displayChat("Gave player item '" + id + "'");
}
}else {
mc.displayErrorChat("Item/Block id #" + id + " does not exist!");
}
}
@Override
public String getDescription() {
return "give item <id> [count]";
}
}
public static class CommandSummon implements Command {
@Override
public void processCommand(Minecraft mc, String[] args) throws Throwable {
if(args.length != 1 && args.length != 4) {
throw new CommandException("arguments must be: <name> [x] [y] [z]");
}
Entity e;
try {
int id = Integer.parseInt(args[0]);
if(id == 1 || id == 49 || id == 9) {
throw new CommandException("Entity id '" + args[0] + "' is not registered");
}
e = EntityList.createEntity(id, mc.theWorld);
}catch(NumberFormatException ex) {
String s = args[0].toLowerCase();
if(s.equals("item") || s.equals("monster") || s.equals("painting")) {
throw new CommandException("Entity id '" + args[0] + "' is not registered");
}
e = EntityList.createEntityInWorld(s, mc.theWorld);
}
if(e == null) {
throw new CommandException("Entity id '" + args[0] + "' is not registered");
}
int x, y, z;
if(args.length == 4) {
x = Integer.parseInt(args[1]);
y = Integer.parseInt(args[2]);
z = Integer.parseInt(args[3]);
while(y > 0 && !mc.theWorld.isBlockOpaqueCube(x, y - 1, z)) {
--y;
}
}else {
x = MathHelper.floor_double(mc.thePlayer.posX);
y = MathHelper.floor_double(mc.thePlayer.posY);
z = MathHelper.floor_double(mc.thePlayer.posZ);
}
e.setLocationAndAngles(x, y, z, 0.0f, 0.0f);
mc.theWorld.entityJoinedWorld(e);
}
@Override
public String getDescription() {
return "spawn an entity <id> [x] [y] [z]";
}
}
public static class CommandTime implements Command {
@Override
public void processCommand(Minecraft mc, String[] args) throws Throwable {
int i;
if(args.length != 1) {
throw new CommandException("arguments must be: <ticks>");
}
try {
i = Integer.parseInt(args[0]);
}catch(NumberFormatException ex) {
throw new CommandException("time argument must be an integer");
}
WorldInfo inf = mc.theWorld.getWorldInfo();
long t = inf.getWorldTime();
t = t / 24000l * 24000l;
t += i;
inf.setWorldTime(t);
mc.displayChat("Set world time to " + i + " ticks");
}
@Override
public String getDescription() {
return "set world time in <ticks>";
}
}
}

View File

@ -817,7 +817,7 @@ public class Minecraft implements Runnable {
this.thePlayer.dropCurrentItem();
}
if(this.isMultiplayerWorld() && Keyboard.getEventKey() == this.gameSettings.keyBindChat.keyCode) {
if(Keyboard.getEventKey() == this.gameSettings.keyBindChat.keyCode) {
this.displayGuiScreen(new GuiChat());
}
}
@ -1233,4 +1233,12 @@ public class Minecraft implements Runnable {
public static Minecraft getMinecraft() {
return theMinecraft;
}
public void displayChat(String s) {
this.ingameGUI.addChatMessage(s);
}
public void displayErrorChat(String s) {
this.ingameGUI.addChatMessage(FontRenderer.formatChar + "c" + s);
}
}

View File

@ -78,7 +78,12 @@ public class EaglerSaveFormat implements ISaveFormat {
//Returns world info for the world
public WorldInfo func_22173_b(String var1) {
byte[] lvl = File.readFile(saveDir + "/" + var1 + "/level.dat");
String s = saveDir + "/" + var1 + "/level.dat";
if(s.startsWith("saves/")) {
s.replace("saves/minecraft/", "minecraft/");
}
System.out.println(s);
byte[] lvl = File.readFile(s);
if(lvl != null) {
try {
NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl)));

View File

@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
public class EntityList {
private static Map stringToClassMapping = new HashMap();
private static Map<String, Class> stringToClassMapping = new HashMap();
private static Map classToStringMapping = new HashMap();
private static Map IDtoClassMapping = new HashMap();
private static Map classToIDMapping = new HashMap();
@ -20,7 +20,12 @@ public class EntityList {
Entity var2 = null;
try {
Class var3 = (Class)stringToClassMapping.get(var0);
Class var3 = null;
for (Map.Entry<String, Class> entry : stringToClassMapping.entrySet()) {
if(entry.getKey().equalsIgnoreCase(var0)) {
var3 = (Class)entry.getValue();
}
}
if(var3 != null) {
var2 = SpawnerAnimals.newInstance(var3);
}

View File

@ -199,9 +199,51 @@ public abstract class EntityLiving extends Entity {
this.newRotationPitch = (double)var8;
this.newPosRotationIncrements = var9;
}
private boolean canSkipUpdate() {
if (this.hurtTime > 0) {
return false;
} else if (this.ticksExisted < 20) {
return false;
} else {
World world = this.worldObj;
if (world == null) {
return false;
} else if (world.playerEntities.size() != 1) {
return false;
} else {
Entity entity = (Entity)world.playerEntities.get(0);
double d0 = Math.max(Math.abs(this.posX - entity.posX) - 16.0D, 0.0D);
double d1 = Math.max(Math.abs(this.posZ - entity.posZ) - 16.0D, 0.0D);
double d2 = d0 * d0 + d1 * d1;
return !this.isInRangeToRenderDist(d2);
}
}
}
private void onUpdateMinimal() {
++this.entityAge;
if (this instanceof EntityMob) {
float f = this.getEntityBrightness(1.0F);
if (f > 0.5F) {
this.entityAge += 2;
}
}
this.func_27021_X();
}
public void onUpdate() {
super.onUpdate();
if(this.canSkipUpdate()) {
this.onUpdateMinimal();
} else {
super.onUpdate();
}
this.onLivingUpdate();
double var1 = this.posX - this.prevPosX;
double var3 = this.posZ - this.prevPosZ;

View File

@ -139,6 +139,7 @@ public class EntityPlayerSP extends EntityPlayer {
}
public void sendChatMessage(String var1) {
this.mc.ingameGUI.addChatMessageTranslate("[Player] " + var1);
}
public boolean isSneaking() {

View File

@ -5,6 +5,8 @@ import java.util.List;
import net.PeytonPlayz585.glemu.GameOverlayFramebuffer;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
@ -50,6 +52,7 @@ public class EntityRenderer {
float fogColorBlue;
private float fogColor2;
private float fogColor1;
private static boolean zoomMode = false;
private GameOverlayFramebuffer overlayFramebuffer;
@ -142,7 +145,28 @@ public class EntityRenderer {
if(var2.isInsideOfMaterial(Material.water)) {
var3 = 60.0F;
}
boolean flag = false;
if(this.mc.currentScreen == null) {
flag = Keyboard.isKeyDown(this.mc.gameSettings.keyBindZoom.keyCode);
}
if(flag) {
if(!zoomMode) {
zoomMode = true;
this.mc.gameSettings.smoothCamera = true;
}
if(zoomMode) {
var3 /= 4.0F;
}
} else if(zoomMode) {
zoomMode = false;
this.mc.gameSettings.smoothCamera = false;
this.mouseFilterXAxis = new MouseFilter();
this.mouseFilterYAxis = new MouseFilter();
}
if(var2.health <= 0) {
float var4 = (float)var2.deathTime + var1;
var3 /= (1.0F - 500.0F / (var4 + 500.0F)) * 2.0F + 1.0F;

View File

@ -11,7 +11,7 @@ public class EntitySheep extends EntityAnimal {
protected void entityInit() {
super.entityInit();
this.dataWatcher.addObject(16, new Byte((byte)0));
this.dataWatcher.addObject(16,(byte)0);
}
public boolean attackEntityFrom(Entity var1, int var2) {

View File

@ -16,11 +16,11 @@ public class EntitySlime extends EntityLiving implements IMob {
protected void entityInit() {
super.entityInit();
this.dataWatcher.addObject(16, new Byte((byte)1));
this.dataWatcher.addObject(16, (byte)1);
}
public void setSlimeSize(int var1) {
this.dataWatcher.updateObject(16, new Byte((byte)var1));
this.dataWatcher.updateObject(16, (byte)var1);
this.setSize(0.6F * (float)var1, 0.6F * (float)var1);
this.health = var1 * var1;
this.setPosition(this.posX, this.posY, this.posZ);

View File

@ -3,24 +3,16 @@ package net.minecraft.src;
import java.util.Comparator;
public class EntitySorter implements Comparator {
private double field_30008_a;
private double field_30007_b;
private double field_30009_c;
private Entity field_1594_a;
public EntitySorter(Entity var1) {
this.field_30008_a = -var1.posX;
this.field_30007_b = -var1.posY;
this.field_30009_c = -var1.posZ;
field_1594_a = var1;
}
public int sortByDistanceToEntity(WorldRenderer var1, WorldRenderer var2) {
double var3 = (double)var1.posXPlus + this.field_30008_a;
double var5 = (double)var1.posYPlus + this.field_30007_b;
double var7 = (double)var1.posZPlus + this.field_30009_c;
double var9 = (double)var2.posXPlus + this.field_30008_a;
double var11 = (double)var2.posYPlus + this.field_30007_b;
double var13 = (double)var2.posZPlus + this.field_30009_c;
return (int)((var3 * var3 + var5 * var5 + var7 * var7 - (var9 * var9 + var11 * var11 + var13 * var13)) * 1024.0D);
float f = var1.distanceToEntitySquared(field_1594_a);
float f1 = var2.distanceToEntitySquared(field_1594_a) ;
return f == f1 ? 0 : f >= f1 ? 1 : -1;
}
public int compare(Object var1, Object var2) {

View File

@ -24,7 +24,7 @@ public class EntityWolf extends EntityAnimal {
super.entityInit();
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
this.dataWatcher.addObject(17, "");
this.dataWatcher.addObject(18, new Integer(this.health));
this.dataWatcher.addObject(18, this.health);
}
protected boolean canTriggerWalking() {

View File

@ -12,6 +12,7 @@ import net.PeytonPlayz585.awt.image.BufferedImage;
import net.PeytonPlayz585.awt.image.ImageIO;
public class FontRenderer {
public static final char formatChar = '\247';
private int[] charWidth = new int[256];
public int fontTextureName = 0;
private int fontDisplayLists;

View File

@ -38,7 +38,8 @@ public class GameSettings {
public KeyBinding keyBindChat = new KeyBinding("key.chat", 20);
public KeyBinding keyBindToggleFog = new KeyBinding("Function", 33);
public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42);
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog};
public KeyBinding keyBindZoom = new KeyBinding("Zoom", 46);
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindZoom};
protected Minecraft mc;
private String optionsFile;
public int difficulty = 2;

View File

@ -2,6 +2,8 @@ package net.minecraft.src;
import org.lwjgl.input.Keyboard;
import net.lax1dude.eaglercraft.beta.SingleplayerCommands;
public class GuiChat extends GuiScreen {
protected String message = "";
private int updateCounter = 0;
@ -26,7 +28,9 @@ public class GuiChat extends GuiScreen {
String var3 = this.message.trim();
if(var3.length() > 0) {
String var4 = this.message.trim();
if(!this.mc.lineIsCommand(var4)) {
if(!this.mc.isMultiplayerWorld() && var4.startsWith("/")) {
SingleplayerCommands.processCommand(this.mc, var4.substring(1));
} else {
this.mc.thePlayer.sendChatMessage(var4);
}
}
@ -77,4 +81,8 @@ public class GuiChat extends GuiScreen {
}
}
public boolean doesGuiPauseGame() {
return false;
}
}

View File

@ -44,7 +44,7 @@ public class GuiGameOver extends GuiScreen {
GL11.glScalef(2.0F, 2.0F, 2.0F);
this.drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215);
GL11.glPopMatrix();
this.drawCenteredString(this.fontRenderer, "Score: &e" + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215);
this.drawCenteredString(this.fontRenderer, "Score: " + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215);
super.drawScreen(var1, var2, var3);
}

View File

@ -2,6 +2,8 @@ package net.minecraft.src;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.Minecraft;
public class GuiRenameWorld extends GuiScreen {
private GuiScreen field_22112_a;
private GuiTextField field_22114_h;
@ -40,7 +42,7 @@ public class GuiRenameWorld extends GuiScreen {
this.mc.displayGuiScreen(this.field_22112_a);
} else if(var1.id == 0) {
ISaveFormat var2 = this.mc.getSaveLoader();
var2.func_22170_a(this.field_22113_i, this.field_22114_h.getText().trim());
var2.func_22170_a(Minecraft.getMinecraft().getSaveDir() + "/" + this.field_22113_i, this.field_22114_h.getText().trim());
this.mc.displayGuiScreen(this.field_22112_a);
}

View File

@ -1,33 +1,19 @@
package net.minecraft.src;
import java.util.concurrent.atomic.AtomicLong;
public class Random {
private final AtomicLong seed;
private long seed = 69;
private static final long multiplier = 0x5DEECE66DL;
private static final long addend = 0xBL;
private static final long mask = (1L << 48) - 1;
private static final long addend = 0xBL;
private static final long mask = (1L << 48) - 1;
public Random() {
this(seedUniquifier() ^ System.nanoTime());
public Random() {
this((long)(Math.random() * 9007199254740991.0));
}
private static long seedUniquifier() {
for (;;) {
long current = seedUniquifier.get();
long next = current * 181783497276652981L;
if (seedUniquifier.compareAndSet(current, next))
return next;
}
}
private static final AtomicLong seedUniquifier
= new AtomicLong(8682522807148012L);
public Random(long seed) {
this.seed = new AtomicLong(initialScramble(seed));
setSeed(seed);
}
private static long initialScramble(long seed) {
@ -35,26 +21,19 @@ public class Random {
}
public void setSeed(long seed) {
this.seed.set(initialScramble(seed));
haveNextNextGaussian = false;
this.seed = initialScramble(seed);
haveNextNextGaussian = true;
}
protected int next(int bits) {
long oldseed, nextseed;
AtomicLong seed = this.seed;
do {
oldseed = seed.get();
nextseed = (oldseed * multiplier + addend) & mask;
} while (!seed.compareAndSet(oldseed, nextseed));
return (int)(nextseed >>> (48 - bits));
seed = (seed * multiplier + addend) & mask;
return (int) (seed >>> (48 - bits));
}
public void nextBytes(byte[] bytes) {
for (int i = 0, len = bytes.length; i < len; )
for (int rnd = nextInt(),
n = Math.min(len - i, Integer.SIZE/Byte.SIZE);
n-- > 0; rnd >>= Byte.SIZE)
bytes[i++] = (byte)rnd;
for (int i = 0, len = bytes.length; i < len;)
for (int rnd = nextInt(), n = Math.min(len - i, Integer.SIZE / Byte.SIZE); n-- > 0; rnd >>= Byte.SIZE)
bytes[i++] = (byte) rnd;
}
public int nextInt() {

View File

@ -1,11 +1,13 @@
package net.minecraft.src;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
public class RenderGlobal implements IWorldAccess {
@ -208,14 +210,15 @@ public class RenderGlobal implements IWorldAccess {
for(var4 = 0; var4 < this.renderChunksWide; ++var4) {
for(int var5 = 0; var5 < this.renderChunksTall; ++var5) {
for(int var6 = 0; var6 < this.renderChunksDeep; ++var6) {
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4] = new WorldRenderer(this.worldObj, this.tileEntities, var4 * 16, var5 * 16, var6 * 16, 16, this.glRenderListBase + var2);
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4].isWaitingOnOcclusionQuery = false;
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4].isVisible = true;
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4].isInFrustum = true;
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4].chunkIndex = var3++;
this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4].markDirty();
this.sortedWorldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4] = this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4];
this.worldRenderersToUpdate.add(this.worldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4]);
int index = (var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4;
WorldRenderer wr = (this.worldRenderers[index] = new WorldRenderer(this.worldObj, this.tileEntities, var4 * 16, var5 * 16, var6 * 16, 16, this.glRenderListBase + var2));
wr.isWaitingOnOcclusionQuery = false;
wr.isVisible = true;
wr.isInFrustum = true;
wr.chunkIndex = var3++;
wr.markDirty();
this.sortedWorldRenderers[(var6 * this.renderChunksTall + var5) * this.renderChunksWide + var4] = wr;
this.worldRenderersToUpdate.add(wr);
var2 += 3;
}
}
@ -415,12 +418,14 @@ public class RenderGlobal implements IWorldAccess {
++this.renderersSkippingRenderPass;
} else if(!this.sortedWorldRenderers[var7].isInFrustum) {
++this.renderersBeingClipped;
} else if(!this.sortedWorldRenderers[var7].isVisible) {
++this.renderersBeingOccluded;
} else {
++this.renderersBeingRendered;
}
}
if(!this.sortedWorldRenderers[var7].skipRenderPass[var3] && this.sortedWorldRenderers[var7].isInFrustum) {
if(!this.sortedWorldRenderers[var7].skipRenderPass[var3] && this.sortedWorldRenderers[var7].isInFrustum && this.sortedWorldRenderers[var7].isVisible) {
int var8 = this.sortedWorldRenderers[var7].getGLCallListForPass(var3);
if(var8 >= 0) {
this.glRenderLists.add(this.sortedWorldRenderers[var7]);
@ -796,147 +801,59 @@ public class RenderGlobal implements IWorldAccess {
}
public boolean updateRenderers(EntityLiving var1, boolean var2) {
boolean var3 = false;
if(var3) {
Collections.sort(this.worldRenderersToUpdate, new RenderSorter(var1));
int var17 = this.worldRenderersToUpdate.size() - 1;
int var18 = this.worldRenderersToUpdate.size();
byte var3 = 2;
RenderSorter var4 = new RenderSorter(var1);
WorldRenderer[] var5 = new WorldRenderer[var3];
ArrayList var6 = null;
int var7 = this.worldRenderersToUpdate.size();
int var8 = 0;
int var9;
WorldRenderer var10;
int var11;
int var12;
List laterUpdateList = new ArrayList(var7);
for (var9 = 0; var9 < var7; ++var9) {
var10 = (WorldRenderer) this.worldRenderersToUpdate.get(var9);
for(int var19 = 0; var19 < var18; ++var19) {
WorldRenderer var20 = (WorldRenderer)this.worldRenderersToUpdate.get(var17 - var19);
if(!var2) {
if(var20.distanceToEntitySquared(var1) > 256.0F) {
if(var20.isInFrustum) {
if(var19 >= 3) {
return false;
}
} else if(var19 >= 1) {
return false;
}
if (var10 != null) {
if (!var10.isInFrustum || !var10.isVisible) {
laterUpdateList.add(var10);
}else {
if (var6 == null) {
var6 = new ArrayList();
}
} else if(!var20.isInFrustum) {
continue;
++var8;
var6.add(var10);
}
var20.updateRenderer();
this.worldRenderersToUpdate.remove(var20);
var20.needsUpdate = false;
}
return this.worldRenderersToUpdate.size() == 0;
} else {
byte var4 = 2;
RenderSorter var5 = new RenderSorter(var1);
WorldRenderer[] var6 = new WorldRenderer[var4];
ArrayList var7 = null;
int var8 = this.worldRenderersToUpdate.size();
int var9 = 0;
int var10;
WorldRenderer var11;
int var12;
int var13;
label169:
for(var10 = 0; var10 < var8; ++var10) {
var11 = (WorldRenderer)this.worldRenderersToUpdate.get(var10);
if(!var2) {
if(var11.distanceToEntitySquared(var1) > 256.0F) {
for(var12 = 0; var12 < var4 && (var6[var12] == null || var5.doCompare(var6[var12], var11) <= 0); ++var12) {
}
--var12;
if(var12 <= 0) {
continue;
}
var13 = var12;
while(true) {
--var13;
if(var13 == 0) {
var6[var12] = var11;
continue label169;
}
var6[var13 - 1] = var6[var13];
}
}
} else if(!var11.isInFrustum) {
continue;
}
if(var7 == null) {
var7 = new ArrayList();
}
++var9;
var7.add(var11);
this.worldRenderersToUpdate.set(var10, (Object)null);
}
if(var7 != null) {
if(var7.size() > 1) {
Collections.sort(var7, var5);
}
for(var10 = var7.size() - 1; var10 >= 0; --var10) {
var11 = (WorldRenderer)var7.get(var10);
var11.updateRenderer();
var11.needsUpdate = false;
}
}
var10 = 0;
int var21;
for(var21 = var4 - 1; var21 >= 0; --var21) {
WorldRenderer var22 = var6[var21];
if(var22 != null) {
if(!var22.isInFrustum && var21 != var4 - 1) {
var6[var21] = null;
var6[0] = null;
break;
}
var6[var21].updateRenderer();
var6[var21].needsUpdate = false;
++var10;
}
}
var21 = 0;
var12 = 0;
for(var13 = this.worldRenderersToUpdate.size(); var21 != var13; ++var21) {
WorldRenderer var14 = (WorldRenderer)this.worldRenderersToUpdate.get(var21);
if(var14 != null) {
boolean var15 = false;
for(int var16 = 0; var16 < var4 && !var15; ++var16) {
if(var14 == var6[var16]) {
var15 = true;
}
}
if(!var15) {
if(var12 != var21) {
this.worldRenderersToUpdate.set(var12, var14);
}
++var12;
}
}
}
while(true) {
--var21;
if(var21 < var12) {
return var8 == var9 + var10;
}
this.worldRenderersToUpdate.remove(var21);
}
}
this.worldRenderersToUpdate = laterUpdateList;
int updates = 0;
int dropped = 0;
if (var6 != null) {
if (var6.size() > 1) {
Collections.sort(var6, var4);
}
for (var9 = var6.size() - 1; var9 >= 0; --var9) {
var10 = (WorldRenderer) var6.get(var9);
if(updates > 1) {
this.worldRenderersToUpdate.add(var10);
++dropped;
}else {
var10.updateRenderer();
var10.needsUpdate = false;
if(!var10.skipAllRenderPasses()) {
++updates;
}
}
}
}
return true;
}
public void drawBlockBreaking(EntityPlayer var1, MovingObjectPosition var2, int var3, ItemStack var4, float var5) {
@ -956,7 +873,7 @@ public class RenderGlobal implements IWorldAccess {
var8 = this.worldObj.getBlockId(var2.blockX, var2.blockY, var2.blockZ);
Block var9 = var8 > 0 ? Block.blocksList[var8] : null;
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPolygonOffset(-3.0F, -3.0F);
GL11.glPolygonOffset(3.0F, 3.0F);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
double var10 = var1.lastTickPosX + (var1.posX - var1.lastTickPosX) * (double)var5;
double var12 = var1.lastTickPosY + (var1.posY - var1.lastTickPosY) * (double)var5;
@ -1148,9 +1065,6 @@ public class RenderGlobal implements IWorldAccess {
public void spawnParticle(String var1, double var2, double var4, double var6, double var8, double var10, double var12) {
if(this.mc != null && this.mc.renderViewEntity != null && this.mc.effectRenderer != null) {
if(isBehindPlayer(var2, var4, var6)) {
return;
}
double var14 = this.mc.renderViewEntity.posX - var2;
double var16 = this.mc.renderViewEntity.posY - var4;
double var18 = this.mc.renderViewEntity.posZ - var6;
@ -1191,12 +1105,6 @@ public class RenderGlobal implements IWorldAccess {
}
}
}
private boolean isBehindPlayer(double x, double y, double z) {
final Vec3D playerToBlock = new Vec3D(x - this.mc.thePlayer.posX, y - this.mc.thePlayer.posY, z - this.mc.thePlayer.posZ).normalize();
final Vec3D direction = (this.mc.thePlayer.getLookVec()).normalize();
return playerToBlock.dotProduct(direction) > 0.5;
}
public void obtainEntitySkin(Entity var1) {
var1.updateCloak();

View File

@ -46,7 +46,12 @@ public class RenderList {
if(this.field_1236_g.remaining() > 0) {
GL11.glPushMatrix();
GL11.glTranslatef((float)this.field_1242_a - this.field_1239_d, (float)this.field_1241_b - this.field_1238_e, (float)this.field_1240_c - this.field_1237_f);
/*
* What the fuck Notch lol
*
* GL11.glTranslatef((float)this.field_1242_a - this.field_1239_d, (float)this.field_1241_b - this.field_1238_e, (float)this.field_1240_c - this.field_1237_f);
*/
GL11.glTranslatef(this.field_1242_a - this.field_1239_d, this.field_1241_b - this.field_1238_e, this.field_1240_c - this.field_1237_f);
GL11.glCallLists(this.field_1236_g);
GL11.glPopMatrix();
}

View File

@ -17,7 +17,7 @@ public abstract class WorldProvider {
}
protected void generateLightBrightnessTable() {
float var1 = 0.05F;
float var1 = 0.2F;
for(int var2 = 0; var2 <= 15; ++var2) {
float var3 = 1.0F - (float)var2 / 15.0F;

View File

@ -206,7 +206,8 @@ public class WorldRenderer {
}
public boolean skipAllRenderPasses() {
return !this.isInitialized ? false : this.skipRenderPass[0] && this.skipRenderPass[1];
return !this.isInitialized ? false : (this.skipRenderPass[0] && this.skipRenderPass[1]
&& !this.needsUpdate); // What the fuck!?
}
public void markDirty() {

View File

@ -1231,8 +1231,6 @@ public class GL11 implements JSObject {
}
public static final void glPolygonOffset(float p1, float p2) {
p1 = -p1;
p2 = -p2;
if(p1 != polygonOffset1 || p2 != polygonOffset2) {
_wglPolygonOffset(p1, p2);
polygonOffset1 = p1;
@ -1588,6 +1586,11 @@ public class GL11 implements JSObject {
QueryGL q = queryObjs.get(in);
out.put(_wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE));
}
public static final void glGetQueryResult1(int in, IntBuffer out) {
QueryGL q = queryObjs.get(in);
out.put(_wglGetQueryObjecti(q, _wGL_QUERY_RESULT));
}
public static final int glGenTextures() {
return texObjects.register(_wglGenTextures());
@ -5447,7 +5450,7 @@ public class GL11 implements JSObject {
webgl.bindFramebuffer(FRAMEBUFFER, backBuffer.obj);
resizeBackBuffer(w2, h2);
try {
Thread.sleep(1l);
Thread.sleep(0l);
} catch (InterruptedException e) {
;
}