Compare commits

2 Commits

Author SHA1 Message Date
William Hubbard
5be1082c72 Update README.md
Closes the repository.
2022-03-11 23:05:43 +00:00
Markil3
70ff889711 Sets up the game to run in fabric. 2021-03-07 12:17:02 -07:00
21 changed files with 512 additions and 409 deletions

View File

@@ -9,3 +9,14 @@ Simply run the "gradle build" (or "./gradlew build" on OSX and Linux) to create
# Licensing # 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. 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

@@ -1,165 +1,90 @@
buildscript { plugins {
repositories { id 'fabric-loom' version '0.5-SNAPSHOT'
maven { url = 'https://files.minecraftforge.net/maven' } id 'maven-publish'
jcenter()
mavenCentral()
} }
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true sourceCompatibility = JavaVersion.VERSION_1_8
} targetCompatibility = JavaVersion.VERSION_1_8
}
apply plugin: 'net.minecraftforge.gradle' archivesBaseName = project.archives_base_name
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. version = project.mod_version + "-" + project.minecraft_version + "-fabric"
apply plugin: 'eclipse' group = project.maven_group
apply plugin: 'maven-publish'
repositories { repositories {
maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
} }
archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version + "-forge"
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: project.mappings
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
examplemod {
source sourceSets.main
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies { dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // To change the versions see the gradle.properties file
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. minecraft "com.mojang:minecraft:${project.minecraft_version}"
// The userdev artifact is a special name and will get all sorts of transformations applied to it. mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
compile(fg.deobf("me.shedaniel.cloth:cloth-config-forge:${project.cloth_version}")) modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// You may put jars on which you depend on in ./libs or you may define them like so.. modApi "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}"
// compile "some.group:artifact:version:classifier" modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
} }
task sourcesJar(type: Jar, dependsOn: classes) { processResources {
classifier = 'sources' inputs.property "version", project.version
from sourceSets.main.allSource
filesMatching("fabric.mod.json") {
expand "version": project.version
}
} }
artifacts { tasks.withType(JavaCompile).configureEach {
archives sourcesJar // ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
} }
// Example for how to get properties into the manifest for reading by the runtime..
jar { jar {
manifest { from("LICENSE") {
attributes([ rename { "${it}_${project.archivesBaseName}"}
"Specification-Title": project.archivesBaseName,
"Specification-Vendor": "Markil 3",
"Specification-Version": project.version,
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"Markil 3",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
} }
} }
// Example configuration to allow publishing using the maven-publish task // configure the maven publication
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
artifact jar // add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
} }
} }
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories { repositories {
maven { // Add repositories to publish to here.
url "file:///${project.projectDir}/mcmodsrepo" // Notice: This block does NOT have the same function as the block in the top level.
} // The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
} }
} }

View File

@@ -1,14 +1,15 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. # Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process. # This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx1G
org.gradle.daemon=false
# Forge Properties # Forge Properties
minecraft_version=1.16.4 minecraft_version=1.16.2
mappings=20201028-1.16.3 yarn_mappings=1.16.2+build.47
forge_version=35.1.37 loader_version=0.11.1
fabric_version=0.31.0+1.16
cloth_version=4.11.14 cloth_version=4.11.14
modmenu_version=1.16.8
# Mod Properties # Mod Properties
mod_version = 1.0 mod_version = 1.0

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip

53
gradlew vendored
View File

@@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else else
eval `echo args$i`="\"$arg\"" eval `echo args$i`="\"$arg\""
fi fi
i=$((i+1)) i=`expr $i + 1`
done done
case $i in case $i in
(0) set -- ;; 0) set -- ;;
(1) set -- "$args0" ;; 1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;; 2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;; 3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " " echo " "
} }
APP_ARGS=$(save "$@") APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View File

@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

9
settings.gradle Normal file
View File

