Made better fast math & fixed shader profile

This commit is contained in:
PeytonPlayz595 2023-10-15 12:31:18 -04:00
parent 8452864d1e
commit 9c87f8de6c
11 changed files with 100519 additions and 100346 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@ public class GuiShaders extends GuiScreen {
if(parGuiButton.id == 201) { if(parGuiButton.id == 201) {
mc.gameSettings.setOptionValue(((GuiOptionButton)parGuiButton).returnEnumOptions(), 1); mc.gameSettings.setOptionValue(((GuiOptionButton)parGuiButton).returnEnumOptions(), 1);
parGuiButton.displayString = mc.gameSettings.getKeyBinding(GameSettings.Options.getEnumOptions(74)); parGuiButton.displayString = mc.gameSettings.getKeyBinding(GameSettings.Options.SHADER_PROFILE);
} }
} }
} }

View File

@ -23,6 +23,7 @@ import net.minecraft.tileentity.TileEntityPiston;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ReportedException; import net.minecraft.util.ReportedException;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -117,8 +118,8 @@ public class TileEntityRendererDispatcher {
if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn
.getMaxRenderDistanceSquared()) { .getMaxRenderDistanceSquared()) {
int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0); int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0);
int j = i % 65536; int j = MathHelper.fastMath ? i % 65536 : i % 4096;
int k = i / 65536; int k = MathHelper.fastMath ? i / 65536 : i / 4096;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
BlockPos blockpos = tileentityIn.getPos(); BlockPos blockpos = tileentityIn.getPos();

View File

