Optifine Performance Tab

This commit is contained in:
peytonplayz595 2023-09-10 07:10:35 -05:00
parent f53639c0ed
commit fedbf2bc8f
11 changed files with 359 additions and 80 deletions

View File

@ -134,6 +134,10 @@ public class Config {
return Minecraft.getMinecraft().gameSettings.ofFogStart;
}
public static int getUpdatesPerFrame() {
return Minecraft.getMinecraft().gameSettings.ofChunkUpdates;
}
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) {
return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
}

View File

@ -0,0 +1,70 @@
package net.PeytonPlayz585.shadow.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptionButton;
import net.minecraft.client.gui.GuiOptionSlider;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
public class GuiPerformance extends GuiScreen {
private GuiScreen prevScreen;
protected String title;
private GameSettings settings;
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.SMOOTH_FPS, GameSettings.Options.FAST_MATH, GameSettings.Options.CHUNK_UPDATES};
public GuiPerformance(GuiScreen p_i52_1_) {
this.prevScreen = p_i52_1_;
this.settings = Minecraft.getMinecraft().gameSettings;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui() {
this.title = I18n.format("of.options.performanceTitle", new Object[0]);
this.buttonList.clear();
for (int i = 0; i < enumOptions.length; ++i) {
GameSettings.Options gamesettings$options = enumOptions[i];
int j = width / 2 - 155 + i % 2 * 160;
int k = height / 6 + 21 * (i / 2) - 12;
if (!gamesettings$options.getEnumFloat()) {
this.buttonList.add(new GuiOptionButton(gamesettings$options.returnEnumOrdinal(), j, k, gamesettings$options, this.settings.getKeyBinding(gamesettings$options)));
} else {
this.buttonList.add(new GuiOptionSlider(gamesettings$options.returnEnumOrdinal(), j, k, gamesettings$options));
}
}
this.buttonList.add(new GuiButton(200, width / 2 - 100, height / 6 + 168 + 11, I18n.format("gui.done", new Object[0])));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id < 200 && button instanceof GuiOptionButton) {
this.settings.setOptionValue(((GuiOptionButton)button).returnEnumOptions(), 1);
button.displayString = this.settings.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
}
if (button.id == 200) {
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.prevScreen);
}
}
}
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, this.title, width / 2, 15, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@ -29,7 +29,7 @@ public class GuiShaders extends GuiScreen {
this.buttonList.add(new GuiButton(6, j1 / 4 * 3 - k1 / 2, height - 25, k1, j, I18n.format("gui.done", new Object[0])));
this.buttonList.add(button = new GuiButton(201, j1 / 4 - k1 / 2, height - 25, k1, j, "Shaders Folder"));
button.enabled = false;
this.buttonList.add(shaderProfile = new GuiOptionButton(201, k, height - 25, shaderProfile2, Minecraft.getMinecraft().gameSettings.getKeyBinding(shaderProfile2)));
this.buttonList.add(shaderProfile = new GuiOptionButton(201, k, height - 25, i, j, shaderProfile2, Minecraft.getMinecraft().gameSettings.getKeyBinding(shaderProfile2)));
shaderProfile.enabled = Minecraft.getMinecraft().gameSettings.shaders;
this.list = new GuiShaders.List(this.mc);
this.list.registerScrollButtons(7, 8);

View File

@ -0,0 +1,59 @@
package net.PeytonPlayz585.shadow.other;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class PlayerControllerOF extends PlayerControllerMP {
private boolean acting = false;
public PlayerControllerOF(Minecraft p_i73_1_, NetHandlerPlayClient p_i73_2_) {
super(p_i73_1_, p_i73_2_);
}
/**
* Called when the player is hitting a block with an item.
*/
public boolean clickBlock(BlockPos loc, EnumFacing face) {
this.acting = true;
boolean flag = super.clickBlock(loc, face);
this.acting = false;
return flag;
}
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing) {
this.acting = true;
boolean flag = super.onPlayerDamageBlock(posBlock, directionFacing);
this.acting = false;
return flag;
}
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn) {
this.acting = true;
boolean flag = super.sendUseItem(playerIn, worldIn, itemStackIn);
this.acting = false;
return flag;
}
public boolean onPlayerRightClick(EntityPlayerSP player, WorldClient worldIn, ItemStack heldStack, BlockPos hitPos, EnumFacing side, Vec3 hitVec) {
this.acting = true;
boolean flag = super.onPlayerRightClick(player, worldIn, heldStack, hitPos, side, hitVec);
this.acting = false;
return flag;
}
public boolean isActing() {
return this.acting;
}
}