@@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@@ -1,119 +1,37 @@
package markil3.panorama; package markil3.panorama;
import net.minecraft.client.Minecraft; import net.minecraft.client.render.Camera;
import net.minecraft.client.gui.screen.MainMenuScreen;
import net.minecraft.client.renderer.RenderSkybox; import markil3.panorama.mixins.CameraAccessor;
import net.minecraft.client.renderer.RenderSkyboxCube;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.ScreenshotEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(Dist.CLIENT)
public class EventBus public class EventBus
{ {
static int screenshotState = 0; public static void onCamera(Camera event)
@SubscribeEvent
public static void onScreenshot(ScreenshotEvent event)
{ {
// event.setCanceled(true); if (Main.isRenderingPanorama())
screenshotState = 1;
}
@SubscribeEvent
public static void onRender(TickEvent.RenderTickEvent event)
{ {
if (event.phase == TickEvent.Phase.START && screenshotState > 0) switch (Main.getPanoramaStage() - 2)
{
Main.renderPanorama(Minecraft.getInstance());
screenshotState = 0;
}
}
@SubscribeEvent
public static void onRenderHand(RenderHandEvent event)
{
if (screenshotState > 0)
{
event.setCanceled(true);
}
}
@SubscribeEvent
public static void onFov(EntityViewRenderEvent.FOVModifier event)
{
if (screenshotState > 0)
{
event.setFOV(90);
}
}
@SubscribeEvent
public static void onCamera(EntityViewRenderEvent.CameraSetup event)
{
if (screenshotState > 0)
{
event.setRoll(0);
switch (screenshotState - 2)
{ {
default: default:
case 0: case 0:
event.setYaw(0F); ((CameraAccessor) event).setView(0, 0);
event.setPitch(0);
break; break;
case 1: case 1:
event.setYaw(90); ((CameraAccessor) event).setView(90, 0);
event.setPitch(0);
break; break;
case 2: case 2:
event.setYaw(180); ((CameraAccessor) event).setView(180, 0);
event.setPitch(0);
break; break;
case 3: case 3:
event.setYaw(270); ((CameraAccessor) event).setView(270, 0);
event.setPitch(0);
break; break;
case 4: case 4:
event.setYaw(0); ((CameraAccessor) event).setView(0, -90);
event.setPitch(-90);
break; break;
case 5: case 5:
event.setYaw(0); ((CameraAccessor) event).setView(0, 90);
event.setPitch(90);
break; break;
} }
screenshotState++;
}
}
@SubscribeEvent
public static void onShowScreen(GuiScreenEvent.InitGuiEvent event)
{
if (event instanceof GuiScreenEvent.InitGuiEvent.Pre)
{
if (Main.numPanoramas > 0)
{
int panorama =
MathHelper.floor(Math.random() * Main.numPanoramas);
MainMenuScreen screen;
if (event.getGui() instanceof MainMenuScreen)
{
// Main.loadPanoramas(Minecraft.getInstance());
screen = (MainMenuScreen) event.getGui();
screen.panorama =
new RenderSkybox(new RenderSkyboxCube(new ResourceLocation(
"panorama:textures/gui/title/background/" + panorama + "/panorama")));
System.out.printf("Displaying panorama %d\n", panorama);
}
}
} }
} }
} }

View File