@ -184,7 +184,6 @@ public class GameSettings {
public boolean shaders = false; public boolean shaders = false;
public boolean shadersAODisable = false; public boolean shadersAODisable = false;
public EaglerDeferredConfig deferredShaderConf = new EaglerDeferredConfig(); public EaglerDeferredConfig deferredShaderConf = new EaglerDeferredConfig();
public int fastMath = 1;
//Main Menu Settings //Main Menu Settings
public float ofAoLevel = 1.0F; public float ofAoLevel = 1.0F;
@ -225,6 +224,7 @@ public class GameSettings {
//Performance Settings //Performance Settings
public boolean ofSmoothFps = false; public boolean ofSmoothFps = false;
public int ofChunkUpdates = 1; public int ofChunkUpdates = 1;
public static boolean ofFastMath = true;
//Super Secret Setting :> //Super Secret Setting :>
public boolean secret = false; public boolean secret = false;
@ -484,10 +484,6 @@ public class GameSettings {
if (parOptions == GameSettings.Options.FULLSCREEN) { if (parOptions == GameSettings.Options.FULLSCREEN) {
this.mc.toggleFullscreen(); this.mc.toggleFullscreen();
} }
if (parOptions == GameSettings.Options.FAST_MATH) {
this.fastMath = (this.fastMath + parInt1) % 3;
}
if (parOptions == GameSettings.Options.ANIMATED_WATER) { if (parOptions == GameSettings.Options.ANIMATED_WATER) {
++this.ofAnimatedWater; ++this.ofAnimatedWater;
@ -661,6 +657,11 @@ public class GameSettings {
this.ofDynamicLights = nextValue(this.ofDynamicLights, OF_DYNAMIC_LIGHTS); this.ofDynamicLights = nextValue(this.ofDynamicLights, OF_DYNAMIC_LIGHTS);
DynamicLights.removeLights(this.mc.renderGlobal); DynamicLights.removeLights(this.mc.renderGlobal);
} }
if (parOptions == GameSettings.Options.FAST_MATH) {
ofFastMath = !ofFastMath;
MathHelper.fastMath = ofFastMath;
}
this.saveOptions(); this.saveOptions();
} }
@ -735,6 +736,8 @@ public class GameSettings {
return this.ofClearWater; return this.ofClearWater;
case SMOOTH_FPS: case SMOOTH_FPS:
return this.ofSmoothFps; return this.ofSmoothFps;
case FAST_MATH:
return ofFastMath;
default: default:
return false; return false;
} }
@ -802,8 +805,6 @@ public class GameSettings {
} else { } else {
return s + I18n.format("options.off"); return s + I18n.format("options.off");
} }
} else if (parOptions == GameSettings.Options.FAST_MATH) {
return s + I18n.format("options.fastMath." + this.fastMath);
} else if (parOptions == GameSettings.Options.ANIMATED_WATER) { } else if (parOptions == GameSettings.Options.ANIMATED_WATER) {
switch (this.ofAnimatedWater) { switch (this.ofAnimatedWater) {
case 1: case 1:
@ -925,6 +926,8 @@ public class GameSettings {
} else if (parOptions == GameSettings.Options.DYNAMIC_LIGHTS) { } else if (parOptions == GameSettings.Options.DYNAMIC_LIGHTS) {
int k = indexOf(this.ofDynamicLights, OF_DYNAMIC_LIGHTS); int k = indexOf(this.ofDynamicLights, OF_DYNAMIC_LIGHTS);
return s + getTranslation(KEYS_DYNAMIC_LIGHTS, k); return s + getTranslation(KEYS_DYNAMIC_LIGHTS, k);
} else if (parOptions == GameSettings.Options.FAST_MATH) {
return ofFastMath ? s + "ON" : s + "OFF";
} else { } else {
return s; return s;
} }
@ -1180,11 +1183,7 @@ public class GameSettings {
this.fxaa = (astring[1].equals("true") || astring[1].equals("false")) ? 0 this.fxaa = (astring[1].equals("true") || astring[1].equals("false")) ? 0
: Integer.parseInt(astring[1]); : Integer.parseInt(astring[1]);
} }
if (astring[0].equals("fastMath")) {
this.fastMath = Integer.parseInt(astring[1]);
}
for (KeyBinding keybinding : this.keyBindings) { for (KeyBinding keybinding : this.keyBindings) {
if (astring[0].equals("key_" + keybinding.getKeyDescription())) { if (astring[0].equals("key_" + keybinding.getKeyDescription())) {
keybinding.setKeyCode(Integer.parseInt(astring[1])); keybinding.setKeyCode(Integer.parseInt(astring[1]));
@ -1342,6 +1341,11 @@ public class GameSettings {
this.ofDynamicLights = Integer.valueOf(astring[1]).intValue(); this.ofDynamicLights = Integer.valueOf(astring[1]).intValue();
this.ofDynamicLights = limit(this.ofDynamicLights, OF_DYNAMIC_LIGHTS); this.ofDynamicLights = limit(this.ofDynamicLights, OF_DYNAMIC_LIGHTS);
} }
if (astring[0].equals("ofFastMath") && astring.length >= 2) {
ofFastMath = Boolean.valueOf(astring[1]).booleanValue();
MathHelper.fastMath = ofFastMath;
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode()); Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
@ -1436,7 +1440,6 @@ public class GameSettings {
printwriter.println("hud24h:" + this.hud24h); printwriter.println("hud24h:" + this.hud24h);
printwriter.println("chunkFix:" + this.chunkFix); printwriter.println("chunkFix:" + this.chunkFix);
printwriter.println("fxaa:" + this.fxaa); printwriter.println("fxaa:" + this.fxaa);
printwriter.println("fastMath:" + this.fastMath);
printwriter.println("shaders:" + this.shaders); printwriter.println("shaders:" + this.shaders);
printwriter.println("ofAnimatedWater:" + this.ofAnimatedWater); printwriter.println("ofAnimatedWater:" + this.ofAnimatedWater);
printwriter.println("ofAnimatedLava:" + this.ofAnimatedLava); printwriter.println("ofAnimatedLava:" + this.ofAnimatedLava);
@ -1480,6 +1483,7 @@ public class GameSettings {
printwriter.println("ofClouds:" + this.ofClouds); printwriter.println("ofClouds:" + this.ofClouds);
printwriter.println("ofCloudsHeight:" + this.ofCloudsHeight); printwriter.println("ofCloudsHeight:" + this.ofCloudsHeight);
printwriter.println("ofDynamicLights:" + this.ofDynamicLights); printwriter.println("ofDynamicLights:" + this.ofDynamicLights);
printwriter.println("ofFastMath:" + ofFastMath);
for (KeyBinding keybinding : this.keyBindings) { for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1605,7 +1609,8 @@ public class GameSettings {
STREAM_BYTES_PER_PIXEL("options.stream.bytesPerPixel", true, false), STREAM_BYTES_PER_PIXEL("options.stream.bytesPerPixel", true, false),
STREAM_VOLUME_MIC("options.stream.micVolumne", true, false), STREAM_VOLUME_MIC("options.stream.micVolumne", true, false),
STREAM_VOLUME_SYSTEM("options.stream.systemVolume", true, false), STREAM_VOLUME_SYSTEM("options.stream.systemVolume", true, false),
STREAM_KBPS("options.stream.kbps", true, false), STREAM_FPS("options.stream.fps", true, false), STREAM_KBPS("options.stream.kbps", true, false),
STREAM_FPS("options.stream.fps", true, false),
STREAM_COMPRESSION("options.stream.compression", false, false), STREAM_COMPRESSION("options.stream.compression", false, false),
STREAM_SEND_METADATA("options.stream.sendMetadata", false, true), STREAM_SEND_METADATA("options.stream.sendMetadata", false, true),
STREAM_CHAT_ENABLED("options.stream.chat.enabled", false, false), STREAM_CHAT_ENABLED("options.stream.chat.enabled", false, false),
@ -1613,12 +1618,17 @@ public class GameSettings {
STREAM_MIC_TOGGLE_BEHAVIOR("options.stream.micToggleBehavior", false, false), STREAM_MIC_TOGGLE_BEHAVIOR("options.stream.micToggleBehavior", false, false),
BLOCK_ALTERNATIVES("options.blockAlternatives", false, true), BLOCK_ALTERNATIVES("options.blockAlternatives", false, true),
REDUCED_DEBUG_INFO("options.reducedDebugInfo", false, true), REDUCED_DEBUG_INFO("options.reducedDebugInfo", false, true),
ENTITY_SHADOWS("options.entityShadows", false, true), HUD_FPS("options.hud.fps", false, true), ENTITY_SHADOWS("options.entityShadows", false, true),
HUD_COORDS("options.hud.coords", false, true), HUD_STATS("options.hud.stats", false, true), HUD_FPS("options.hud.fps", false, true),
HUD_WORLD("options.hud.world", false, true), HUD_PLAYER("options.hud.player", false, true), HUD_COORDS("options.hud.coords", false, true),
HUD_24H("options.hud.24h", false, true), CHUNK_FIX("options.chunkFix", false, true), HUD_STATS("options.hud.stats", false, true),
HUD_WORLD("options.hud.world", false, true),
HUD_PLAYER("options.hud.player", false, true),
HUD_24H("options.hud.24h", false, true),
CHUNK_FIX("options.chunkFix", false, true),
FXAA("options.fxaa", false, false), FXAA("options.fxaa", false, false),
FULLSCREEN("options.fullscreen", false, true), FAST_MATH("options.fastMath", false, false), FULLSCREEN("options.fullscreen", false, true),
FAST_MATH("options.fastMath", false, true),
ANIMATED_WATER("Water Animated", false, false), ANIMATED_WATER("Water Animated", false, false),
ANIMATED_LAVA("Lava Animated", false, false), ANIMATED_LAVA("Lava Animated", false, false),
ANIMATED_FIRE("Fire Animated", false, false), ANIMATED_FIRE("Fire Animated", false, false),

View File

@ -28,6 +28,8 @@ public class MathHelper {
* (exclusive), with steps of 2*PI / 65536. * (exclusive), with steps of 2*PI / 65536.
*/ */
private static final float[] SIN_TABLE = new float[65536]; private static final float[] SIN_TABLE = new float[65536];
private static final float[] SIN_TABLE_FAST = new float[4096];
public static boolean fastMath = false;
private static final int[] multiplyDeBruijnBitPosition; private static final int[] multiplyDeBruijnBitPosition;
private static final double field_181163_d; private static final double field_181163_d;
private static final double[] field_181164_e; private static final double[] field_181164_e;
@ -37,14 +39,14 @@ public class MathHelper {
* sin looked up in a table * sin looked up in a table
*/ */
public static float sin(float parFloat1) { public static float sin(float parFloat1) {
return SIN_TABLE[(int) (parFloat1 * 10430.378F) & '\uffff']; return fastMath ? SIN_TABLE_FAST[(int)(parFloat1 * 651.8986F) & 4095] : SIN_TABLE[(int)(parFloat1 * 10430.378F) & 65535];
} }
/**+ /**+
* cos looked up in the sin table with the appropriate offset * cos looked up in the sin table with the appropriate offset
*/ */
public static float cos(float value) { public static float cos(float value) {
return SIN_TABLE[(int) (value * 10430.378F + 16384.0F) & '\uffff']; return fastMath ? SIN_TABLE_FAST[(int)((value + ((float) Math.PI / 2F)) * 651.8986F) & 4095] : SIN_TABLE[(int)(value * 10430.378F + 16384.0F) & 65535];
} }
public static float sqrt_float(float value) { public static float sqrt_float(float value) {
@ -488,8 +490,16 @@ public class MathHelper {
static { static {
for (int i = 0; i < 65536; ++i) { for (int i = 0; i < 65536; ++i) {
SIN_TABLE[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D); SIN_TABLE[i] = (float) Math.sin((double) i * Math.PI * 2.0D / 65536.0D);
} }
for (int j = 0; j < 4096; ++j) {
SIN_TABLE_FAST[j] = (float) Math.sin((double)(((float) j + 0.5F) / 4096.0F * ((float) Math.PI * 2F)));
}
for (int l = 0; l < 360; l += 90) {
SIN_TABLE_FAST[(int)((float) l * 11.377778F) & 4095] = (float) Math.sin((double)((float) l * 0.017453292F));
}
multiplyDeBruijnBitPosition = new int[] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, multiplyDeBruijnBitPosition = new int[] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13,
23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };

View File

@ -83,12 +83,6 @@ public class Timer {
this.elapsedTicks = 10; this.elapsedTicks = 10;
} }
int fastMathSetting = Minecraft.getMinecraft().gameSettings.fastMath; this.renderPartialTicks = this.elapsedPartialTicks;
if (fastMathSetting > 0) {
float f = fastMathSetting == 2 ? 16.0f : 64.0f;
this.renderPartialTicks = ((int) (this.elapsedPartialTicks * f) / f);
} else {
this.renderPartialTicks = this.elapsedPartialTicks;
}
} }
} }

View File

@ -1533,37 +1533,6 @@ public abstract class World implements IBlockAccess {
} }
} }
int fastMathSetting = Minecraft.getMinecraft().gameSettings.fastMath;
if (fastMathSetting > 0) {
double posPrec = fastMathSetting == 2 ? 256.0 : 1024.0;
float rotPrec = fastMathSetting == 2 ? 64.0f : 128.0f;
double velPrec = fastMathSetting == 2 ? 2048.0 : 4096.0;
entityIn.lastTickPosX = (long) (entityIn.lastTickPosX * posPrec) / posPrec;
entityIn.lastTickPosY = (long) (entityIn.lastTickPosY * posPrec) / posPrec;
entityIn.lastTickPosZ = (long) (entityIn.lastTickPosZ * posPrec) / posPrec;
entityIn.prevPosX = (int) (entityIn.prevPosX * posPrec) / posPrec;
entityIn.prevPosY = (int) (entityIn.prevPosY * posPrec) / posPrec;
entityIn.prevPosZ = (int) (entityIn.prevPosZ * posPrec) / posPrec;
entityIn.posX = (int) (entityIn.posX * posPrec) / posPrec;
entityIn.posY = (int) (entityIn.posY * posPrec) / posPrec;
entityIn.posZ = (int) (entityIn.posZ * posPrec) / posPrec;
entityIn.prevRotationPitch = (int) (entityIn.prevRotationPitch * rotPrec) / rotPrec;
entityIn.prevRotationYaw = (int) (entityIn.prevRotationYaw * rotPrec) / rotPrec;
entityIn.rotationPitch = (int) (entityIn.rotationPitch * rotPrec) / rotPrec;
entityIn.rotationYaw = (int) (entityIn.rotationYaw * rotPrec) / rotPrec;
if (entityIn instanceof EntityLivingBase) {
EntityLivingBase l = (EntityLivingBase) entityIn;
l.prevRotationYawHead = (int) (l.prevRotationYawHead * rotPrec) / rotPrec;
l.rotationYawHead = (int) (l.rotationYawHead * rotPrec) / rotPrec;
l.prevRenderYawOffset = (int) (l.prevRenderYawOffset * rotPrec) / rotPrec;
l.renderYawOffset = (int) (l.renderYawOffset * rotPrec) / rotPrec;
l.prevRotationPitch = (int) (l.prevRotationPitch * rotPrec) / rotPrec;
l.rotationPitch = (int) (l.rotationPitch * rotPrec) / rotPrec;
}
entityIn.motionX = (int) (entityIn.motionX * velPrec) / velPrec;
entityIn.motionY = (int) (entityIn.motionY * velPrec) / velPrec;
entityIn.motionZ = (int) (entityIn.motionZ * velPrec) / velPrec;
}
} }
/**+ /**+

View File

@ -3,6 +3,7 @@ package net.minecraft.world.chunk;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
/**+ /**+
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code. * This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
@ -24,6 +25,7 @@ import net.minecraft.init.Blocks;
*/ */
public class ChunkPrimer { public class ChunkPrimer {
private final short[] data = new short[4096]; private final short[] data = new short[4096];
private final short[] data_fast = new short[4096];
private final IBlockState defaultState = Blocks.air.getDefaultState(); private final IBlockState defaultState = Blocks.air.getDefaultState();
public IBlockState getBlockState(int x, int y, int z) { public IBlockState getBlockState(int x, int y, int z) {
@ -32,11 +34,20 @@ public class ChunkPrimer {
} }
public IBlockState getBlockState(int index) { public IBlockState getBlockState(int index) {
if (index >= 0 && index < this.data.length) { if (MathHelper.fastMath) {
IBlockState iblockstate = (IBlockState) Block.BLOCK_STATE_IDS.getByValue(this.data[index]); if (index >= 0 && index < this.data.length) {
return iblockstate != null ? iblockstate : this.defaultState; IBlockState iblockstate = (IBlockState) Block.BLOCK_STATE_IDS.getByValue(this.data[index]);
} else { return iblockstate != null ? iblockstate : this.defaultState;
throw new IndexOutOfBoundsException("The coordinate is out of range"); } else {
throw new IndexOutOfBoundsException("The coordinate is out of range");
}
} else {
if (index >= 0 && index < this.data_fast.length) {
IBlockState iblockstate = (IBlockState) Block.BLOCK_STATE_IDS.getByValue(this.data_fast[index]);
return iblockstate != null ? iblockstate : this.defaultState;
} else {
throw new IndexOutOfBoundsException("The coordinate is out of range");
}
} }
} }
@ -46,10 +57,18 @@ public class ChunkPrimer {
} }
public void setBlockState(int index, IBlockState state) { public void setBlockState(int index, IBlockState state) {
if (index >= 0 && index < this.data.length) { if(MathHelper.fastMath) {
this.data[index] = (short) Block.BLOCK_STATE_IDS.get(state); if (index >= 0 && index < this.data.length) {
} else { this.data[index] = (short) Block.BLOCK_STATE_IDS.get(state);
throw new IndexOutOfBoundsException("The coordinate is out of range"); } else {
throw new IndexOutOfBoundsException("The coordinate is out of range");
}
} else {
if (index >= 0 && index < this.data_fast.length) {
this.data_fast[index] = (short) Block.BLOCK_STATE_IDS.get(state);
} else {
throw new IndexOutOfBoundsException("The coordinate is out of range");
}
} }
} }
} }