Compare commits

3 Commits

Author SHA1 Message Date
William Hubbard
b367e81569 Update README.md
Closes the repository.
2022-03-11 23:05:27 +00:00
Markil3
bc89d27b85 Reduces the resolution of panoramas.
Do we really need 2048 x 2048? That's more than HD.
2021-03-17 12:07:40 -06:00
Markil3
4e8d9aaf3b Decides the folder for panoramas before we start rendering.
This prevents panoramas being split into different folders, since the time it takes to render these things is non-trivial.
2021-03-17 12:07:13 -06:00
2 changed files with 32 additions and 17 deletions

View File

@@ -9,3 +9,14 @@ Simply run the "gradle build" (or "./gradlew build" on OSX and Linux) to create
# Licensing
This mod is licensed under the GNU General Public License version 3.0. In short, you are allowed to use and modify this mod for whatever you wish (including commercial use), but all distributions (modified or otherwise) must be under the same license, contain the source code (with changes highlighted), and preserve the copyright notices.
# A Message on the Future of this Application.
*To anyone who finds this useful.*
*I've recently taken on a new job, and, due to the demands of a full-time developer job, I will no longer be able to finish this project. I've had a lot of fun with it, but continuing it for the future is simply unfeasible.*
*With that said, this application is fully open-source, and anyone is available to freely use it, modify it, or maintain their own copy. The only thing I require is that the copyright and license is preserved. I hope that you find this useful.
*May God bless you all,*
*Markil 3*

View File

@@ -3,21 +3,15 @@ package markil3.panorama;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ScreenShotHelper;
import net.minecraft.util.Util;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@@ -33,7 +27,7 @@ import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.stream.Collectors;
import java.util.Optional;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("panorama")
@@ -84,7 +78,7 @@ public class Main
File panoramas = new File(mc.gameDir, "panoramas");
if (panoramas.isDirectory())
{
for (File panorama : panoramas.listFiles())
for (File panorama : Optional.ofNullable(panoramas.listFiles()).orElse(new File[0]))
{
if (panorama.isDirectory())
{
@@ -129,41 +123,51 @@ public class Main
static void renderPanorama(Minecraft mc)
{
final SimpleDateFormat FORMATTER =
new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
final int SCREENSHOT_WIDTH = 2048;
final int SCREENSHOT_HEIGHT = 2048;
String name;
RenderSystem.viewport(0, 0, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
if (mc.world != null)
{
name = FORMATTER.format(new Date());
// We need to render an extra frame at the beginning, or
// otherwise it won't render correctly.
for (int i = -1; i < 6; i++)
{
mc.gameRenderer.renderWorld(mc.getRenderPartialTicks(),
Util.nanoTime(), new MatrixStack());
saveScreenshot(mc, 0, i);
saveScreenshot(mc, name, i);
}
}
}
static void saveScreenshot(Minecraft mc, int panoramaNum, int panoramaSide)
static void saveScreenshot(Minecraft mc, String name, int panoramaSide)
{
final SimpleDateFormat FORMATTER =
new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
final int FRAMEBUFFER_WIDTH = mc.getMainWindow().getFramebufferWidth();
final int FRAMEBUFFER_HEIGHT =
mc.getMainWindow().getFramebufferHeight();
final int SCREENSHOT_WIDTH = 2048;
final int SCREENSHOT_HEIGHT = 2048;
final int SCREENSHOT_WIDTH = 1024;
final int SCREENSHOT_HEIGHT = 1024;
File file = new File(mc.gameDir,
"panoramas/" + FORMATTER.format(new Date()) + "/panorama_" + panoramaSide +
"panoramas/" + name + "/panorama_" + panoramaSide +
".png");
file.getParentFile().mkdirs();
try
{
file.createNewFile();
if (!file.getParentFile().mkdirs())
{
throw new IOException("Could not create panorama directory " + file.getParent());
}
if (!file.createNewFile())
{
throw new IOException("Could not create file " + file.getAbsolutePath());
}
}
catch (IOException e)
{