diff --git a/build.gradle b/build.gradle index 7d6fbbd9f..e6ca87806 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version "${loom_version}" id 'maven-publish' - id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'com.matthewprenger.cursegradle' version "${cursegradle_version}" } boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equalsIgnoreCase('false'); ext.buildnumber = 0 -project.buildnumber = System.getenv('BUILD_NUMBER') != null ? System.getenv('BUILD_NUMBER') : "custom" +project.buildnumber = System.getenv('BUILD_NUMBER') != null ? System.getenv('BUILD_NUMBER') : 'custom' version = "${mc_update_version}-${mod_version}" + (dev ? ".${buildnumber}" : '') group = 'com.jozufozu.flywheel' @@ -22,21 +22,29 @@ println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getPro repositories { maven { - name "tterrag maven" - url "https://maven.tterrag.com/" + name 'tterrag maven' + url 'https://maven.tterrag.com/' + } + maven { + url 'https://maven.parchmentmc.org/' } } dependencies { // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings loom.layered() { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip") + } + modImplementation "net.fabricmc:fabric-loader:${loader_version}" // Fabric API - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" implementation 'com.google.code.findbugs:jsr305:3.0.2' + + //implementation 'org.joml:joml:1.10.1' } processResources { @@ -67,7 +75,7 @@ java { jar { from('LICENSE') { - rename { "${it}_${project.archivesBaseName}" } + rename { "${it}_${archivesBaseName}" } } } @@ -75,14 +83,14 @@ jar { jar { manifest { attributes([ - "Specification-Title" : "flywheel", - //"Specification-Vendor": "flywheel authors", - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : project.version, - //"Implementation-Vendor": "flywheel authors", - "MixinConfigs" : "flywheel.mixins.json", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + 'Specification-Title' : 'flywheel', + //'Specification-Vendor': 'flywheel authors', + 'Specification-Version' : '1', // We are version 1 of ourselves + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.version, + //'Implementation-Vendor': 'flywheel authors', + 'MixinConfigs' : 'flywheel.mixins.json', + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } diff --git a/gradle.properties b/gradle.properties index 69fd0df36..f4921ab8a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,21 @@ -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false +org.gradle.jvmargs = -Xmx3G +org.gradle.daemon = false + # mod version info -mod_version=0.3.0 -mc_update_version=1.17 -minecraft_version=1.17.1 -loader_version=0.12.1 -fabric_version=0.40.8+1.17 +mod_version = 0.3.0 +mc_update_version = 1.17 +minecraft_version = 1.17.1 +loader_version = 0.12.5 +fabric_version = 0.42.1+1.17 + +# build dependency versions +loom_version = 0.10-SNAPSHOT +cursegradle_version = 1.4.0 +parchment_version = 2021.10.31 # curseforge info -projectId=486392 -curse_type=beta +projectId = 486392 +curse_type = beta # github info -github_project=Jozufozu/Flywheel +github_project = Jozufozu/Flywheel diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c02..7454180f2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254..e750102e0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c8..c53aefaa5 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# 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" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index a6b40f781..9228aebea 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -21,8 +21,8 @@ import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; public class Backend { public static final Logger log = LogManager.getLogger(Backend.class); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/PersistentGlBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/PersistentGlBuffer.java index de3dc3e72..6c5188dab 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/PersistentGlBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/PersistentGlBuffer.java @@ -1,8 +1,8 @@ package com.jozufozu.flywheel.backend.gl.buffer; +import static org.lwjgl.opengl.GL30.GL_MAP_WRITE_BIT; import static org.lwjgl.opengl.GL44.GL_MAP_COHERENT_BIT; import static org.lwjgl.opengl.GL44.GL_MAP_PERSISTENT_BIT; -import static org.lwjgl.opengl.GL44.GL_MAP_WRITE_BIT; import java.nio.ByteBuffer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/error/GlError.java b/src/main/java/com/jozufozu/flywheel/backend/gl/error/GlError.java index f96cfd207..3df53b71b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/error/GlError.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/error/GlError.java @@ -1,5 +1,7 @@ package com.jozufozu.flywheel.backend.gl.error; +import java.util.function.Supplier; + import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; @@ -35,4 +37,12 @@ public enum GlError { public static GlError poll() { return errorLookup.get(GL20.glGetError()); } + + public static void pollAndThrow(Supplier context) { + // TODO: build flag? to enable or disable this function + GlError poll = GlError.poll(); + if (poll != null) { + //throw new GlException(poll, context.get()); + } + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index e4356c2bf..8f9efd7f0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -9,14 +9,12 @@ import static org.lwjgl.opengl.GL20.glUseProgram; import java.nio.FloatBuffer; import org.lwjgl.system.MemoryStack; -import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlObject; -import com.jozufozu.flywheel.util.RenderUtil; +import com.mojang.math.Matrix4f; import net.minecraft.resources.ResourceLocation; -import com.mojang.math.Matrix4f; public abstract class GlProgram extends GlObject { private static final FloatBuffer floatBuffer = MemoryStack.stackGet() diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java index b17051c50..6d67ae02e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java @@ -12,8 +12,8 @@ import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.ListenerStatus; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LightLayer; /** * A general interface providing information about any type of thing that could use Flywheel's instanced rendering. @@ -29,6 +29,13 @@ public abstract class AbstractInstance implements IInstance, ILightUpdateListene this.world = world; } + /** + * Initialize models here. + */ + public void init() { + + } + /** * Free any acquired resources. */ diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java index 1e9d85dcd..364d406c6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java @@ -9,6 +9,7 @@ import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.error.GlError; import com.jozufozu.flywheel.backend.model.IBufferedModel; import com.jozufozu.flywheel.backend.model.ModelAllocator; import com.jozufozu.flywheel.backend.struct.StructType; @@ -73,14 +74,22 @@ public class GPUInstancer implements Instancer { if (invalid()) return; vao.bind(); - renderSetup(); + GlError.pollAndThrow(() -> modelData.name() + "_bind"); - if (glInstanceCount > 0) model.drawInstances(glInstanceCount); + renderSetup(); + GlError.pollAndThrow(() -> modelData.name() + "_setup"); + + if (glInstanceCount > 0) { + model.drawInstances(glInstanceCount); + GlError.pollAndThrow(() -> modelData.name() + "_draw"); + } // persistent mapping sync point instanceVBO.doneForThisFrame(); vao.unbind(); + + GlError.pollAndThrow(() -> modelData.name() + "_unbind"); } private boolean invalid() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java index 573d3fac2..b10936ca6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java @@ -12,12 +12,12 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManagerImpl; import com.jozufozu.flywheel.light.LightUpdater; +import com.mojang.math.Vector3f; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.minecraft.client.Camera; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; -import com.mojang.math.Vector3f; public abstract class InstanceManager implements MaterialManagerImpl.OriginShiftListener { @@ -286,6 +286,7 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh AbstractInstance renderer = createRaw(obj); if (renderer != null) { + renderer.init(); renderer.updateLight(); LightUpdater.get(renderer.world) .addListener(renderer); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java index 9c9d94e1e..0e454d2f5 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java @@ -9,11 +9,10 @@ import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.RenderLayerEvent; import com.jozufozu.flywheel.util.ChunkIter; -import com.mojang.blaze3d.systems.RenderSystem; +import com.jozufozu.flywheel.util.TextureBinder; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.entity.BlockEntity; @@ -103,9 +102,7 @@ public class InstanceWorld { public void renderLayer(RenderLayerEvent event) { event.type.setupRenderState(); - ShaderInstance shader = RenderSystem.getShader(); - if (shader != null) - shader.apply(); + TextureBinder.bindActiveTextures(); materialManager.render(event.layer, event.viewProjection, event.camX, event.camY, event.camZ); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java index 64e92c3ee..76970613f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java @@ -9,15 +9,15 @@ import com.jozufozu.flywheel.light.GridAlignedBB; import com.jozufozu.flywheel.light.ILightUpdateListener; import com.jozufozu.flywheel.light.IMovingListener; import com.jozufozu.flywheel.light.LightProvider; +import com.mojang.math.Vector3f; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.AABB; -import net.minecraft.core.BlockPos; -import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; -import com.mojang.math.Vector3f; -import net.minecraft.core.Vec3i; /** * The layer between a {@link BlockEntity} and the Flywheel backend. diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceManager.java index 2cbca481e..db9ba49ec 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceManager.java @@ -6,8 +6,8 @@ import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; import com.jozufozu.flywheel.backend.material.MaterialManagerImpl; -import net.minecraft.world.entity.Entity; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java index b51e9fddb..f79190e8f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java @@ -11,9 +11,9 @@ import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.light.GridAlignedBB; import com.jozufozu.flywheel.light.ImmutableBox; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; /** * The layer between a {@link BlockEntity} and the Flywheel backend. diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java index 7d1c793d2..40505b260 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java @@ -6,10 +6,10 @@ import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; import com.jozufozu.flywheel.backend.material.MaterialManagerImpl; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; public class TileInstanceManager extends InstanceManager { diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/Material.java b/src/main/java/com/jozufozu/flywheel/backend/material/Material.java index a7a68133d..af1e2d609 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/Material.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/Material.java @@ -11,8 +11,8 @@ import com.jozufozu.flywheel.util.Pair; import com.jozufozu.flywheel.util.RenderUtil; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; public interface Material { /** diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialGroupImpl.java b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialGroupImpl.java index 8cea7ca24..6aae0c6d1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialGroupImpl.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialGroupImpl.java @@ -7,7 +7,6 @@ import java.util.Map; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.state.IRenderState; import com.jozufozu.flywheel.core.shader.WorldProgram; - import com.mojang.math.Matrix4f; /** diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java index 74f17e702..639bfb1ed 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java @@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.state.IRenderState; import com.jozufozu.flywheel.backend.state.RenderLayer; import com.jozufozu.flywheel.backend.state.TextureRenderState; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.core.Vec3i; +import net.minecraft.world.inventory.InventoryMenu; public interface MaterialManager { diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialRenderer.java index 8bd0ae82b..bbffa0881 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialRenderer.java @@ -6,7 +6,6 @@ import java.util.function.Supplier; import com.jozufozu.flywheel.backend.instancing.GPUInstancer; import com.jozufozu.flywheel.core.shader.WorldProgram; - import com.mojang.math.Matrix4f; public class MaterialRenderer

{ diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java index 5b5b5026d..e06f7be4b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.model; -import static org.lwjgl.opengl.GL20.glDrawArrays; +import static org.lwjgl.opengl.GL11.glDrawArrays; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlPrimitive; diff --git a/src/main/java/com/jozufozu/flywheel/backend/pipeline/ProtoProgram.java b/src/main/java/com/jozufozu/flywheel/backend/pipeline/ProtoProgram.java index 17e7c321a..caa331d79 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/pipeline/ProtoProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/pipeline/ProtoProgram.java @@ -1,7 +1,7 @@ package com.jozufozu.flywheel.backend.pipeline; +import static org.lwjgl.opengl.GL11.GL_TRUE; import static org.lwjgl.opengl.GL20.GL_LINK_STATUS; -import static org.lwjgl.opengl.GL20.GL_TRUE; import static org.lwjgl.opengl.GL20.glAttachShader; import static org.lwjgl.opengl.GL20.glBindAttribLocation; import static org.lwjgl.opengl.GL20.glCreateProgram; diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java b/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java index b53893a76..88db37083 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java @@ -10,9 +10,9 @@ import com.google.common.collect.Lists; import com.jozufozu.flywheel.util.ResourceUtil; import com.jozufozu.flywheel.util.StreamUtil; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.resources.ResourceLocation; /** * The main object for loading and parsing source files. diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/error/lines/HeaderLine.java b/src/main/java/com/jozufozu/flywheel/backend/source/error/lines/HeaderLine.java index 85eab0fe4..2488095e8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/error/lines/HeaderLine.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/error/lines/HeaderLine.java @@ -1,7 +1,5 @@ package com.jozufozu.flywheel.backend.source.error.lines; -import com.jozufozu.flywheel.backend.source.error.Level; - public record HeaderLine(String level, CharSequence message) implements ErrorLine { @Override diff --git a/src/main/java/com/jozufozu/flywheel/core/PartialModel.java b/src/main/java/com/jozufozu/flywheel/core/PartialModel.java index 9333100a9..572df712c 100644 --- a/src/main/java/com/jozufozu/flywheel/core/PartialModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/PartialModel.java @@ -29,25 +29,37 @@ import net.minecraft.server.packs.resources.ResourceManagerReloadListener; */ public class PartialModel { - private static final List all = new ArrayList<>(); + private static final List ALL = new ArrayList<>(); + private static boolean tooLate = false; protected final ResourceLocation modelLocation; protected BakedModel bakedModel; public PartialModel(ResourceLocation modelLocation) { + if (tooLate) throw new RuntimeException("PartialModel '" + modelLocation + "' loaded after ModelRegistryEvent"); this.modelLocation = modelLocation; - all.add(this); + ALL.add(this); } public static void onModelRegistry(ResourceManager manager, Consumer out) { - for (PartialModel partial : all) + for (PartialModel partial : ALL) out.accept(partial.modelLocation); + + tooLate = true; } public static void onModelBake(ModelManager manager) { - for (PartialModel partial : all) - partial.bakedModel = BakedModelManagerHelper.getModel(manager, partial.modelLocation); + for (PartialModel partial : ALL) + partial.set(BakedModelManagerHelper.getModel(manager, partial.getLocation())); + } + + protected void set(BakedModel bakedModel) { + this.bakedModel = bakedModel; + } + + public ResourceLocation getLocation() { + return modelLocation; } public BakedModel get() { diff --git a/src/main/java/com/jozufozu/flywheel/core/StitchedSprite.java b/src/main/java/com/jozufozu/flywheel/core/StitchedSprite.java index f8badcd2d..c43f045a6 100644 --- a/src/main/java/com/jozufozu/flywheel/core/StitchedSprite.java +++ b/src/main/java/com/jozufozu/flywheel/core/StitchedSprite.java @@ -2,8 +2,8 @@ package com.jozufozu.flywheel.core; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; public class StitchedSprite { diff --git a/src/main/java/com/jozufozu/flywheel/core/atlas/AtlasInfo.java b/src/main/java/com/jozufozu/flywheel/core/atlas/AtlasInfo.java index afffa920a..01388512b 100644 --- a/src/main/java/com/jozufozu/flywheel/core/atlas/AtlasInfo.java +++ b/src/main/java/com/jozufozu/flywheel/core/atlas/AtlasInfo.java @@ -6,8 +6,8 @@ import java.util.Map; import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingProgram.java index 61b3d9482..1da5ae75a 100644 --- a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingProgram.java +++ b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingProgram.java @@ -8,11 +8,11 @@ import com.jozufozu.flywheel.core.atlas.AtlasInfo; import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.extension.IProgramExtension; -import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; public class CrumblingProgram extends WorldProgram { protected final int uTextureScale; diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java b/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java index e6e9c537a..3434b5284 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java @@ -1,7 +1,5 @@ package com.jozufozu.flywheel.core.materials; -import org.lwjgl.system.MemoryUtil; - import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java b/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java index 97f1aa3cb..2b07cebf0 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java @@ -3,8 +3,8 @@ package com.jozufozu.flywheel.core.materials.model.writer; import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.core.materials.model.ModelData; public class UnsafeModelWriter extends UnsafeBufferWriter { diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedData.java b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedData.java index 7e133cbaa..b43711cf9 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedData.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedData.java @@ -3,11 +3,11 @@ package com.jozufozu.flywheel.core.materials.oriented; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.materials.BasicData; import com.jozufozu.flywheel.util.vec.Vec3; - -import net.minecraft.core.BlockPos; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; +import net.minecraft.core.BlockPos; + public class OrientedData extends BasicData { public float posX; diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java index 53204c5bf..b44df9a9d 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java @@ -3,8 +3,8 @@ package com.jozufozu.flywheel.core.materials.oriented.writer; import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; public class UnsafeOrientedWriter extends UnsafeBufferWriter { diff --git a/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java b/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java index d60187bd9..149740244 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java @@ -55,6 +55,11 @@ public class BakedModelModel implements IModel { this.numQuads = numQuads; } + @Override + public String name() { + return model.toString(); + } + @Override public void buffer(VecBuffer buffer) { diff --git a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java index 07cd74e03..073d547aa 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java @@ -27,6 +27,8 @@ public class BlockModel implements IModel { private final BufferBuilderReader reader; + private final String name; + public BlockModel(BlockState state) { this(Minecraft.getInstance() .getBlockRenderer() @@ -39,6 +41,12 @@ public class BlockModel implements IModel { public BlockModel(BakedModel model, BlockState referenceState, PoseStack ms) { reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms)); + name = referenceState.toString(); + } + + @Override + public String name() { + return name; } @Override diff --git a/src/main/java/com/jozufozu/flywheel/core/model/IModel.java b/src/main/java/com/jozufozu/flywheel/core/model/IModel.java index b7ffd1a1b..75c1be74d 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/IModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/IModel.java @@ -27,6 +27,11 @@ import com.jozufozu.flywheel.core.QuadConverter; */ public interface IModel { + /** + * A name uniquely identifying this model. + */ + String name(); + /** * Copy this model into the given buffer. */ diff --git a/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java b/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java index 6ccb583e3..3574019a6 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java @@ -10,9 +10,11 @@ public class ModelPart implements IModel { private final List cuboids; private int vertices; + private final String name; - public ModelPart(List cuboids) { + public ModelPart(List cuboids, String name) { this.cuboids = cuboids; + this.name = name; vertices = 0; @@ -21,8 +23,13 @@ public class ModelPart implements IModel { } } - public static PartBuilder builder(int sizeU, int sizeV) { - return new PartBuilder(sizeU, sizeV); + public static PartBuilder builder(String name, int sizeU, int sizeV) { + return new PartBuilder(name, sizeU, sizeV); + } + + @Override + public String name() { + return name; } @Override diff --git a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java index 96a1a033d..127cbd2d2 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java @@ -8,13 +8,13 @@ import java.util.List; import java.util.Set; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.core.Direction; import com.mojang.math.Matrix3f; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.Direction; + public class PartBuilder { private final float sizeU; @@ -23,8 +23,10 @@ public class PartBuilder { private TextureAtlasSprite sprite; private final List cuboids = new ArrayList<>(); + private final String name; - public PartBuilder(int sizeU, int sizeV) { + public PartBuilder(String name, int sizeU, int sizeV) { + this.name = name; this.sizeU = (float) sizeU; this.sizeV = (float) sizeV; } @@ -39,7 +41,7 @@ public class PartBuilder { } public ModelPart build() { - return new ModelPart(cuboids); + return new ModelPart(cuboids, name); } private PartBuilder addCuboid(CuboidBuilder builder) { diff --git a/src/main/java/com/jozufozu/flywheel/core/model/Readable.java b/src/main/java/com/jozufozu/flywheel/core/model/Readable.java index 80d519dcb..1108ce02d 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/Readable.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/Readable.java @@ -1,8 +1,9 @@ package com.jozufozu.flywheel.core.model; -import net.minecraft.core.Direction; import com.mojang.math.Vector3f; +import net.minecraft.core.Direction; + public class Readable { public static class ModelBox { private final TexturedQuad[] quads; diff --git a/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java b/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java index 938d5cdca..32939ff22 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java @@ -15,9 +15,16 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp public class WorldModel implements IModel { private final BufferBuilderReader reader; + private final String name; - public WorldModel(BlockAndTintGetter renderWorld, RenderType layer, Collection blocks) { + public WorldModel(BlockAndTintGetter renderWorld, RenderType layer, Collection blocks, String name) { reader = new BufferBuilderReader(ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, blocks)); + this.name = name; + } + + @Override + public String name() { + return name; } @Override diff --git a/src/main/java/com/jozufozu/flywheel/core/shader/WorldProgram.java b/src/main/java/com/jozufozu/flywheel/core/shader/WorldProgram.java index 6d065f21c..ad8c0a9fb 100644 --- a/src/main/java/com/jozufozu/flywheel/core/shader/WorldProgram.java +++ b/src/main/java/com/jozufozu/flywheel/core/shader/WorldProgram.java @@ -8,11 +8,11 @@ import java.util.List; import com.jozufozu.flywheel.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.util.AnimationTickHolder; - import com.mojang.blaze3d.platform.Window; +import com.mojang.math.Matrix4f; + import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; -import com.mojang.math.Matrix4f; public class WorldProgram extends ExtensibleGlProgram { protected final int uTime = getUniformLocation("uTime"); diff --git a/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java b/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java index 48ee19f44..5dc44ceca 100644 --- a/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java +++ b/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java @@ -1,27 +1,27 @@ package com.jozufozu.flywheel.light; -import static org.lwjgl.opengl.GL20.GL_LINEAR; -import static org.lwjgl.opengl.GL20.GL_MIRRORED_REPEAT; -import static org.lwjgl.opengl.GL20.GL_TEXTURE0; -import static org.lwjgl.opengl.GL20.GL_TEXTURE4; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_3D; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_MAG_FILTER; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_MIN_FILTER; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_WRAP_R; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_WRAP_S; -import static org.lwjgl.opengl.GL20.GL_TEXTURE_WRAP_T; -import static org.lwjgl.opengl.GL20.GL_UNPACK_ALIGNMENT; -import static org.lwjgl.opengl.GL20.GL_UNPACK_IMAGE_HEIGHT; -import static org.lwjgl.opengl.GL20.GL_UNPACK_ROW_LENGTH; -import static org.lwjgl.opengl.GL20.GL_UNPACK_SKIP_IMAGES; -import static org.lwjgl.opengl.GL20.GL_UNPACK_SKIP_PIXELS; -import static org.lwjgl.opengl.GL20.GL_UNPACK_SKIP_ROWS; -import static org.lwjgl.opengl.GL20.GL_UNSIGNED_BYTE; -import static org.lwjgl.opengl.GL20.glActiveTexture; -import static org.lwjgl.opengl.GL20.glPixelStorei; -import static org.lwjgl.opengl.GL20.glTexImage3D; -import static org.lwjgl.opengl.GL20.glTexParameteri; -import static org.lwjgl.opengl.GL20.glTexSubImage3D; +import static org.lwjgl.opengl.GL11.GL_LINEAR; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_MAG_FILTER; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_MIN_FILTER; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_S; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_T; +import static org.lwjgl.opengl.GL11.GL_UNPACK_ALIGNMENT; +import static org.lwjgl.opengl.GL11.GL_UNPACK_ROW_LENGTH; +import static org.lwjgl.opengl.GL11.GL_UNPACK_SKIP_PIXELS; +import static org.lwjgl.opengl.GL11.GL_UNPACK_SKIP_ROWS; +import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE; +import static org.lwjgl.opengl.GL11.glPixelStorei; +import static org.lwjgl.opengl.GL11.glTexParameteri; +import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; +import static org.lwjgl.opengl.GL12.GL_TEXTURE_WRAP_R; +import static org.lwjgl.opengl.GL12.GL_UNPACK_IMAGE_HEIGHT; +import static org.lwjgl.opengl.GL12.GL_UNPACK_SKIP_IMAGES; +import static org.lwjgl.opengl.GL12.glTexImage3D; +import static org.lwjgl.opengl.GL12.glTexSubImage3D; +import static org.lwjgl.opengl.GL13.GL_TEXTURE0; +import static org.lwjgl.opengl.GL13.GL_TEXTURE4; +import static org.lwjgl.opengl.GL13.glActiveTexture; +import static org.lwjgl.opengl.GL14.GL_MIRRORED_REPEAT; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlTexture; @@ -36,6 +36,7 @@ public class GPULightVolume extends LightVolume { private final GlTexture glTexture; private final RGPixelFormat pixelFormat; + private final GlTextureUnit textureUnit = GlTextureUnit.T4; protected boolean bufferDirty; public GPULightVolume(ImmutableBox sampleVolume) { @@ -70,7 +71,7 @@ public class GPULightVolume extends LightVolume { // just in case something goes wrong, or we accidentally call this before this volume is properly disposed of. if (lightData == null) return; - GlTextureUnit.T4.makeActive(); + textureUnit.makeActive(); glTexture.bind(); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/src/main/java/com/jozufozu/flywheel/light/GridAlignedBB.java b/src/main/java/com/jozufozu/flywheel/light/GridAlignedBB.java index c1285e138..1ccdf6a81 100644 --- a/src/main/java/com/jozufozu/flywheel/light/GridAlignedBB.java +++ b/src/main/java/com/jozufozu/flywheel/light/GridAlignedBB.java @@ -2,11 +2,11 @@ package com.jozufozu.flywheel.light; import com.jozufozu.flywheel.util.RenderUtil; -import net.minecraft.core.Direction; -import net.minecraft.world.phys.AABB; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.core.SectionPos; import net.minecraft.core.Vec3i; +import net.minecraft.world.phys.AABB; public class GridAlignedBB implements ImmutableBox { private int minX; diff --git a/src/main/java/com/jozufozu/flywheel/mixin/CancelEntityRenderMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/CancelEntityRenderMixin.java index 1b45c59be..9f101adc4 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/CancelEntityRenderMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/CancelEntityRenderMixin.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.mixin; import java.util.ArrayList; -import java.util.Iterator; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,10 +11,9 @@ import com.google.common.collect.Lists; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.world.entity.Entity; -import net.minecraft.util.ClassInstanceMultiMap; @Mixin(LevelRenderer.class) public class CancelEntityRenderMixin { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java index 52e15bde2..1105ba7ab 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java @@ -5,14 +5,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.LevelRenderer; -import com.mojang.math.Matrix4f; +import net.minecraft.client.renderer.LightTexture; @Mixin(LevelRenderer.class) public class FixFabulousDepthMixin { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/InstanceRemoveMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/InstanceRemoveMixin.java index 188019ec5..e0282a5c8 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/InstanceRemoveMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/InstanceRemoveMixin.java @@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; @Mixin(BlockEntity.class) public class InstanceRemoveMixin { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/ShaderInstanceMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/ShaderInstanceMixin.java new file mode 100644 index 000000000..9778874cd --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/mixin/ShaderInstanceMixin.java @@ -0,0 +1,59 @@ +package com.jozufozu.flywheel.mixin; + +import java.util.List; +import java.util.Map; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import com.jozufozu.flywheel.util.TextureBinder; +import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.client.renderer.texture.AbstractTexture; + +@Mixin(ShaderInstance.class) +public class ShaderInstanceMixin implements TextureBinder { + @Shadow + @Final + private List samplerLocations; + + @Shadow + @Final + private List samplerNames; + + @Shadow + @Final + private Map samplerMap; + + @Override + public void bind() { + int i = GlStateManager._getActiveTexture(); + + for(int j = 0; j < samplerLocations.size(); ++j) { + String s = samplerNames.get(j); + if (samplerMap.get(s) != null) { + RenderSystem.activeTexture('\u84c0' + j); + RenderSystem.enableTexture(); + Object object = this.samplerMap.get(s); + int l = -1; + if (object instanceof RenderTarget) { + l = ((RenderTarget)object).getColorTextureId(); + } else if (object instanceof AbstractTexture) { + l = ((AbstractTexture)object).getId(); + } else if (object instanceof Integer) { + l = (Integer)object; + } + + if (l != -1) { + RenderSystem.bindTexture(l); + } + } + } + + GlStateManager._activeTexture(i); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java index 55c0e6ae2..9a9cd1dc2 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java @@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.jozufozu.flywheel.core.atlas.AtlasInfo; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.profiling.ProfilerFiller; @Mixin(TextureAtlas.class) public abstract class AtlasDataMixin { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java index 5bb3b1a94..0992907e3 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java @@ -9,8 +9,8 @@ import com.jozufozu.flywheel.backend.RenderWork; import com.jozufozu.flywheel.light.LightUpdater; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket; @Mixin(ClientPacketListener.class) diff --git a/src/main/java/com/jozufozu/flywheel/util/TextureBinder.java b/src/main/java/com/jozufozu/flywheel/util/TextureBinder.java new file mode 100644 index 000000000..2c7e816de --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/TextureBinder.java @@ -0,0 +1,30 @@ +package com.jozufozu.flywheel.util; + +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.ShaderInstance; + +/** + * This is a silly hack that's needed because flywheel does things too different from vanilla. + * + *

+ * When a {@link RenderType} is setup, the associated textures are passed to the active ShaderInstance, and properly + * bound later on when {@link ShaderInstance#apply()} is called. + * This interface (and {@link com.jozufozu.flywheel.mixin.ShaderInstanceMixin mixin} binds textures to opengl + * without binding the shader. + *

+ */ +public interface TextureBinder { + + /** + * Call this after calling {@link RenderType#setupRenderState()}. + */ + static void bindActiveTextures() { + TextureBinder shader = (TextureBinder) RenderSystem.getShader(); + if (shader != null) + shader.bind(); + } + + void bind(); +} diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java index 591ab3a41..5f8604b9e 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.util.transform; import com.mojang.blaze3d.vertex.PoseStack; - import com.mojang.math.Quaternion; public class MatrixTransformStack implements TransformStack { diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java index 0a704f90d..f6cdf2ade 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java @@ -1,10 +1,11 @@ package com.jozufozu.flywheel.util.transform; -import net.minecraft.core.Direction; import com.mojang.math.Quaternion; -import net.minecraft.world.phys.Vec3; import com.mojang.math.Vector3f; + +import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; +import net.minecraft.world.phys.Vec3; public interface TransformStack { Vec3 CENTER = new Vec3(0.5, 0.5, 0.5); diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java index cddfddec7..22d771e9a 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java @@ -7,13 +7,13 @@ import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.core.model.ModelPart; import com.jozufozu.flywheel.util.AnimationTickHolder; - -import net.minecraft.client.renderer.blockentity.BellRenderer; -import net.minecraft.world.level.block.entity.BellBlockEntity; -import net.minecraft.util.Mth; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.blockentity.BellRenderer; +import net.minecraft.util.Mth; +import net.minecraft.world.level.block.entity.BellBlockEntity; + public class BellInstance extends TileEntityInstance implements IDynamicInstance { private final OrientedData bell; @@ -64,7 +64,7 @@ public class BellInstance extends TileEntityInstance implements } private static ModelPart createBellModel() { - return ModelPart.builder(32, 32) + return ModelPart.builder("bell", 32, 32) .sprite(BellRenderer.BELL_RESOURCE_LOCATION.sprite()) .cuboid() .start(5.0F, 6.0F, 5.0F) diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java index 905f86fee..3ed6547ec 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java @@ -14,20 +14,20 @@ import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.core.model.ModelPart; import com.jozufozu.flywheel.util.AnimationTickHolder; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; import it.unimi.dsi.fastutil.floats.Float2FloatFunction; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.resources.model.Material; import net.minecraft.world.level.block.AbstractChestBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ChestBlock; -import net.minecraft.client.renderer.Sheets; -import net.minecraft.client.resources.model.Material; -import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.DoubleBlockCombiner; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraft.world.level.block.entity.LidBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.DoubleBlockCombiner; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import net.minecraft.world.level.block.state.properties.ChestType; public class ChestInstance extends TileEntityInstance implements IDynamicInstance { @@ -137,7 +137,7 @@ public class ChestInstance extends TileE switch (chestType) { case LEFT: - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_base_left", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 19) @@ -146,7 +146,7 @@ public class ChestInstance extends TileE .endCuboid() .build(); case RIGHT: - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_base_right", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 19) @@ -156,7 +156,7 @@ public class ChestInstance extends TileE .build(); } - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_base", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 19) @@ -170,7 +170,7 @@ public class ChestInstance extends TileE switch (chestType) { case LEFT: - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_lid_left", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 0) @@ -183,7 +183,7 @@ public class ChestInstance extends TileE .endCuboid() .build(); case RIGHT: - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_lid_right", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 0) @@ -197,7 +197,7 @@ public class ChestInstance extends TileE .build(); } - return ModelPart.builder(64, 64) + return ModelPart.builder("chest_lid", 64, 64) .sprite(renderMaterial.sprite()) .cuboid() .textureOffset(0, 0) diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java index 820b4d364..021c5f069 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java @@ -11,15 +11,15 @@ import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.core.model.ModelPart; import com.jozufozu.flywheel.util.AnimationTickHolder; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.math.Vector3f; import net.minecraft.core.Vec3i; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import com.mojang.math.Vector3f; public class MinecartInstance extends EntityInstance implements IDynamicInstance, ITickableInstance { @@ -155,7 +155,7 @@ public class MinecartInstance extends EntityInstance private IModel getBodyModel() { int y = -3; - return ModelPart.builder(64, 32) + return ModelPart.builder("minecart", 64, 32) .cuboid().invertYZ().start(-10, -8, -y).size(20, 16, 2).textureOffset(0, 10).rotateX(((float)Math.PI / 2F)).endCuboid() .cuboid().invertYZ().start(-8, y, -10).size(16, 8, 2).rotateY(((float)Math.PI * 1.5F)).endCuboid() .cuboid().invertYZ().start(-8, y, -10).size(16, 8, 2).rotateY(((float)Math.PI / 2F)).endCuboid() diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java index 334778b89..a77affd6b 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java @@ -8,16 +8,16 @@ import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.model.ModelPart; import com.jozufozu.flywheel.util.AnimationTickHolder; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; - -import net.minecraft.world.level.block.ShulkerBoxBlock; -import net.minecraft.client.renderer.Sheets; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; -import net.minecraft.core.Direction; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.block.ShulkerBoxBlock; +import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; + public class ShulkerBoxInstance extends TileEntityInstance implements IDynamicInstance { private final TextureAtlasSprite texture; @@ -101,7 +101,7 @@ public class ShulkerBoxInstance extends TileEntityInstance