@@ -1,48 +1,48 @@
package markil3.panorama; package markil3.panorama;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.resource.metadata.TextureResourceMetadata;
import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.resources.data.TextureMetadataSection; import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.resources.IResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
public class FileTexture extends SimpleTexture public class FileTexture extends ResourceTexture
{ {
private final File file; private final File file;
public FileTexture(ResourceLocation p_i1275_1_, File file) public FileTexture(Identifier p_i1275_1_, File file)
{ {
super(p_i1275_1_); super(p_i1275_1_);
this.file = file; this.file = file;
} }
@Override @Override
protected TextureData getTextureData(IResourceManager p_215246_1_) protected ResourceTexture.TextureData loadTextureData(ResourceManager p_215246_1_)
{ {
return getTextureData(p_215246_1_, this.file); return getTextureData(p_215246_1_, this.file);
} }
public static SimpleTexture.TextureData getTextureData(IResourceManager resourceManagerIn, public static ResourceTexture.TextureData getTextureData(ResourceManager resourceManagerIn,
File locationIn) File locationIn)
{ {
NativeImage image; NativeImage image;
TextureMetadataSection meta; TextureResourceMetadata meta;
try (FileInputStream stream = new FileInputStream(locationIn)) try (FileInputStream stream = new FileInputStream(locationIn))
{ {
image = image =
NativeImage.read(stream); NativeImage.read(stream);
meta = null; meta = null;
return new SimpleTexture.TextureData(null, return new ResourceTexture.TextureData(null,
image); image);
} }
catch (IOException e) catch (IOException e)
{ {
return new SimpleTexture.TextureData(e); return new ResourceTexture.TextureData(e);
} }
} }
} }

View File

