Merge branch '1.18/dev' into 1.19/dev

Conflicts:
	build.gradle
	gradle.properties
This commit is contained in:
PepperCode1 2023-06-26 19:08:11 -07:00
commit 5ae96be11a
16 changed files with 100 additions and 225 deletions

View file

@ -6,7 +6,7 @@ buildscript {
maven { url = 'https://maven.parchmentmc.org' } maven { url = 'https://maven.parchmentmc.org' }
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forgegradle_version}", changing: false classpath "net.minecraftforge.gradle:ForgeGradle:${forgegradle_version}"
classpath "org.spongepowered:mixingradle:${mixingradle_version}" classpath "org.spongepowered:mixingradle:${mixingradle_version}"
classpath "org.parchmentmc:librarian:${librarian_version}" classpath "org.parchmentmc:librarian:${librarian_version}"
} }
@ -31,9 +31,14 @@ version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '')
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft { minecraft {
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}" if (Boolean.parseBoolean(project.use_parchment)) {
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
} else {
mappings channel: 'official', version: "${minecraft_version}"
}
runs { runs {
client { client {
@ -114,13 +119,13 @@ dependencies {
// switch to implementation for debugging // switch to implementation for debugging
compileOnly fg.deobf("maven.modrinth:starlight-forge:1.1.1+1.19") compileOnly fg.deobf("maven.modrinth:starlight-forge:1.1.1+1.19")
compileOnly fg.deobf("maven.modrinth:rubidium:0.6.1") compileOnly fg.deobf("maven.modrinth:rubidium:0.6.2b")
compileOnly fg.deobf("maven.modrinth:oculus:1.19-1.2.5a") compileOnly fg.deobf("maven.modrinth:oculus:1.19.2-1.6.4")
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497 // https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings // Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
// This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly // This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly
if (System.getProperty('idea.sync.active') != 'true') { if (!Boolean.getBoolean('idea.sync.active')) {
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor" annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
} }
} }

View file

@ -2,19 +2,21 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false org.gradle.daemon = false
# mod version info # mod version info
mod_version = 0.6.8.a mod_version = 0.6.9
artifact_minecraft_version = 1.19.2 artifact_minecraft_version = 1.19.2
minecraft_version = 1.19.2 minecraft_version = 1.19.2
forge_version = 43.1.23 forge_version = 43.2.4
# build dependency versions # build dependency versions
forgegradle_version = 5.1.53 forgegradle_version = 5.1.74
mixingradle_version = 0.7-SNAPSHOT mixingradle_version = 0.7-SNAPSHOT
mixin_version = 0.8.5 mixin_version = 0.8.5
librarian_version = 1.+ librarian_version = 1.+
cursegradle_version = 1.4.0 cursegradle_version = 1.4.0
parchment_version = 2022.11.06 parchment_version = 2022.11.27
use_parchment = true
# curseforge info # curseforge info
projectId = 486392 projectId = 486392

Binary file not shown.

View file

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

18
gradlew vendored
View file

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (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 # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,10 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View file

@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View file

@ -2,7 +2,6 @@ package com.jozufozu.flywheel.core;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.core.compile.ProgramCompiler; import com.jozufozu.flywheel.core.compile.ProgramCompiler;
import com.jozufozu.flywheel.core.crumbling.CrumblingProgram;
import com.jozufozu.flywheel.core.shader.NormalDebugStateProvider; import com.jozufozu.flywheel.core.shader.NormalDebugStateProvider;
import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.core.source.FileResolution; import com.jozufozu.flywheel.core.source.FileResolution;
@ -18,7 +17,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class Contexts { public class Contexts {
public static ProgramCompiler<WorldProgram> WORLD; public static ProgramCompiler<WorldProgram> WORLD;
public static ProgramCompiler<CrumblingProgram> CRUMBLING; public static ProgramCompiler<WorldProgram> CRUMBLING;
public static void flwInit(GatherContextEvent event) { public static void flwInit(GatherContextEvent event) {
GameStateRegistry.register(NormalDebugStateProvider.INSTANCE); GameStateRegistry.register(NormalDebugStateProvider.INSTANCE);
@ -27,7 +26,7 @@ public class Contexts {
FileResolution crumblingBuiltins = Resolver.INSTANCE.get(ResourceUtil.subPath(Names.CRUMBLING, ".glsl")); FileResolution crumblingBuiltins = Resolver.INSTANCE.get(ResourceUtil.subPath(Names.CRUMBLING, ".glsl"));
WORLD = ProgramCompiler.create(Templates.INSTANCING, WorldProgram::new, worldBuiltins); WORLD = ProgramCompiler.create(Templates.INSTANCING, WorldProgram::new, worldBuiltins);
CRUMBLING = ProgramCompiler.create(Templates.INSTANCING, CrumblingProgram::new, crumblingBuiltins); CRUMBLING = ProgramCompiler.create(Templates.INSTANCING, WorldProgram::new, crumblingBuiltins);
} }
public static class Names { public static class Names {

View file

@ -1,48 +0,0 @@
package com.jozufozu.flywheel.core.crumbling;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.resources.ResourceLocation;
/**
* Track width and height of all created texture atlases.
*
* @see com.jozufozu.flywheel.mixin.atlas.AtlasDataMixin
*/
public class AtlasInfo {
private static final Map<ResourceLocation, SheetSize> sheetData = new HashMap<>();
@Nullable
public static TextureAtlas getAtlas(ResourceLocation name) {
AbstractTexture texture = Minecraft.getInstance().getTextureManager().getTexture(name);
if (texture instanceof TextureAtlas atlas)
return atlas;
else
return null;
}
@Nullable
public static SheetSize getSheetSize(@Nullable ResourceLocation loc) {
return sheetData.get(loc);
}
/**
* FOR USE IN MIXIN
*/
public static void _setAtlasData(ResourceLocation atlas, SheetDataAccessor accessor) {
sheetData.put(atlas, new SheetSize(accessor.flywheel$getWidth(), accessor.flywheel$getHeight()));
}
public record SheetSize(int width, int height) {
}
}

View file

@ -3,16 +3,13 @@ package com.jozufozu.flywheel.core.crumbling;
import com.jozufozu.flywheel.backend.RenderLayer; import com.jozufozu.flywheel.backend.RenderLayer;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup; import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.util.Textures; import com.jozufozu.flywheel.util.Textures;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.math.Matrix4f; import com.mojang.math.Matrix4f;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
public class CrumblingGroup<P extends CrumblingProgram> extends InstancedMaterialGroup<P> { public class CrumblingGroup<P extends WorldProgram> extends InstancedMaterialGroup<P> {
private int width;
private int height;
public CrumblingGroup(InstancingEngine<P> owner, RenderType type) { public CrumblingGroup(InstancingEngine<P> owner, RenderType type) {
super(owner, type); super(owner, type);
@ -21,41 +18,9 @@ public class CrumblingGroup<P extends CrumblingProgram> extends InstancedMateria
// XXX See notes of overriden method // XXX See notes of overriden method
@Override @Override
public void render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer) { public void render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer) {
type.setupRenderState();
int renderTex = RenderSystem.getShaderTexture(0);
updateAtlasSize();
type.clearRenderState();
CrumblingRenderer._currentLayer.setupRenderState(); CrumblingRenderer._currentLayer.setupRenderState();
int breakingTex = RenderSystem.getShaderTexture(0);
RenderSystem.setShaderTexture(0, renderTex);
RenderSystem.setShaderTexture(4, breakingTex);
Textures.bindActiveTextures(); Textures.bindActiveTextures();
renderAll(viewProjection, camX, camY, camZ, layer); renderAll(viewProjection, camX, camY, camZ, layer);
CrumblingRenderer._currentLayer.clearRenderState(); CrumblingRenderer._currentLayer.clearRenderState();
} }
private void updateAtlasSize() {
AtlasInfo.SheetSize sheetSize = AtlasInfo.getSheetSize(Textures.getShaderTexture(0));
if (sheetSize != null) {
width = sheetSize.width();
height = sheetSize.height();
} else {
width = height = 256;
}
}
@Override
protected void setup(P p) {
p.setAtlasSize(width, height);
}
} }

View file

@ -1,42 +0,0 @@
package com.jozufozu.flywheel.core.crumbling;
import static org.lwjgl.opengl.GL20.glUniform2f;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
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;
protected int uCrumbling;
public CrumblingProgram(ResourceLocation name, int handle) {
super(name, handle);
uTextureScale = getUniformLocation("uTextureScale");
}
@Override
protected void registerSamplers() {
super.registerSamplers();
uCrumbling = setSamplerBinding("uCrumbling", 4);
}
public void setTextureScale(float x, float y) {
glUniform2f(uTextureScale, x, y);
}
public void setAtlasSize(int width, int height) {
TextureAtlas blockAtlas = AtlasInfo.getAtlas(InventoryMenu.BLOCK_ATLAS);
if (blockAtlas == null) return;
TextureAtlasSprite sprite = blockAtlas.getSprite(ModelBakery.BREAKING_LOCATIONS.get(0));
setTextureScale(width / (float) sprite.getWidth(), height / (float) sprite.getHeight());
}
}

View file

@ -6,17 +6,16 @@ import java.util.SortedSet;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.gl.GlStateTracker; import com.jozufozu.flywheel.backend.gl.GlStateTracker;
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine; import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
import com.jozufozu.flywheel.core.Contexts; import com.jozufozu.flywheel.core.Contexts;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.event.ReloadRenderersEvent; import com.jozufozu.flywheel.event.ReloadRenderersEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent; import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.jozufozu.flywheel.mixin.LevelRendererAccessor; import com.jozufozu.flywheel.mixin.LevelRendererAccessor;
import com.jozufozu.flywheel.util.Lazy; import com.jozufozu.flywheel.util.Lazy;
import com.jozufozu.flywheel.util.Pair; import com.jozufozu.flywheel.util.Pair;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
@ -26,8 +25,6 @@ import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.BlockDestructionProgress; import net.minecraft.server.level.BlockDestructionProgress;
@ -67,17 +64,14 @@ public class CrumblingRenderer {
// XXX Restore state // XXX Restore state
GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
CrumblingRenderer.renderBreaking(activeStages, new RenderLayerEvent(level, null, stack, null, cameraPos.x, cameraPos.y, cameraPos.z)); renderCrumbling(activeStages, camera, new RenderLayerEvent(level, null, stack, null, cameraPos.x, cameraPos.y, cameraPos.z));
restoreState.restore(); restoreState.restore();
} }
private static void renderBreaking(Int2ObjectMap<List<BlockEntity>> activeStages, RenderLayerEvent event) { private static void renderCrumbling(Int2ObjectMap<List<BlockEntity>> activeStages, Camera camera, RenderLayerEvent event) {
State state = STATE.get(); State state = STATE.get();
InstanceManager<BlockEntity> instanceManager = state.instanceManager; InstanceManager<BlockEntity> instanceManager = state.instanceManager;
InstancingEngine<CrumblingProgram> materials = state.materialManager; InstancingEngine<WorldProgram> materials = state.materialManager;
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
Camera info = Minecraft.getInstance().gameRenderer.getMainCamera();
for (Int2ObjectMap.Entry<List<BlockEntity>> stage : activeStages.int2ObjectEntrySet()) { for (Int2ObjectMap.Entry<List<BlockEntity>> stage : activeStages.int2ObjectEntrySet()) {
_currentLayer = ModelBakery.DESTROY_TYPES.get(stage.getIntKey()); _currentLayer = ModelBakery.DESTROY_TYPES.get(stage.getIntKey());
@ -86,22 +80,14 @@ public class CrumblingRenderer {
if (_currentLayer != null) { if (_currentLayer != null) {
stage.getValue().forEach(instanceManager::add); stage.getValue().forEach(instanceManager::add);
instanceManager.beginFrame(SerialTaskEngine.INSTANCE, info); instanceManager.beginFrame(SerialTaskEngine.INSTANCE, camera);
// XXX Each call applies another restore state even though we are already inside of a restore state // XXX Each call applies another restore state even though we are already inside of a restore state
materials.render(SerialTaskEngine.INSTANCE, event); materials.render(SerialTaskEngine.INSTANCE, event);
instanceManager.invalidate(); instanceManager.invalidate();
} }
} }
// XXX Inconsistent GL state cleanup
// If texture binding and active unit need to be restored, store them in variables before GL state is changed
// instead of guessing that unit 0 and crumbling tex 0 are correct
GlTextureUnit.T0.makeActive();
AbstractTexture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(0));
if (breaking != null) RenderSystem.bindTexture(breaking.getId());
} }
/** /**
@ -145,7 +131,7 @@ public class CrumblingRenderer {
} }
private static class State { private static class State {
private final InstancingEngine<CrumblingProgram> materialManager; private final InstancingEngine<WorldProgram> materialManager;
private final InstanceManager<BlockEntity> instanceManager; private final InstanceManager<BlockEntity> instanceManager;
private State() { private State() {

View file

@ -1,28 +0,0 @@
package com.jozufozu.flywheel.mixin.atlas;
import java.util.stream.Stream;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.jozufozu.flywheel.core.crumbling.AtlasInfo;
import net.minecraft.client.renderer.texture.TextureAtlas;
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 {
@Shadow
public abstract ResourceLocation location();
@Inject(method = "prepareToStitch", at = @At("RETURN"))
public void stealAtlasData(ResourceManager resourceManager, Stream<ResourceLocation> locationStream, ProfilerFiller profiler, int mipMapLevels, CallbackInfoReturnable<TextureAtlas.Preparations> cir) {
AtlasInfo._setAtlasData(location(), (SheetDataAccessor) cir.getReturnValue());
}
}

View file

@ -1,17 +0,0 @@
package com.jozufozu.flywheel.mixin.atlas;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.renderer.texture.TextureAtlas;
@Mixin(TextureAtlas.Preparations.class)
public interface SheetDataAccessor {
@Accessor("width")
int flywheel$getWidth();
@Accessor("height")
int flywheel$getHeight();
}

View file

@ -4,15 +4,60 @@ uniform float uTime;
uniform mat4 uViewProjection; uniform mat4 uViewProjection;
uniform vec3 uCameraPos; uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas; uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap; uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize; uniform vec2 uWindowSize;
#if defined(VERTEX_SHADER) #if defined(VERTEX_SHADER)
// Replicates the result of SheetedDecalTextureGenerator.java
vec2 crumblingUV(vec3 pos, vec3 normal) {
float maxLen = -2;
int face = 2;
if (-normal.y > maxLen) {
maxLen = -normal.y;
face = 0;
}
if (normal.y > maxLen) {
maxLen = normal.y;
face = 1;
}
if (-normal.z > maxLen) {
maxLen = -normal.z;
face = 2;
}
if (normal.z > maxLen) {
maxLen = normal.z;
face = 3;
}
if (-normal.x > maxLen) {
maxLen = -normal.x;
face = 4;
}
if (normal.x > maxLen) {
maxLen = normal.x;
face = 5;
}
if (face == 0) {
return vec2(pos.x, -pos.z);
} else if (face == 1) {
return vec2(pos.x, pos.z);
} else if (face == 3) {
return vec2(pos.x, -pos.y);
} else if (face == 4) {
return vec2(-pos.z, -pos.y);
} else if (face == 5) {
return vec2(pos.z, -pos.y);
} else { // face == 2
return vec2(-pos.x, -pos.y);
}
}
vec4 FLWVertex(inout Vertex v) { vec4 FLWVertex(inout Vertex v) {
v.texCoords = crumblingUV(v.pos, normalize(v.normal));
FragDistance = cylindrical_distance(v.pos, uCameraPos); FragDistance = cylindrical_distance(v.pos, uCameraPos);
return uViewProjection * vec4(v.pos, 1.); return uViewProjection * vec4(v.pos, 1.);
@ -23,10 +68,7 @@ vec4 FLWVertex(inout Vertex v) {
out vec4 fragColor; out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) { vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale); return texture(uBlockAtlas, texCoords);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
} }
void FLWFinalizeColor(vec4 color) { void FLWFinalizeColor(vec4 color) {

View file

@ -4,7 +4,6 @@ uniform float uTime;
uniform mat4 uViewProjection; uniform mat4 uViewProjection;
uniform vec3 uCameraPos; uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas; uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap; uniform sampler2D uLightMap;

View file

@ -20,8 +20,6 @@
"PausedPartialTickAccessor", "PausedPartialTickAccessor",
"RenderTexturesMixin", "RenderTexturesMixin",
"RenderTypeMixin", "RenderTypeMixin",
"atlas.AtlasDataMixin",
"atlas.SheetDataAccessor",
"instancemanage.ChunkRebuildHooksMixin", "instancemanage.ChunkRebuildHooksMixin",
"instancemanage.ChunkRenderDispatcherAccessor", "instancemanage.ChunkRenderDispatcherAccessor",
"instancemanage.InstanceAddMixin", "instancemanage.InstanceAddMixin",