View File

@ -37,6 +37,11 @@ public class GuiOptionButton extends GuiButton {
this.enumOptions = parOptions;
}
public GuiOptionButton(int parInt1, int parInt2, int parInt3, int parInt4, int parInt5, GameSettings.Options parOptions, String parString1) {
super(parInt1, parInt2, parInt3, parInt4, parInt5, parString1);
this.enumOptions = parOptions;
}
public GameSettings.Options returnEnumOptions() {
return this.enumOptions;
}

View File

@ -137,6 +137,10 @@ public class GuiVideoSettings extends GuiScreen {
this.mc.displayGuiScreen(new GuiQuality(this));
}
if(parGuiButton.id == 212) {
this.mc.displayGuiScreen(new GuiPerformance(this));
}
if (this.guiGameSettings.guiScale != i) {
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int j = scaledresolution.getScaledWidth();

View File

@ -1,5 +1,6 @@
package net.minecraft.client.multiplayer;
import net.PeytonPlayz585.shadow.other.PlayerControllerOF;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import java.util.Set;
import java.util.concurrent.Callable;
@ -72,6 +73,7 @@ public class WorldClient extends World {
private final Set<Entity> entitySpawnQueue = Sets.newHashSet();
private final Minecraft mc = Minecraft.getMinecraft();
private final Set<ChunkCoordIntPair> previousActiveChunkSet = Sets.newHashSet();
private boolean playerUpdate = false;
public WorldClient(NetHandlerPlayClient parNetHandlerPlayClient, WorldSettings parWorldSettings, int parInt1,
EnumDifficulty parEnumDifficulty, Profiler parProfiler) {
@ -85,6 +87,10 @@ public class WorldClient extends World {
this.mapStorage = new SaveDataMemoryStorage();
this.calculateInitialSkylight();
this.calculateInitialWeather();
if (this.mc.playerController != null && this.mc.playerController.getClass() == PlayerControllerMP.class) {
this.mc.playerController = new PlayerControllerOF(this.mc, parNetHandlerPlayClient);
}
}
/**+
@ -428,4 +434,30 @@ public class WorldClient extends World {
super.setWorldTime(i);
}
/**
* Sets the block state at a given location. Flag 1 will cause a block update. Flag 2 will send the change to
* clients (you almost always want this). Flag 4 prevents the block from being re-rendered, if this is a client
* world. Flags can be added together.
*/
@Override
public boolean setBlockState(BlockPos pos, IBlockState newState, int flags) {
this.playerUpdate = this.isPlayerActing();
boolean flag = super.setBlockState(pos, newState, flags);
this.playerUpdate = false;
return flag;
}
private boolean isPlayerActing() {
if (this.mc.playerController instanceof PlayerControllerOF) {
PlayerControllerOF playercontrollerof = (PlayerControllerOF)this.mc.playerController;
return playercontrollerof.isActing();
} else {
return false;
}
}
public boolean isPlayerUpdate() {
return this.playerUpdate;
}
}

View File

@ -1190,6 +1190,12 @@ public class EntityRenderer implements IResourceManagerReloadListener {
}
this.mc.mcProfiler.endStartSection("terrain");
if (this.mc.gameSettings.ofSmoothFps && pass > 0) {
this.mc.mcProfiler.endStartSection("finish");
this.mc.mcProfiler.endStartSection("terrain");
}
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.pushMatrix();
GlStateManager.disableAlpha();

View File

@ -5,6 +5,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -187,6 +188,9 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
private int renderDistance = 0;
private int renderDistanceSq = 0;
public Set chunksToResortTransparency = new LinkedHashSet();
public Set chunksToUpdateForced = new LinkedHashSet();
public RenderGlobal(Minecraft mcIn) {
this.mc = mcIn;
this.renderManager = mcIn.getRenderManager();
@ -957,12 +961,15 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
RenderChunk renderchunk4 = renderglobal$containerlocalrenderinformation2.renderChunk;
if (renderchunk4.isNeedsUpdate() || set.contains(renderchunk4)) {
this.displayListEntitiesDirty = true;
if (this.mc.gameSettings.chunkFix ? this.isPositionInRenderChunkHack(blockpos1, renderchunk4)
: this.isPositionInRenderChunk(blockpos, renderchunk4)) {
if (this.mc.gameSettings.chunkFix ? this.isPositionInRenderChunkHack(blockpos1, renderchunk4) : this.isPositionInRenderChunk(blockpos, renderchunk4)) {
if (!renderchunk4.isPlayerUpdate()) {
this.chunksToUpdateForced.add(renderchunk4);
} else {
this.mc.mcProfiler.startSection("build near");
this.renderDispatcher.updateChunkNow(renderchunk4);
renderchunk4.setNeedsUpdate(false);
this.mc.mcProfiler.endSection();
}
} else {
this.chunksToUpdate.add(renderchunk4);
}
@ -1081,22 +1088,26 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
public int renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass, Entity entityIn) {
RenderHelper.disableStandardItemLighting();
if (blockLayerIn == EnumWorldBlockLayer.TRANSLUCENT) {
this.mc.mcProfiler.startSection("translucent_sort");
double d0 = entityIn.posX - this.prevRenderSortX;
double d1 = entityIn.posY - this.prevRenderSortY;
double d2 = entityIn.posZ - this.prevRenderSortZ;
if (d0 * d0 + d1 * d1 + d2 * d2 > 1.0D) {
this.prevRenderSortX = entityIn.posX;
this.prevRenderSortY = entityIn.posY;
this.prevRenderSortZ = entityIn.posZ;
int k = 0;
Iterator iterator = this.renderInfos.iterator();
this.chunksToResortTransparency.clear();
for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos) {
if (renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk
.isLayerStarted(blockLayerIn) && k++ < 15) {
this.renderDispatcher
.updateTransparencyLater(renderglobal$containerlocalrenderinformation.renderChunk);
while (iterator.hasNext()) {
RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = (RenderGlobal.ContainerLocalRenderInformation)iterator.next();
if (renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk.isLayerStarted(blockLayerIn) && k++ < 15) {
this.chunksToResortTransparency.add(renderglobal$containerlocalrenderinformation.renderChunk);
}
}
}
@ -1112,14 +1123,18 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
int j1 = flag ? -1 : 1;
for (int j = i1; j != i; j += j1) {
RenderChunk renderchunk = ((RenderGlobal.ContainerLocalRenderInformation) this.renderInfos
.get(j)).renderChunk;
RenderChunk renderchunk = ((RenderGlobal.ContainerLocalRenderInformation)this.renderInfos.get(j)).renderChunk;
if (!renderchunk.getCompiledChunk().isLayerEmpty(blockLayerIn)) {
++l;
this.renderContainer.addRenderChunk(renderchunk, blockLayerIn);
}
}
if (l == 0) {
this.mc.mcProfiler.endSection();
return l;
} else {
if (Config.isFogOff() && this.mc.entityRenderer.fogStandard) {
GlStateManager.disableFog();
}
@ -1129,6 +1144,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
this.mc.mcProfiler.endSection();
return l;
}
}
public static interface ChunkCullAdapter {
boolean shouldCull(RenderChunk chunk);
@ -1802,22 +1818,61 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
}
public void updateChunks(long finishTimeNano) {
finishTimeNano = (long)((double)finishTimeNano + 1.0E8D);
this.displayListEntitiesDirty |= this.renderDispatcher.updateChunks(finishTimeNano);
if (!this.chunksToUpdate.isEmpty()) {
Iterator iterator = this.chunksToUpdate.iterator();
if (this.chunksToUpdateForced.size() > 0) {
Iterator iterator = this.chunksToUpdateForced.iterator();
while (iterator.hasNext()) {
RenderChunk renderchunk = (RenderChunk)iterator.next();
if (!this.renderDispatcher.updateChunkLater(renderchunk)) {
break;
}
renderchunk.setNeedsUpdate(false);
iterator.remove();
long i = finishTimeNano - System.nanoTime();
if (i < 0L) {
this.chunksToUpdate.remove(renderchunk);
this.chunksToResortTransparency.remove(renderchunk);
}
}
if (this.chunksToResortTransparency.size() > 0) {
Iterator iterator2 = this.chunksToResortTransparency.iterator();
if (iterator2.hasNext()) {
RenderChunk renderchunk2 = (RenderChunk)iterator2.next();
if (this.renderDispatcher.updateTransparencyLater(renderchunk2)) {
iterator2.remove();
}
}
}
int j = 0;
int k = Config.getUpdatesPerFrame();
int i = k * 2;
Iterator iterator1 = this.chunksToUpdate.iterator();
while (iterator1.hasNext()) {
RenderChunk renderchunk1 = (RenderChunk)iterator1.next();
if (!this.renderDispatcher.updateChunkLater(renderchunk1)) {
break;
}
renderchunk1.setNeedsUpdate(false);
iterator1.remove();
if (renderchunk1.getCompiledChunk().isEmpty() && k < i) {
++k;
}
++j;
if (j >= k) {
break;
}
}
}

View File

@ -17,6 +17,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.RegionRenderCache;
import net.minecraft.client.renderer.RenderGlobal;
@ -71,8 +72,8 @@ public class RenderChunk {
public ShadowFrustumState shadowLOD0InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD1InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD2InFrustum = ShadowFrustumState.OUTSIDE;
//private EnumMap<EnumFacing, BlockPos> field_181702_p = Maps.newEnumMap(EnumFacing.class);
private BlockPos[] positionOffsets16 = new BlockPos[EnumFacing.VALUES.length];
private boolean playerUpdate = false;
public RenderChunk(World worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn) {
this.world = worldIn;
@ -300,12 +301,33 @@ public class RenderChunk {
public void setNeedsUpdate(boolean needsUpdateIn) {
this.needsUpdate = needsUpdateIn;
if (this.needsUpdate) {
if (this.isWorldPlayerUpdate()) {
this.playerUpdate = true;
}
} else {
this.playerUpdate = false;
}
}
public boolean isNeedsUpdate() {
return this.needsUpdate;
}
private boolean isWorldPlayerUpdate() {
if (this.world instanceof WorldClient) {
WorldClient worldclient = (WorldClient)this.world;
return worldclient.isPlayerUpdate();
} else {
return false;
}
}
public boolean isPlayerUpdate() {
return this.playerUpdate;
}
public BlockPos func_181701_a(EnumFacing p_181701_1_) {
return this.getPositionOffset16(p_181701_1_);
}

View File

@ -73,14 +73,6 @@ public class GameSettings {
"options.particles.minimal" };
private static final String[] AMBIENT_OCCLUSIONS = new String[] { "options.ao.off", "options.ao.min",
"options.ao.max" };
private static final String[] STREAM_COMPRESSIONS = new String[] { "options.stream.compression.low",
"options.stream.compression.medium", "options.stream.compression.high" };
private static final String[] STREAM_CHAT_MODES = new String[] { "options.stream.chat.enabled.streaming",
"options.stream.chat.enabled.always", "options.stream.chat.enabled.never" };
private static final String[] STREAM_CHAT_FILTER_MODES = new String[] { "options.stream.chat.userFilter.all",
"options.stream.chat.userFilter.subs", "options.stream.chat.userFilter.mods" };
private static final String[] STREAM_MIC_MODES = new String[] { "options.stream.mic_toggle.mute",
"options.stream.mic_toggle.talk" };
private static final String[] field_181149_aW = new String[] { "options.off", "options.graphics.fast",
"options.graphics.fancy" };
public float mouseSensitivity = 0.5F;
@ -226,6 +218,10 @@ public class GameSettings {
public boolean ofAnimatedTerrain = true;
public boolean ofAnimatedTextures = true;
//Performance Settings
public boolean ofSmoothFps = false;
public int ofChunkUpdates = 1;
//Super Secret Setting :>
public boolean secret = false;
@ -628,6 +624,18 @@ public class GameSettings {
shader.updateShaderProfile(profile);
}
if (parOptions == GameSettings.Options.SMOOTH_FPS) {
this.ofSmoothFps = !this.ofSmoothFps;
}
if (parOptions == GameSettings.Options.CHUNK_UPDATES) {
++this.ofChunkUpdates;
if (this.ofChunkUpdates > 5) {
this.ofChunkUpdates = 1;
}
}
this.saveOptions();
}
@ -698,6 +706,8 @@ public class GameSettings {
return this.ofCustomSky;
case CLEAR_WATER:
return this.ofClearWater;
case SMOOTH_FPS:
return this.ofSmoothFps;
default:
return false;
}
@ -757,7 +767,6 @@ public class GameSettings {
if (this.fancyGraphics) {
return s + I18n.format("options.graphics.fancy", new Object[0]);
} else {
String s1 = "options.graphics.fast";
return s + I18n.format("options.graphics.fast", new Object[0]);
}
} else if (parOptions == GameSettings.Options.FXAA) {
@ -870,6 +879,10 @@ public class GameSettings {
default:
return s + "Low";
}
} else if (parOptions == GameSettings.Options.SMOOTH_FPS) {
return this.ofSmoothFps ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.CHUNK_UPDATES) {
return s + this.ofChunkUpdates;
} else {
return s;
}
@ -1273,6 +1286,15 @@ public class GameSettings {
System.out.println("Loaded Shader Profile: " + this.profile);
}
if (astring[0].equals("ofSmoothFps") && astring.length >= 2) {
this.ofSmoothFps = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofChunkUpdates") && astring.length >= 2) {
this.ofChunkUpdates = Integer.valueOf(astring[1]).intValue();
this.ofChunkUpdates = Config.limit(this.ofChunkUpdates, 1, 5);
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory.values()) {
@ -1402,24 +1424,22 @@ public class GameSettings {
printwriter.println("ofBetterGrass:" + this.ofBetterGrass);
printwriter.println("ofFogType:" + this.ofFogType);
printwriter.println("ofFogStart:" + this.ofFogStart);
//printwriter.print("secret:" + this.secret);
switch(this.profile) {
case 1:
printwriter.println("profile:low");
break;
case 2:
printwriter.println("profile:mid");
break;
case 3:
printwriter.println("profile:high");
break;
case 4:
printwriter.println("profile:ultra");
break;
}
printwriter.println("ofSmoothFps:" + this.ofSmoothFps);
printwriter.println("ofChunkUpdates:" + this.ofChunkUpdates);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1587,7 +1607,9 @@ public class GameSettings {
BETTER_GRASS("Better Grass", false, false),
FOG_FANCY("Fog", false, false),
FOG_START("Fog Start", false, false),
SHADER_PROFILE("Profile", false, false);
SHADER_PROFILE("Profile", false, false),
SMOOTH_FPS("Smooth FPS", false, false),
CHUNK_UPDATES("Chunk Updates", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;