@@ -1,30 +1,23 @@
package markil3.panorama; package markil3.panorama;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.Block; import net.fabricmc.api.ModInitializer;
import net.minecraft.block.Blocks; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
import net.minecraft.client.Minecraft; import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.gui.CubeMapRenderer;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.gui.RotatingCubeMapRenderer;
import net.minecraft.util.ResourceLocation; import net.minecraft.client.texture.NativeImage;
import net.minecraft.util.ScreenShotHelper; import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.ScreenshotUtils;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraft.util.profiler.Profiler;
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;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -33,55 +26,37 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.stream.Collectors; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
// The value here should match an entry in the META-INF/mods.toml file public class Main implements ModInitializer, IdentifiableResourceReloadListener
@Mod("panorama")
public class Main
{ {
// Directly reference a log4j logger. // Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
static int numPanoramas = 0; static int numPanoramas = 0;
private static int screenshotState = 0;
@Override
public void onInitialize()
{
// ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES)
// .registerReloadListener(this);
}
public Main() public Main()
{ {
// Register the setup method for modloading
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::setup);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::processIMC);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::doClientStuff);
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::onStitch);
// Register ourselves for server and other game events we are
// interested in
MinecraftForge.EVENT_BUS.register(this);
} }
public void onStitch(ModelBakeEvent event) static void loadPanoramas(MinecraftClient mc,
{ ResourceManager manager,
Main.loadPanoramas(Minecraft.getInstance()); Executor prepareExecutor,
} Executor applyExecutor)
static void loadPanoramas(Minecraft mc)
{ {
int i = 0; int i = 0;
int j; int j;
TextureManager textureManager = mc.textureManager; TextureManager textureManager = mc.getTextureManager();
ResourceLocation loc; File panoramas = new File(mc.runDirectory, "panoramas");
File panoramas = new File(mc.gameDir, "panoramas");
if (panoramas.isDirectory()) if (panoramas.isDirectory())
{ {
for (File panorama : panoramas.listFiles()) for (File panorama : panoramas.listFiles())
@@ -90,12 +65,17 @@ public class Main
{ {
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
{ {
loc = new ResourceLocation( int finalI = i;
"panorama:textures/gui/title/background/" + i + "/panorama_" + j + ".png"); int finalJ = j;
textureManager.loadTexture(loc, Identifier loc = new Identifier(
"panorama:textures/gui/title" +
"/background/" + finalI +
"/panorama_" + finalJ + ".png");
textureManager.registerTexture(loc,
new FileTexture(loc, new FileTexture(loc,
new File(panorama, new File(panorama,
"panorama_" + j + ".png"))); "panorama_" + finalJ +
".png")));
} }
i++; i++;
} }
@@ -104,61 +84,79 @@ public class Main
numPanoramas = i; numPanoramas = i;
} }
private void setup(final FMLCommonSetupEvent event) public static boolean isRenderingPanorama()
{ {
return screenshotState > 0;
} }
private void doClientStuff(final FMLClientSetupEvent event) public static int getPanoramaStage()
{ {
// loadPanoramas(event.getMinecraftSupplier().get()); return screenshotState;
} }
private void enqueueIMC(final InterModEnqueueEvent event) public static int nextStage()
{ {
return ++screenshotState;
} }
private void processIMC(final InterModProcessEvent event) public static void startRenderingPanorama()
{ {
screenshotState = 1;
} }
// You can use SubscribeEvent and let the Event Bus discover methods to call public static void finishRenderingPanorama()
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event)
{ {
screenshotState = 0;
} }
static void renderPanorama(Minecraft mc) public static RotatingCubeMapRenderer getPanorama()
{ {
if (numPanoramas > 0)
{
int panorama =
MathHelper.floor(Math.random() * Main.numPanoramas);
return new RotatingCubeMapRenderer(new CubeMapRenderer(new Identifier(
"panorama:textures/gui/title/background/" + panorama +
"/panorama")));
}
return null;
}
public static void renderPanorama(MinecraftClient mc)
{
final SimpleDateFormat FORMATTER =
new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
final int SCREENSHOT_WIDTH = 2048; final int SCREENSHOT_WIDTH = 2048;
final int SCREENSHOT_HEIGHT = 2048; final int SCREENSHOT_HEIGHT = 2048;
String name;
RenderSystem.viewport(0, 0, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT); RenderSystem.viewport(0, 0, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
if (mc.world != null) if (mc.world != null)
{ {
name = FORMATTER.format(new Date());
// We need to render an extra frame at the beginning, or // We need to render an extra frame at the beginning, or
// otherwise it won't render correctly. // otherwise it won't render correctly.
for (int i = -1; i < 6; i++) for (int i = -1; i < 6; i++)
{ {
mc.gameRenderer.renderWorld(mc.getRenderPartialTicks(), mc.gameRenderer.renderWorld(mc.getTickDelta(),
Util.nanoTime(), new MatrixStack()); Util.getMeasuringTimeNano(), new MatrixStack());
saveScreenshot(mc, 0, i); saveScreenshot(mc, name, i);
nextStage();
} }
finishRenderingPanorama();
} }
} }
static void saveScreenshot(Minecraft mc, int panoramaNum, int panoramaSide) static void saveScreenshot(MinecraftClient mc,
String panoramaNum,
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_WIDTH = 2048;
final int SCREENSHOT_HEIGHT = 2048; final int SCREENSHOT_HEIGHT = 2048;
File file = new File(mc.gameDir, File file = new File(mc.runDirectory,
"panoramas/" + FORMATTER.format(new Date()) + "/panorama_" + panoramaSide + "panoramas/" + panoramaNum + "/panorama_" + panoramaSide +
".png"); ".png");
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
try try
@@ -169,11 +167,11 @@ public class Main
{ {
e.printStackTrace(); e.printStackTrace();
} }
NativeImage nativeimage = ScreenShotHelper.createScreenshot( NativeImage nativeimage = ScreenshotUtils.takeScreenshot(
SCREENSHOT_WIDTH, SCREENSHOT_WIDTH,
SCREENSHOT_HEIGHT, SCREENSHOT_HEIGHT,
mc.getFramebuffer()); mc.getFramebuffer());
Util.getRenderingService().execute(() -> { Util.getIoWorkerExecutor().execute(() -> {
int i = nativeimage.getWidth(); int i = nativeimage.getWidth();
int j = nativeimage.getHeight(); int j = nativeimage.getHeight();
int k = 0; int k = 0;
@@ -194,7 +192,7 @@ public class Main
false)) false))
{ {
nativeimage.resizeSubRectTo(k, l, i, j, nativeimage1); nativeimage.resizeSubRectTo(k, l, i, j, nativeimage1);
nativeimage1.write(file); nativeimage1.writeFile(file);
} }
catch (IOException ioexception) catch (IOException ioexception)
{ {
@@ -208,4 +206,25 @@ public class Main
}); });
} }
@Override
public Identifier getFabricId()
{
return new Identifier("panorama", "backgrounds");
}
@Override
public CompletableFuture<Void> reload(Synchronizer synchronizer,
ResourceManager manager,
Profiler prepareProfiler,
Profiler applyProfiler,
Executor prepareExecutor,
Executor applyExecutor)
{
loadPanoramas(MinecraftClient.getInstance(),
manager,
prepareExecutor,
applyExecutor);
return CompletableFuture.completedFuture(null);
}
} }

