-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd5a1b7
commit fd0e12b
Showing
10 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/betterfpsdist/config/ConfigurationCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.betterfpsdist.config; | ||
|
||
public class ConfigurationCache | ||
{ | ||
public static double stretch = 1; | ||
} |
44 changes: 43 additions & 1 deletion
44
src/main/java/com/betterfpsdist/event/ClientEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,48 @@ | ||
package com.betterfpsdist.event; | ||
|
||
import com.betterfpsdist.BetterfpsdistMod; | ||
import com.betterfpsdist.config.ConfigurationCache; | ||
import net.minecraft.client.AbstractOption; | ||
import net.minecraft.client.gui.screen.VideoSettingsScreen; | ||
import net.minecraft.client.settings.SliderPercentageOption; | ||
import net.minecraft.util.text.StringTextComponent; | ||
import net.minecraftforge.client.event.GuiOpenEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ClientEventHandler | ||
{ | ||
|
||
public static final SliderPercentageOption RenderSizeStretch = new SliderPercentageOption("options.renderDistance", 0.5D, 10.0D, 0.25F, (value) -> { | ||
return ConfigurationCache.stretch; | ||
}, (setting, value) -> { | ||
ConfigurationCache.stretch = value; | ||
BetterfpsdistMod.config.getCommonConfig().stretch.set(value); | ||
}, (settings, value) -> { | ||
return new StringTextComponent("HRdistStretch:" + ConfigurationCache.stretch); | ||
}); | ||
static | ||
{ | ||
try | ||
{ | ||
final List<AbstractOption> options = new ArrayList<>(Arrays.asList(VideoSettingsScreen.OPTIONS)); | ||
options.add(options.indexOf(AbstractOption.GUI_SCALE) + 1, RenderSizeStretch); | ||
VideoSettingsScreen.OPTIONS = options.toArray(new AbstractOption[0]); | ||
} | ||
catch (Throwable e) | ||
{ | ||
BetterfpsdistMod.LOGGER.error("Error trying to add an option Button to video settings, likely optifine is present which removes vanilla functionality required." | ||
+ " The mod still works, but you'll need to manually adjust the config to get different Render distance stretch values as the button could not be added."); | ||
} | ||
} | ||
@SubscribeEvent | ||
public static void on(GuiOpenEvent event) | ||
{ | ||
if (event.isCanceled()) | ||
{ | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/com/betterfpsdist/mixin/LevelRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.betterfpsdist.mixin; | ||
|
||
import com.betterfpsdist.config.ConfigurationCache; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.WorldRenderer; | ||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; | ||
import net.minecraft.util.math.vector.Vector3d; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(WorldRenderer.class) | ||
public class LevelRendererMixin | ||
{ | ||
@Shadow | ||
@Final | ||
private Minecraft minecraft; | ||
private ChunkRenderDispatcher.ChunkRender current = null; | ||
//private HashSet<BlockPos> renderedPositions = new HashSet<>(); | ||
//private long nextUpdate = 0; | ||
|
||
@Redirect(method = "renderChunkLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$ChunkRender;getCompiledChunk()Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;")) | ||
public ChunkRenderDispatcher.CompiledChunk on(final ChunkRenderDispatcher.ChunkRender instance) | ||
{ | ||
current = instance; | ||
return instance.getCompiledChunk(); | ||
} | ||
|
||
@Redirect(method = "renderChunkLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;isEmpty(Lnet/minecraft/client/renderer/RenderType;)Z")) | ||
public boolean on(final ChunkRenderDispatcher.CompiledChunk instance, final RenderType type) | ||
{ | ||
boolean returnv = | ||
minecraft.cameraEntity != null && | ||
distSqr(minecraft.cameraEntity.position(), new Vector3d(current.getOrigin().getX(), current.getOrigin().getY(), current.getOrigin().getZ())) | ||
> (Minecraft.getInstance().options.renderDistance * 16) * (Minecraft.getInstance().options.renderDistance * 16) | ||
|| instance.isEmpty(type); | ||
|
||
/* | ||
if (Minecraft.getInstance().player.level.getGameTime() > nextUpdate) | ||
{ | ||
nextUpdate = Minecraft.getInstance().player.level.getGameTime() + 20 * 60; | ||
BetterfpsdistMod.LOGGER.warn("Rendered Sections:" + renderedPositions.size()); | ||
renderedPositions.clear(); | ||
} | ||
if (!returnv) | ||
{ | ||
renderedPositions.add(current.getOrigin()); | ||
}*/ | ||
|
||
return returnv; | ||
} | ||
|
||
private double distSqr(Vector3d from, Vector3d to) | ||
{ | ||
double d0 = from.x - to.x; | ||
double d1 = from.y - to.y; | ||
double d2 = from.z - to.z; | ||
return d0 * d0 + ConfigurationCache.stretch * (d1 * d1) + d2 * d2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
public net.minecraft.entity.LivingEntity func_184583_d(Lnet/minecraft/util/DamageSource;)Z # isDamageSourceBlocked | ||
public net.minecraft.world.end.DragonFightManager field_186109_c # dragonEvent | ||
public net.minecraft.entity.monster.IllusionerEntity$MirrorSpellGoal | ||
public-f net.minecraft.client.gui.screen.VideoSettingsScreen field_213107_d # OPTIONS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"mixins": [ | ||
], | ||
"client": [ | ||
"LevelRendererMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
|