Merge remote-tracking branch 'origin/1.17/dev' into 1.17/fabric/dev

Conflicts:
	build.gradle
	gradle.properties
	src/main/java/com/jozufozu/flywheel/backend/Loader.java
	src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java
	src/main/java/com/jozufozu/flywheel/config/BooleanConfig.java
	src/main/java/com/jozufozu/flywheel/config/SConfigureBooleanPacket.java
	src/main/java/com/jozufozu/flywheel/core/AtlasStitcher.java
	src/main/java/com/jozufozu/flywheel/core/PartialModel.java
	src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingRenderer.java
	src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java
	src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java
	src/main/java/com/jozufozu/flywheel/event/BeginFrameEvent.java
	src/main/java/com/jozufozu/flywheel/event/RenderLayerEvent.java
	src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java
	src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java
	src/main/java/com/jozufozu/flywheel/util/BakedQuadWrapper.java
	src/main/java/com/jozufozu/flywheel/util/BufferBuilderReader.java
	src/main/resources/flywheel.mixins.json
	src/main/resources/pack.mcmeta
This commit is contained in:
PepperBell 2021-11-20 09:54:22 -08:00
commit dbe46a6f28
57 changed files with 491 additions and 278 deletions

View file

@ -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")
])
}
}

View file

@ -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

Binary file not shown.

View file

@ -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

269
gradlew vendored
View file

@ -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" "$@"

View file

@ -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);

View file

@ -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;

View file

@ -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<String> context) {
// TODO: build flag? to enable or disable this function
GlError poll = GlError.poll();
if (poll != null) {
//throw new GlException(poll, context.get());
}
}
}

View file

@ -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()

View file

@ -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.
*/

View file

@ -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<D extends InstanceData> implements Instancer<D> {
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() {

View file

@ -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<T> implements MaterialManagerImpl.OriginShiftListener {
@ -286,6 +286,7 @@ public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginSh
AbstractInstance renderer = createRaw(obj);
if (renderer != null) {
renderer.init();
renderer.updateLight();
LightUpdater.get(renderer.world)
.addListener(renderer);

View file

@ -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);

View file

@ -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.

View file

@ -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;

View file

@ -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.

View file

@ -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<BlockEntity> {

View file

@ -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<D extends InstanceData> {
/**

View file

@ -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;
/**

View file

@ -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 {

View file

@ -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<P extends WorldProgram> {

View file

@ -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;

View file

@ -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;

View file

@ -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.

View file

@ -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

View file

@ -29,25 +29,37 @@ import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
*/
public class PartialModel {
private static final List<PartialModel> all = new ArrayList<>();
private static final List<PartialModel> 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<ResourceLocation> 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() {

View file

@ -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 {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<ModelData> {

View file

@ -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;

View file

@ -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<OrientedData> {

View file

@ -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) {

View file

@ -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

View file

@ -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.
*/

View file

@ -10,9 +10,11 @@ public class ModelPart implements IModel {
private final List<PartBuilder.CuboidBuilder> cuboids;
private int vertices;
private final String name;
public ModelPart(List<PartBuilder.CuboidBuilder> cuboids) {
public ModelPart(List<PartBuilder.CuboidBuilder> 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

View file

@ -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<CuboidBuilder> 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) {

View file

@ -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;

View file

@ -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<StructureTemplate.StructureBlockInfo> blocks) {
public WorldModel(BlockAndTintGetter renderWorld, RenderType layer, Collection<StructureTemplate.StructureBlockInfo> blocks, String name) {
reader = new BufferBuilderReader(ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, blocks));
this.name = name;
}
@Override
public String name() {
return name;
}
@Override

View file

@ -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");

View file

@ -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);

View file

@ -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;

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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<Integer> samplerLocations;
@Shadow
@Final
private List<String> samplerNames;
@Shadow
@Final
private Map<String, Object> 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);
}
}

View file

@ -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 {

View file

@ -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)

View file

@ -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.
*
* <p>
* 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.
* </p>
*/
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();
}

View file

@ -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 {

View file

@ -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);

View file

@ -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<BellBlockEntity> implements IDynamicInstance {
private final OrientedData bell;
@ -64,7 +64,7 @@ public class BellInstance extends TileEntityInstance<BellBlockEntity> 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)

View file

@ -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<T extends BlockEntity & LidBlockEntity> extends TileEntityInstance<T> implements IDynamicInstance {
@ -137,7 +137,7 @@ public class ChestInstance<T extends BlockEntity & LidBlockEntity> 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<T extends BlockEntity & LidBlockEntity> 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<T extends BlockEntity & LidBlockEntity> 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<T extends BlockEntity & LidBlockEntity> 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<T extends BlockEntity & LidBlockEntity> 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<T extends BlockEntity & LidBlockEntity> extends TileE
.build();
}
return ModelPart.builder(64, 64)
return ModelPart.builder("chest_lid", 64, 64)
.sprite(renderMaterial.sprite())
.cuboid()
.textureOffset(0, 0)

View file

@ -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<T extends AbstractMinecart> extends EntityInstance<T> implements IDynamicInstance, ITickableInstance {
@ -155,7 +155,7 @@ public class MinecartInstance<T extends AbstractMinecart> 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()

View file

@ -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<ShulkerBoxBlockEntity> implements IDynamicInstance {
private final TextureAtlasSprite texture;
@ -101,7 +101,7 @@ public class ShulkerBoxInstance extends TileEntityInstance<ShulkerBoxBlockEntity
}
private ModelPart makeBaseModel() {
return ModelPart.builder(64, 64)
return ModelPart.builder("shulker_base", 64, 64)
.sprite(texture)
.cuboid()
.textureOffset(0, 28)
@ -112,7 +112,7 @@ public class ShulkerBoxInstance extends TileEntityInstance<ShulkerBoxBlockEntity
}
private ModelPart makeLidModel() {
return ModelPart.builder(64, 64)
return ModelPart.builder("shulker_lid", 64, 64)
.sprite(texture)
.cuboid()
.size(16, 12, 16)

View file

@ -4,20 +4,23 @@
"package": "com.jozufozu.flywheel.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
"CancelEntityRenderMixin",
"ChunkRebuildHooksMixin",
"FixFabulousDepthMixin",
"RenderHooksMixin",
"ShaderCloseMixin",
"atlas.AtlasDataMixin",
"atlas.SheetDataAccessor",
"light.LightUpdateMixin",
"light.NetworkLightUpdateMixin",
"LevelRendererAccessor",
"matrix.Matrix3fMixin",
"matrix.Matrix4fMixin",
"CancelEntityRenderMixin",
"ChunkRebuildHooksMixin",
"FixFabulousDepthMixin",
"InstanceAddMixin",
"InstanceRemoveMixin",
"LeakChunkStorageArrayMixin",
"PausedPartialTickAccessor"
"LevelRendererAccessor",
"PausedPartialTickAccessor",
"RenderHooksMixin",
"ShaderCloseMixin",
"ShaderInstanceMixin"
,
"fabric.BufferBuilderAccessor",
"fabric.ClientLevelMixin",
@ -26,10 +29,6 @@
"fabric.MinecraftMixin",
"fabric.VertexFormatAccessor"
],
"mixins": [
"matrix.Matrix3fMixin",
"matrix.Matrix4fMixin"
],
"injectors": {
"defaultRequire": 1
}