View File

@@ -0,0 +1,13 @@
package markil3.panorama.mixins;
import net.minecraft.client.render.Camera;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Camera.class)
public interface CameraAccessor
{
@Invoker("setRotation")
public void setView(float yaw, float pitch);
}

View File

@@ -0,0 +1,14 @@
package markil3.panorama.mixins;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(GameRenderer.class)
public interface GameRenderAccessor
{
@Accessor("renderingPanorama")
public void setPanoramic(boolean panoramic);
}

View File

@@ -0,0 +1,67 @@
package markil3.panorama.mixins;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import markil3.panorama.EventBus;
import markil3.panorama.Main;
@Mixin(GameRenderer.class)
public class GameRenderHook
{
@Inject(method = "render", at = @At(value = "HEAD"))
public void startPanora(float tickDelta, long startTime, boolean tick,
CallbackInfo callbackInfo)
{
if (Main.isRenderingPanorama())
{
Main.renderPanorama(MinecraftClient.getInstance());
}
}
@Inject(method = "renderWorld", at = @At(value = "HEAD"))
public void startPanora(float tickDelta,
long limitTime,
MatrixStack matrix,
CallbackInfo callbackInfo)
{
if (Main.isRenderingPanorama())
{
((GameRenderAccessor) MinecraftClient.getInstance().gameRenderer).setPanoramic(
true);
}
}
@Inject(method = "renderWorld", at = @At(value = "TAIL"))
public void finishPanora(float tickDelta,
long limitTime,
MatrixStack matrix,
CallbackInfo callbackInfo)
{
if (Main.isRenderingPanorama())
{
((GameRenderAccessor) MinecraftClient.getInstance().gameRenderer).setPanoramic(
false);
}
}
@Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet" +
"/minecraft/client/render/Camera;update" +
"(Lnet/minecraft/world/BlockView;Lnet/minecraft/entity/Entity;" +
"ZZF)V", shift = At.Shift.AFTER))
public void adjustCamera(float tickDelta,
long limitTime,
MatrixStack matrix,
CallbackInfo callbackInfo)
{
if (Main.isRenderingPanorama())
{
EventBus.onCamera(MinecraftClient.getInstance().gameRenderer.getCamera());
}
}
}

View File

@@ -0,0 +1,31 @@
package markil3.panorama.mixins;
import net.minecraft.client.Keyboard;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.util.ScreenshotUtils;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.io.File;
import java.util.function.Consumer;
import markil3.panorama.Main;
@Mixin(ScreenshotUtils.class)
public class ScreenshotHook
{
@Inject(method = "saveScreenshot", at = @At(value = "HEAD"))
private static void takeScreenshot(File gameDirectory,
int framebufferWidth,
int framebufferHeight,
Framebuffer framebuffer,
Consumer<Text> messageReceiver,
CallbackInfo callbackInfo)
{
Main.startRenderingPanorama();
}
}

View File

@@ -0,0 +1,14 @@
package markil3.panorama.mixins;
import net.minecraft.client.gui.RotatingCubeMapRenderer;
import net.minecraft.client.gui.screen.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(TitleScreen.class)
public interface TitleAccessor
{
@Accessor("backgroundRenderer")
public void setPanoramic(RotatingCubeMapRenderer panoramic);
}

