Skip to content

Commit

Permalink
Added chunk preloading support
Browse files Browse the repository at this point in the history
  • Loading branch information
ata4 committed Aug 22, 2014
1 parent 788356f commit 4de9acd
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import info.ata4.minecraft.mineshot.client.config.MineshotConfig;
import info.ata4.minecraft.mineshot.client.config.MineshotConfigGuiIngame;
import info.ata4.minecraft.mineshot.client.util.ChatUtils;
import info.ata4.minecraft.mineshot.util.reflection.RenderGlobalAccessor;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.settings.KeyBinding;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -69,6 +71,9 @@ public void onKeyInput(InputEvent.KeyInputEvent event) {
} else {
task = new CaptureTask(config, taskFile);
}
if (config.preloadChunks.get()) {
preloadChunks();
}
}
}
}
Expand All @@ -90,8 +95,16 @@ public void onRenderTick(RenderTickEvent evt) {
task = null;
}
}


private void preloadChunks() {
WorldRenderer[] worldRenderers = RenderGlobalAccessor.getWorldRenderers(MC.renderGlobal);
for (WorldRenderer worldRenderer : worldRenderers) {
if (worldRenderer.isInFrustum && worldRenderer.needsUpdate) {
worldRenderer.updateRenderer(MC.renderViewEntity);
}
}
}

private File getScreenshotFile() {
File dir = new File(MC.mcDataDir, "screenshots");
if (!dir.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static Dimension getMaxViewportDims() {
public final ConfigInteger captureWidth = new ConfigInteger(3840, 1, MAX_TARGA_SIZE);
public final ConfigInteger captureHeight = new ConfigInteger(2160, 1, MAX_TARGA_SIZE);
public final ConfigBoolean captureTiled = new ConfigBoolean(false);
public final ConfigBoolean preloadChunks = new ConfigBoolean(true);

public MineshotConfig(Configuration config) {
super(config);
Expand All @@ -54,5 +55,6 @@ public MineshotConfig(Configuration config) {
register(captureWidth, "captureWidth", Configuration.CATEGORY_GENERAL);
register(captureHeight, "captureHeight", Configuration.CATEGORY_GENERAL);
register(captureTiled, "captureTiled", Configuration.CATEGORY_GENERAL);
register(preloadChunks, "preloadChunks", Configuration.CATEGORY_GENERAL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
** 2014 August 22
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
*/
package info.ata4.minecraft.mineshot.util.reflection;

import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
*
* @author Nico Bergemann <barracuda415 at yahoo.de>
*/
public class RenderGlobalAccessor {

private static final Logger L = LogManager.getLogger();
private static final String[] FIELD_WORLDRENDERERS = new String[] {"worldRenderers", "field_72765_l"};

private RenderGlobalAccessor() {
}

public static WorldRenderer[] getWorldRenderers(RenderGlobal rg) {
try {
return ReflectionHelper.getPrivateValue(RenderGlobal.class, rg, FIELD_WORLDRENDERERS);
} catch (Exception ex) {
L.error("getWordRenderers() failed", ex);
return new WorldRenderer[]{};
}
}
}
15 changes: 9 additions & 6 deletions src/main/resources/assets/mineshot/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ mineshot.gui.warn.gui=Benutzeroberfläche kann nicht aufgenommen werden!
mineshot.gui.err.toolarge.targa=Zu groß für das Targa Format!

# config
mineshot.config.captureWidth=Width
mineshot.config.captureWidth.tooltip=Screenshot Breite
mineshot.config.captureWidth=Breite
mineshot.config.captureWidth.tooltip=Breite des aufzunehmenden Screenshots

mineshot.config.captureHeight=Height
mineshot.config.captureHeight.tooltip=Screenshot Höhe
mineshot.config.captureHeight=Höhe
mineshot.config.captureHeight.tooltip=Höhe des aufzunehmenden Screenshots

mineshot.config.captureTiled=Kachelrendering
mineshot.config.captureTiled.tooltip=Der Screenshot wird in mehreren kleinen Kacheln gerendert wenn akiviert. Dadurch können wesentlich größere Screenshots aufgenommen als normal möglich. Allerdings funktionieren dann manche Shader nicht richtig und die Benutzeroberfläche ist unsichtbar.
mineshot.config.captureTiled=Kachelgrafik
mineshot.config.captureTiled.tooltip=Der Screenshot aus mehreren kleineren Screenshots zusammengesetzt. Dadurch können wesentlich größere Screenshots aufgenommen werden als normal möglich. Allerdings funktionieren dann manche Shader nicht mehr richtig und die Benutzeroberfläche ist unsichtbar.

mineshot.config.preloadChunks=Chunk-Preloading
mineshot.config.preloadChunks.tooltip=Alle sichtbaren Chunks werden vollständig geladen bevor der Screenshot erstellt wird.
7 changes: 5 additions & 2 deletions src/main/resources/assets/mineshot/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ mineshot.config.captureWidth.tooltip=Screenshot capture width
mineshot.config.captureHeight=Height
mineshot.config.captureHeight.tooltip=Screenshot capture height

mineshot.config.captureTiled=Tiled rendering
mineshot.config.captureTiled.tooltip=Renders the screenshot in multiple smaller tiles when activated. This allows much larger screenshots to be captured than usually possible, but causes problems with shaders and also disables the GUI.
mineshot.config.captureTiled=Tiled Rendering
mineshot.config.captureTiled.tooltip=Compose screenshots from multiple smaller screenshots. This allows much larger screenshots to be captured than usually possible, but causes problems with shaders and also disables the GUI.

mineshot.config.preloadChunks=Chunk Preloading
mineshot.config.preloadChunks.tooltip=Fully load all visible chunks before capturing the screenshot.

0 comments on commit 4de9acd

Please sign in to comment.