View File

@@ -0,0 +1,33 @@
package markil3.panorama.mixins;
import net.minecraft.client.gui.RotatingCubeMapRenderer;
import net.minecraft.client.gui.screen.TitleScreen;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import markil3.panorama.Main;
@Mixin(TitleScreen.class)
public class TitleHook
{
@Redirect(method = "<init>(Z)V", at = @At(value = "FIELD", target = "Lnet" +
"/minecraft/client/gui/screen/TitleScreen;" +
"backgroundRenderer:Lnet/minecraft/client/gui" +
"/RotatingCubeMapRenderer;", opcode = Opcodes.PUTFIELD))
private void injected(TitleScreen screen,
RotatingCubeMapRenderer defaultPan)
{
RotatingCubeMapRenderer pan = Main.getPanorama();
if (pan != null)
{
((TitleAccessor) screen).setPanoramic(pan);
}
else
{
((TitleAccessor) screen).setPanoramic(defaultPan);
}
}
}

View File

@@ -1 +0,0 @@
public-f net.minecraft.client.gui.screen.MainMenuScreen field_209101_K #panorama

View File

@@ -1,29 +0,0 @@
modLoader="javafml"
loaderVersion="[34,)"
license="GPL-3.0-only"
issueTrackerURL="https://github.com/Markil3/MinecraftPanorama/issues"
[[mods]]
modId="panorama"
version="${file.jarVersion}"
displayName="Panorama Mod"
updateJSONURL="https://raw.githubusercontent.com/Markil3/MinecraftPanorama/master/update-forge.json"
displayURL="https://markil3.github.io/MinecraftPanorama"
#logoFile="examplemod.png"
credits="Mojang Studios for the original screenshot code."
# A text field displayed in the mod UI
authors="Markil 3"
description='''
This Minecraft mod provides the ability to take panoramic screenshots at any time with the Screenshot key (default to F2 on most Minecraft installations). On top of that, these screenshots will occupy the main menu background, allowing you to relive your adventures every time you boot up the game.
'''
[[dependencies.panorama]]
modId="forge"
mandatory=true
versionRange="[34,)"
ordering="NONE"
side="CLIENT"
[[dependencies.panorama]]
modId="minecraft"
mandatory=true
versionRange="[1.16.3]"
ordering="NONE"
side="CLIENT"

View File

@@ -0,0 +1,41 @@
{
"schemaVersion": 1,
"id": "panorama",
"version": "${version}",
"name": "Panorama Mod",
"description": "This Minecraft mod provides the ability to take panoramic screenshots at any time with the Screenshot key (default to F2 on most Minecraft installations). On top of that, these screenshots will occupy the main menu background, allowing you to relive your adventures every time you boot up the game.",
"authors": [
"Markil 3"
],
"contact": {
"homepage": "https://www.planetminecraft.com/mod/panorama/",
"sources": "https://github.com/Markil3/MinecraftPanorama",
"issues": "https://github.com/Markil3/MinecraftPanorama/issues"
},
"license": "GPL-3.0-only",
"icon": "assets/panorama/icon.png",
"environment": "client",
"entrypoints": {
"main": [
"markil3.panorama.Main"
]
},
"mixins": [
{
"config": "modid.mixins.json",
"environment": "client"
}
],
"depends": {
"fabricloader": ">=0.7.4",
"minecraft": "1.16.x"
},
"suggests": {
"modmenu": "*",
"cloth-config2": "*"
}
}

View File

@@ -0,0 +1,19 @@
{
"required": true,
"minVersion": "0.8",
"package": "markil3.panorama.mixins",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
"ScreenshotHook",
"GameRenderHook",
"TitleHook",
"GameRenderAccessor",
"TitleAccessor",
"CameraAccessor"
],
"injectors": {
"defaultRequire": 1
}
}