mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-04 01:04:58 +01:00
Fix registry freeze timing
- Move registry freezing to right before start of initial resource reload - Also warn if Fabric config JSON is not an object - Move Flywheel.java to API - Remove Flywheel.LOGGER and others; add impl-specific and backend-specific loggers - Remove unused mixins - Organize imports
This commit is contained in:
parent
6dff488f8c
commit
914ce0a7de
54 changed files with 147 additions and 188 deletions
|
@ -2,17 +2,16 @@ package com.jozufozu.gradle.platform
|
|||
|
||||
import com.jozufozu.gradle.jarset.JarTaskSet
|
||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
import net.fabricmc.loom.task.RemapSourcesJarTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.gradle.kotlin.dsl.the
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion
|
|||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
|
||||
|
||||
class SubprojectPlugin: Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.extensions.create("defaultPackageInfos", PackageInfosExtension::class.java, project)
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.gradle.api.Action
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
open class TransitiveSourceSetsExtension(private val project: Project) {
|
||||
var compileClasspath: FileCollection? = null
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package com.jozufozu.flywheel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
package com.jozufozu.flywheel.api;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public final class Flywheel {
|
||||
public static final String ID = "flywheel";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
|
||||
|
||||
private Flywheel() {
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.compile.IndirectPrograms;
|
||||
import com.jozufozu.flywheel.backend.compile.InstancingPrograms;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.jozufozu.flywheel.backend;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
|
||||
public final class FlwBackend {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/backend");
|
||||
|
||||
private FlwBackend() {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
ShaderIndices.init();
|
||||
Backends.init();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.layout.FloatRepr;
|
||||
import com.jozufozu.flywheel.api.layout.Layout;
|
||||
import com.jozufozu.flywheel.api.layout.LayoutBuilder;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.backend.ShaderIndices;
|
||||
import com.jozufozu.flywheel.backend.compile.component.UberShaderComponent;
|
||||
|
@ -22,7 +22,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
||||
public final class FlwPrograms {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/shaders");
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/backend/shaders");
|
||||
|
||||
private static final ResourceLocation COMPONENTS_HEADER_VERT = Flywheel.rl("internal/components_header.vert");
|
||||
private static final ResourceLocation COMPONENTS_HEADER_FRAG = Flywheel.rl("internal/components_header.frag");
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.backend.compile.component.InstanceStructComponent;
|
||||
import com.jozufozu.flywheel.backend.compile.component.SsboInstanceComponent;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.InternalVertex;
|
||||
import com.jozufozu.flywheel.backend.Samplers;
|
||||
import com.jozufozu.flywheel.backend.compile.component.InstanceStructComponent;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.Samplers;
|
||||
import com.jozufozu.flywheel.backend.compile.component.BufferTextureInstanceComponent;
|
||||
import com.jozufozu.flywheel.backend.compile.component.SsboInstanceComponent;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.compile.component;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.layout.Layout;
|
||||
import com.jozufozu.flywheel.backend.glsl.generate.FnSignature;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.compile.component;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.layout.Layout;
|
||||
import com.jozufozu.flywheel.backend.compile.LayoutInterpreter;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.compile.component;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.layout.Layout;
|
||||
import com.jozufozu.flywheel.backend.engine.indirect.IndirectBuffers;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.compile.component;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceComponent;
|
||||
|
||||
public final class StringSubstitutionComponent implements SourceComponent {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.compile.core.SourceLoader;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceComponent;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceFile;
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceFile;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceLines;
|
||||
import com.jozufozu.flywheel.backend.glsl.error.ConsoleColors;
|
||||
|
|
|
@ -8,13 +8,13 @@ import java.util.Queue;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.backend.Engine;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.instance.Instancer;
|
||||
import com.jozufozu.flywheel.api.model.Model;
|
||||
import com.jozufozu.flywheel.backend.FlwBackend;
|
||||
import com.jozufozu.flywheel.backend.engine.embed.Environment;
|
||||
import com.jozufozu.flywheel.lib.util.Pair;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public abstract class DrawManager<N extends AbstractInstancer<?>> {
|
|||
.forEach(f -> builder.append("\n\t")
|
||||
.append(f.toString()));
|
||||
|
||||
Flywheel.LOGGER.warn(builder.toString());
|
||||
FlwBackend.LOGGER.warn(builder.toString());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class FrameUniforms extends UniformWriter {
|
|||
}
|
||||
|
||||
private static long writeTime(long ptr, RenderContext context) {
|
||||
int ticks = ((LevelRendererAccessor) context.renderer()).flywheel$ticks();
|
||||
int ticks = ((LevelRendererAccessor) context.renderer()).flywheel$getTicks();
|
||||
float partialTick = context.partialTick();
|
||||
float renderTicks = ticks + partialTick;
|
||||
float renderSeconds = renderTicks / 20f;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.lwjgl.opengl.GLCapabilities;
|
|||
import org.lwjgl.opengl.KHRShaderSubgroup;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.FlwBackend;
|
||||
import com.jozufozu.flywheel.backend.compile.core.Compilation;
|
||||
import com.jozufozu.flywheel.backend.glsl.GlslVersion;
|
||||
import com.jozufozu.flywheel.lib.math.MoreMath;
|
||||
|
@ -26,7 +26,7 @@ public final class GlCompat {
|
|||
caps = GL.getCapabilities();
|
||||
} catch (IllegalStateException e) {
|
||||
// This happens with vulkanmod installed.
|
||||
Flywheel.LOGGER.warn("Failed to get GL capabilities, all flywheel backends will be disabled.");
|
||||
FlwBackend.LOGGER.warn("Failed to get GL capabilities; default Flywheel backends will be disabled.");
|
||||
caps = null;
|
||||
}
|
||||
CAPABILITIES = caps;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public interface GameRendererAccessor {
|
||||
@Invoker("getFov")
|
||||
double flywheel$getFov(Camera pActiveRenderInfo, float pPartialTicks, boolean pUseFOVSetting);
|
||||
|
||||
@Accessor("zoom")
|
||||
float flywheel$getZoom();
|
||||
|
||||
@Accessor("zoomX")
|
||||
float flywheel$getZoomX();
|
||||
|
||||
@Accessor("zoomY")
|
||||
float flywheel$getZoomY();
|
||||
}
|
|
@ -8,5 +8,5 @@ import net.minecraft.client.renderer.LevelRenderer;
|
|||
@Mixin(LevelRenderer.class)
|
||||
public interface LevelRendererAccessor {
|
||||
@Accessor("ticks")
|
||||
int flywheel$ticks();
|
||||
int flywheel$getTicks();
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
|
||||
@Mixin(LightTexture.class)
|
||||
public interface LightTextureAccessor {
|
||||
@Accessor("lightTexture")
|
||||
DynamicTexture flywheel$texture();
|
||||
}
|
|
@ -10,7 +10,7 @@ import com.jozufozu.flywheel.backend.engine.uniform.OptionsUniforms;
|
|||
import net.minecraft.client.Options;
|
||||
|
||||
@Mixin(Options.class)
|
||||
public class OptionsMixin {
|
||||
abstract class OptionsMixin {
|
||||
@Inject(method = "load()V", at = @At("RETURN"))
|
||||
private void flywheel$onLoad(CallbackInfo ci) {
|
||||
OptionsUniforms.update((Options) (Object) this);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
|
||||
@Mixin(OverlayTexture.class)
|
||||
public interface OverlayTextureAccessor {
|
||||
@Accessor("texture")
|
||||
DynamicTexture flywheel$texture();
|
||||
}
|
|
@ -6,12 +6,9 @@
|
|||
"refmap": "backend-flywheel.refmap.json",
|
||||
"client": [
|
||||
"AbstractClientPlayerAccessor",
|
||||
"GameRendererAccessor",
|
||||
"GlStateManagerMixin",
|
||||
"LevelRendererAccessor",
|
||||
"LightTextureAccessor",
|
||||
"OptionsMixin",
|
||||
"OverlayTextureAccessor",
|
||||
"RenderSystemMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.lib.instance;
|
|||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.layout.FloatRepr;
|
||||
import com.jozufozu.flywheel.api.layout.IntegerRepr;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.jozufozu.flywheel.lib.internal;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.api.internal.DependencyInjection;
|
||||
import com.jozufozu.flywheel.lib.transform.PoseTransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -7,5 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
public interface FlwLibLink {
|
||||
FlwLibLink INSTANCE = DependencyInjection.load(FlwLibLink.class, "com.jozufozu.flywheel.impl.FlwLibLinkImpl");
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
PoseTransformStack getPoseTransformStackOf(PoseStack stack);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.lib.material;
|
|||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.material.CutoutShader;
|
||||
|
||||
public class CutoutShaders {
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.lib.material;
|
|||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.material.FogShader;
|
||||
|
||||
public class FogShaders {
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.lib.material;
|
|||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.material.MaterialShaders;
|
||||
|
||||
public final class StandardMaterialShaders {
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.lib.memory;
|
|||
|
||||
import java.lang.ref.Cleaner;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.lib.internal.FlwLibLink;
|
||||
import com.jozufozu.flywheel.lib.util.StringUtil;
|
||||
|
||||
class DebugMemoryBlockImpl extends AbstractMemoryBlockImpl {
|
||||
|
@ -91,7 +91,7 @@ class DebugMemoryBlockImpl extends AbstractMemoryBlockImpl {
|
|||
builder.append("\n\t");
|
||||
builder.append(frame);
|
||||
}
|
||||
Flywheel.LOGGER.warn(builder.toString());
|
||||
FlwLibLink.INSTANCE.getLogger().warn(builder.toString());
|
||||
|
||||
FlwMemoryTracker.free(ptr);
|
||||
FlwMemoryTracker._freeCPUMemory(size);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.lib.util;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
|
|
@ -4,14 +4,11 @@ import java.lang.reflect.Field;
|
|||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.lib.internal.FlwLibLink;
|
||||
import com.jozufozu.flywheel.lib.internal.FlwLibXplat;
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
public final class ShadersModHandler {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
private static final String OPTIFINE_ROOT_PACKAGE = "net.optifine";
|
||||
|
||||
private static final boolean IS_IRIS_LOADED;
|
||||
|
@ -29,13 +26,13 @@ public final class ShadersModHandler {
|
|||
// OptiFine and Iris/Oculus are assumed to be mutually exclusive
|
||||
|
||||
if (IS_IRIS_LOADED) {
|
||||
LOGGER.debug("Iris detected.");
|
||||
FlwLibLink.INSTANCE.getLogger().debug("Iris detected.");
|
||||
INTERNAL_HANDLER = irisHandler;
|
||||
} else if (IS_OPTIFINE_INSTALLED) {
|
||||
LOGGER.debug("OptiFine detected.");
|
||||
FlwLibLink.INSTANCE.getLogger().debug("OptiFine detected.");
|
||||
INTERNAL_HANDLER = new OptifineHandler();
|
||||
} else {
|
||||
LOGGER.debug("No shaders mod detected.");
|
||||
FlwLibLink.INSTANCE.getLogger().debug("No shaders mod detected.");
|
||||
INTERNAL_HANDLER = new InternalHandler() {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.api.instance.Instance;
|
|||
import com.jozufozu.flywheel.api.instance.Instancer;
|
||||
import com.jozufozu.flywheel.api.task.Plan;
|
||||
import com.jozufozu.flywheel.api.visual.DynamicVisual;
|
||||
import com.jozufozu.flywheel.api.visual.TickableVisual;
|
||||
import com.jozufozu.flywheel.lib.task.RunnablePlan;
|
||||
|
||||
public interface SimpleDynamicVisual extends DynamicVisual {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
|
|||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.api.instance.Instancer;
|
||||
import com.jozufozu.flywheel.api.task.Plan;
|
||||
import com.jozufozu.flywheel.api.visual.DynamicVisual;
|
||||
import com.jozufozu.flywheel.api.visual.TickableVisual;
|
||||
import com.jozufozu.flywheel.lib.task.RunnablePlan;
|
||||
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
package com.jozufozu.flywheel.impl;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.Backends;
|
||||
import com.jozufozu.flywheel.impl.visualization.VisualizationManagerImpl;
|
||||
import com.jozufozu.flywheel.lib.backend.SimpleBackend;
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public final class BackendManagerImpl {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public static final Backend OFF_BACKEND = SimpleBackend.builder()
|
||||
.engineFactory(level -> {
|
||||
throw new UnsupportedOperationException("Cannot create engine when backend is off.");
|
||||
|
@ -49,7 +45,7 @@ public final class BackendManagerImpl {
|
|||
var actual = preferred.findFallback();
|
||||
|
||||
if (preferred != actual) {
|
||||
LOGGER.warn("Flywheel backend fell back from '{}' to '{}'", Backend.REGISTRY.getIdOrThrow(preferred), Backend.REGISTRY.getIdOrThrow(actual));
|
||||
FlwImpl.LOGGER.warn("Flywheel backend fell back from '{}' to '{}'", Backend.REGISTRY.getIdOrThrow(preferred), Backend.REGISTRY.getIdOrThrow(actual));
|
||||
}
|
||||
|
||||
backend = actual;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.jozufozu.flywheel.impl;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backends;
|
||||
import com.jozufozu.flywheel.backend.ShaderIndices;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.FlwBackend;
|
||||
import com.jozufozu.flywheel.impl.registry.IdRegistryImpl;
|
||||
import com.jozufozu.flywheel.impl.registry.RegistryImpl;
|
||||
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
|
||||
|
@ -11,8 +14,11 @@ import com.jozufozu.flywheel.lib.material.StandardMaterialShaders;
|
|||
import com.jozufozu.flywheel.lib.util.ShadersModHandler;
|
||||
import com.jozufozu.flywheel.vanilla.VanillaVisuals;
|
||||
|
||||
public final class FlywheelInit {
|
||||
private FlywheelInit() {
|
||||
public final class FlwImpl {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID);
|
||||
public static final Logger CONFIG_LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/config");
|
||||
|
||||
private FlwImpl() {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
@ -27,8 +33,7 @@ public final class FlywheelInit {
|
|||
StandardMaterialShaders.init();
|
||||
|
||||
// backend
|
||||
ShaderIndices.init();
|
||||
Backends.init();
|
||||
FlwBackend.init();
|
||||
|
||||
// vanilla
|
||||
VanillaVisuals.init();
|
|
@ -1,11 +1,18 @@
|
|||
package com.jozufozu.flywheel.impl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.impl.extension.PoseStackExtension;
|
||||
import com.jozufozu.flywheel.lib.internal.FlwLibLink;
|
||||
import com.jozufozu.flywheel.lib.transform.PoseTransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public class FlwLibLinkImpl implements FlwLibLink {
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return FlwImpl.LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PoseTransformStack getPoseTransformStackOf(PoseStack stack) {
|
||||
return ((PoseStackExtension) stack).flywheel$transformStack();
|
||||
|
|
|
@ -20,12 +20,12 @@ abstract class ClientChunkCacheMixin {
|
|||
@Final
|
||||
ClientLevel level;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "onLightUpdate")
|
||||
private void flywheel$onLightUpdate(LightLayer pType, SectionPos pPos, CallbackInfo ci) {
|
||||
@Inject(method = "onLightUpdate", at = @At("HEAD"))
|
||||
private void flywheel$onLightUpdate(LightLayer layer, SectionPos pos, CallbackInfo ci) {
|
||||
var manager = VisualizationManagerImpl.get(level);
|
||||
|
||||
if (manager != null) {
|
||||
manager.enqueueLightUpdateSection(pPos.asLong());
|
||||
manager.enqueueLightUpdateSection(pos.asLong());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ abstract class LevelRendererMixin {
|
|||
flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);
|
||||
}
|
||||
|
||||
@Group(name = "onStage$afterParticles", min = 1)
|
||||
@Group(name = "onStage$afterParticles", min = 2, max = 2)
|
||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;F)V", shift = Shift.AFTER))
|
||||
private void flywheel$onStage$afterParticles$fabric(CallbackInfo ci) {
|
||||
flywheel$dispatch(RenderStage.AFTER_PARTICLES);
|
||||
|
|
|
@ -9,19 +9,14 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.task.TaskExecutor;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.jozufozu.flywheel.impl.FlwImpl;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
// https://github.com/CaffeineMC/sodium-fabric/blob/5d364ed5ba63f9067fcf72a078ca310bff4db3e9/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuilder.java
|
||||
// https://stackoverflow.com/questions/29655531
|
||||
public class ParallelTaskExecutor implements TaskExecutor {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
private final String name;
|
||||
private final int threadCount;
|
||||
|
||||
|
@ -70,7 +65,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
|
|||
threads.add(thread);
|
||||
}
|
||||
|
||||
LOGGER.info("Started {} worker threads", threads.size());
|
||||
FlwImpl.LOGGER.info("Started {} worker threads", threads.size());
|
||||
}
|
||||
|
||||
public void stopWorkers() {
|
||||
|
@ -82,7 +77,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
|
|||
throw new IllegalStateException("No threads are alive but the executor is in the RUNNING state");
|
||||
}
|
||||
|
||||
LOGGER.info("Stopping worker threads");
|
||||
FlwImpl.LOGGER.info("Stopping worker threads");
|
||||
|
||||
// Notify all worker threads to wake up, where they will then terminate
|
||||
synchronized (taskNotifier) {
|
||||
|
@ -233,7 +228,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
|
|||
try {
|
||||
task.run();
|
||||
} catch (Exception e) {
|
||||
Flywheel.LOGGER.error("Error running task", e);
|
||||
FlwImpl.LOGGER.error("Error running task", e);
|
||||
} finally {
|
||||
waitGroup.done();
|
||||
}
|
||||
|
@ -243,7 +238,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
|
|||
try {
|
||||
task.run();
|
||||
} catch (Exception e) {
|
||||
Flywheel.LOGGER.error("Error running main thread task", e);
|
||||
FlwImpl.LOGGER.error("Error running main thread task", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys;
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.backend.Backend;
|
||||
import com.jozufozu.flywheel.api.backend.BackendManager;
|
||||
|
||||
|
@ -25,21 +24,21 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
.getConfigDir()
|
||||
.resolve("flywheel.json");
|
||||
|
||||
public static final FabricFlwConfig INSTANCE = new FabricFlwConfig(PATH.toFile());
|
||||
|
||||
protected static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static final boolean LIMIT_UPDATES_DEFAULT = true;
|
||||
public static final int WORKER_THREADS_DEFAULT = -1;
|
||||
public static final int WORKER_THREADS_MAX = Runtime.getRuntime()
|
||||
.availableProcessors();
|
||||
public static final boolean LIMIT_UPDATES_DEFAULT = true;
|
||||
|
||||
public static final FabricFlwConfig INSTANCE = new FabricFlwConfig(PATH.toFile());
|
||||
|
||||
private final File file;
|
||||
|
||||
public Backend backend = BackendManager.getDefaultBackend();
|
||||
public boolean limitUpdates = LIMIT_UPDATES_DEFAULT;
|
||||
public int workerThreads = WORKER_THREADS_DEFAULT;
|
||||
|
||||
private final File file;
|
||||
|
||||
public FabricFlwConfig(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
try (FileReader reader = new FileReader(file)) {
|
||||
fromJson(JsonParser.parseReader(reader));
|
||||
} catch (Exception e) {
|
||||
Flywheel.LOGGER.error("Could not load config from file '{}'", file.getAbsolutePath(), e);
|
||||
FlwImpl.CONFIG_LOGGER.warn("Could not load config from file '{}'", file.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
// In case we found an error in the config file, immediately save to fix it.
|
||||
|
@ -75,12 +74,13 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
try (FileWriter writer = new FileWriter(file)) {
|
||||
GSON.toJson(toJson(), writer);
|
||||
} catch (Exception e) {
|
||||
Flywheel.LOGGER.error("Could not save config to file '{}'", file.getAbsolutePath(), e);
|
||||
FlwImpl.CONFIG_LOGGER.warn("Could not save config to file '{}'", file.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void fromJson(JsonElement json) {
|
||||
if (!(json instanceof JsonObject object)) {
|
||||
FlwImpl.CONFIG_LOGGER.warn("Config JSON must be an object");
|
||||
backend = BackendManager.getDefaultBackend();
|
||||
limitUpdates = LIMIT_UPDATES_DEFAULT;
|
||||
workerThreads = WORKER_THREADS_DEFAULT;
|
||||
|
@ -94,41 +94,42 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
|
||||
private void readBackend(JsonObject object) {
|
||||
var backendJson = object.get("backend");
|
||||
|
||||
String err = null;
|
||||
String msg = null;
|
||||
|
||||
if (backendJson instanceof JsonPrimitive primitive && primitive.isString()) {
|
||||
var backendString = primitive.getAsString();
|
||||
var value = primitive.getAsString();
|
||||
try {
|
||||
this.backend = Backend.REGISTRY.getOrThrow(new ResourceLocation(backendString));
|
||||
this.backend = Backend.REGISTRY.getOrThrow(new ResourceLocation(value));
|
||||
return;
|
||||
} catch (IllegalArgumentException e) {
|
||||
err = "backend ID '" + backendString + "' is not registered";
|
||||
} catch (ResourceLocationException e) {
|
||||
err = "backend '" + backendString + "' is not a valid resource location";
|
||||
msg = "'backend' value '" + value + "' is not a valid resource location";
|
||||
} catch (IllegalArgumentException e) {
|
||||
msg = "Backend with ID '" + value + "' is not registered";
|
||||
} catch (Exception e) {
|
||||
// Something else went wrong? This should be dead code.
|
||||
err = "backend '" + backendString + "' is invalid";
|
||||
msg = "'backend' value '" + value + "' is invalid";
|
||||
}
|
||||
} else if (backendJson != null) {
|
||||
err = "backend must be a string";
|
||||
msg = "'backend' value must be a string";
|
||||
}
|
||||
|
||||
// Don't log an error if the field is missing.
|
||||
if (err != null) {
|
||||
Flywheel.LOGGER.warn(err);
|
||||
if (msg != null) {
|
||||
FlwImpl.CONFIG_LOGGER.warn(msg);
|
||||
}
|
||||
backend = BackendManager.getDefaultBackend();
|
||||
}
|
||||
|
||||
private void readLimitUpdates(JsonObject object) {
|
||||
var limitUpdatesJson = object.get("limitUpdates");
|
||||
|
||||
if (limitUpdatesJson instanceof JsonPrimitive primitive && primitive.isBoolean()) {
|
||||
limitUpdates = primitive.getAsBoolean();
|
||||
return;
|
||||
} else if (limitUpdatesJson != null) {
|
||||
Flywheel.LOGGER.warn("limitUpdates must be a boolean");
|
||||
FlwImpl.CONFIG_LOGGER.warn("'limitUpdates' value must be a boolean");
|
||||
}
|
||||
|
||||
limitUpdates = LIMIT_UPDATES_DEFAULT;
|
||||
}
|
||||
|
||||
|
@ -136,18 +137,17 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
var workerThreadsJson = object.get("workerThreads");
|
||||
|
||||
if (workerThreadsJson instanceof JsonPrimitive primitive && primitive.isNumber()) {
|
||||
int configuredValue = primitive.getAsInt();
|
||||
int value = primitive.getAsInt();
|
||||
int clamped = Mth.clamp(value, WORKER_THREADS_DEFAULT, WORKER_THREADS_MAX);
|
||||
|
||||
int clamped = Mth.clamp(configuredValue, WORKER_THREADS_DEFAULT, WORKER_THREADS_MAX);
|
||||
|
||||
if (clamped != configuredValue) {
|
||||
Flywheel.LOGGER.warn("workerThreads value of {} is out of range, clamping to {}", configuredValue, clamped);
|
||||
if (clamped != value) {
|
||||
FlwImpl.CONFIG_LOGGER.warn("'workerThreads' value of {} is out of range, clamping to {}", value, clamped);
|
||||
}
|
||||
|
||||
workerThreads = clamped;
|
||||
return;
|
||||
} else if (workerThreadsJson != null) {
|
||||
Flywheel.LOGGER.warn("workerThreads must be an integer");
|
||||
FlwImpl.CONFIG_LOGGER.warn("'workerThreads' value must be an integer");
|
||||
}
|
||||
|
||||
workerThreads = WORKER_THREADS_DEFAULT;
|
||||
|
@ -155,9 +155,9 @@ public class FabricFlwConfig implements FlwConfig {
|
|||
|
||||
public JsonObject toJson() {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("backend", Backend.REGISTRY.getIdOrThrow(backend).toString());
|
||||
object.addProperty("limitUpdates", limitUpdates);
|
||||
object.addProperty("workerThreads", workerThreads);
|
||||
object.addProperty("backend", Backend.REGISTRY.getIdOrThrow(backend).toString());
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.impl;
|
|||
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.event.BeginFrameCallback;
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadCallback;
|
||||
import com.jozufozu.flywheel.api.event.ReloadLevelRendererCallback;
|
||||
|
@ -40,13 +40,7 @@ public final class FlywheelFabric implements ClientModInitializer {
|
|||
setupLib();
|
||||
setupBackend();
|
||||
|
||||
FlywheelInit.init();
|
||||
|
||||
// FIXME: Registries cannot be frozen this early.
|
||||
FlywheelInit.freezeRegistries();
|
||||
// Have to load the config after we freeze registries,
|
||||
// so we can find third party backends.
|
||||
FabricFlwConfig.INSTANCE.load();
|
||||
FlwImpl.init();
|
||||
}
|
||||
|
||||
private static void setupImpl() {
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadCallback;
|
||||
import com.jozufozu.flywheel.impl.FabricFlwConfig;
|
||||
import com.jozufozu.flywheel.impl.FlwImpl;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
|
@ -21,6 +23,14 @@ abstract class MinecraftMixin {
|
|||
@Final
|
||||
private ReloadableResourceManager resourceManager;
|
||||
|
||||
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ReloadableResourceManager;createReload(Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Ljava/util/List;)Lnet/minecraft/server/packs/resources/ReloadInstance;"))
|
||||
private void flywheel$onBeginInitialResourceReload(CallbackInfo ci) {
|
||||
FlwImpl.freezeRegistries();
|
||||
// Load the config after we freeze registries,
|
||||
// so we can find third party backends.
|
||||
FabricFlwConfig.INSTANCE.load();
|
||||
}
|
||||
|
||||
@Inject(method = "method_24040", at = @At("HEAD"))
|
||||
private void flywheel$onEndInitialResourceReload(Optional<Throwable> error, CallbackInfo ci) {
|
||||
EndClientResourceReloadCallback.EVENT.invoker()
|
||||
|
|
|
@ -24,11 +24,9 @@ public final class FlwCommands {
|
|||
}
|
||||
|
||||
public static void registerClientCommands(RegisterClientCommandsEvent event) {
|
||||
ForgeFlwConfig config = ForgeFlwConfig.INSTANCE;
|
||||
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = Commands.literal("flywheel");
|
||||
|
||||
ConfigValue<String> backendValue = config.client.backend;
|
||||
ConfigValue<String> backendValue = ForgeFlwConfig.INSTANCE.client.backend;
|
||||
command.then(Commands.literal("backend")
|
||||
.executes(context -> {
|
||||
Backend backend = BackendManager.getBackend();
|
||||
|
@ -58,7 +56,7 @@ public final class FlwCommands {
|
|||
return Command.SINGLE_SUCCESS;
|
||||
})));
|
||||
|
||||
BooleanValue limitUpdatesValue = config.client.limitUpdates;
|
||||
BooleanValue limitUpdatesValue = ForgeFlwConfig.INSTANCE.client.limitUpdates;
|
||||
command.then(Commands.literal("limitUpdates")
|
||||
.executes(context -> {
|
||||
if (limitUpdatesValue.get()) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.jozufozu.flywheel.impl;
|
|||
import java.lang.reflect.Field;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.lib.internal.FlwLibXplat;
|
||||
import com.jozufozu.flywheel.lib.model.baked.BakedModelBuilder;
|
||||
|
@ -13,7 +12,6 @@ import com.jozufozu.flywheel.lib.model.baked.ForgeBlockModelBuilder;
|
|||
import com.jozufozu.flywheel.lib.model.baked.ForgeMultiBlockModelBuilder;
|
||||
import com.jozufozu.flywheel.lib.model.baked.MultiBlockModelBuilder;
|
||||
import com.jozufozu.flywheel.lib.util.ShadersModHandler;
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -27,8 +25,6 @@ import net.minecraftforge.fml.ModList;
|
|||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
|
||||
public class FlwLibXplatImpl implements FlwLibXplat {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
@Override
|
||||
public BlockRenderDispatcher createVanillaBlockRenderDispatcher() {
|
||||
BlockRenderDispatcher defaultDispatcher = Minecraft.getInstance().getBlockRenderer();
|
||||
|
@ -40,7 +36,7 @@ public class FlwLibXplatImpl implements FlwLibXplat {
|
|||
}
|
||||
ObfuscationReflectionHelper.setPrivateValue(BlockRenderDispatcher.class, dispatcher, new ModelBlockRenderer(Minecraft.getInstance().getBlockColors()), "f_110900_");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to initialize vanilla BlockRenderDispatcher!", e);
|
||||
FlwImpl.LOGGER.error("Failed to initialize vanilla BlockRenderDispatcher!", e);
|
||||
return defaultDispatcher;
|
||||
}
|
||||
return dispatcher;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.impl;
|
|||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.Flywheel;
|
||||
import com.jozufozu.flywheel.api.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadEvent;
|
||||
import com.jozufozu.flywheel.api.event.ReloadLevelRendererEvent;
|
||||
|
@ -33,7 +33,6 @@ import net.minecraftforge.fml.LogicalSide;
|
|||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
@ -66,7 +65,7 @@ public final class FlywheelForge {
|
|||
registerBackendEventListeners(forgeEventBus, modEventBus);
|
||||
|
||||
CrashReportCallables.registerCrashCallable("Flywheel Backend", BackendManagerImpl::getBackendString);
|
||||
FlywheelInit.init();
|
||||
FlwImpl.init();
|
||||
}
|
||||
|
||||
private static void registerImplEventListeners(IEventBus forgeEventBus, IEventBus modEventBus) {
|
||||
|
@ -95,8 +94,6 @@ public final class FlywheelForge {
|
|||
FlwDebugInfo.addDebugInfo(minecraft, e.getRight());
|
||||
});
|
||||
|
||||
modEventBus.addListener((FMLLoadCompleteEvent e) -> FlywheelInit.freezeRegistries());
|
||||
|
||||
modEventBus.addListener((EndClientResourceReloadEvent e) -> BackendManagerImpl.onEndClientResourceReload(e.error().isPresent()));
|
||||
|
||||
modEventBus.addListener((FMLCommonSetupEvent e) -> {
|
||||
|
|
|
@ -2,11 +2,9 @@ package com.jozufozu.flywheel.impl;
|
|||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.api.backend.Backend;
|
||||
import com.jozufozu.flywheel.api.backend.BackendManager;
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -15,7 +13,6 @@ import net.minecraftforge.fml.ModLoadingContext;
|
|||
import net.minecraftforge.fml.config.ModConfig;
|
||||
|
||||
public class ForgeFlwConfig implements FlwConfig {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final ForgeFlwConfig INSTANCE = new ForgeFlwConfig();
|
||||
|
||||
public final ClientConfig client;
|
||||
|
@ -44,13 +41,13 @@ public class ForgeFlwConfig implements FlwConfig {
|
|||
try {
|
||||
backendId = new ResourceLocation(idStr);
|
||||
} catch (ResourceLocationException e) {
|
||||
LOGGER.warn("Config contains invalid backend ID '" + idStr + "'!");
|
||||
FlwImpl.CONFIG_LOGGER.warn("'backend' value '{}' is not a valid resource location", idStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
Backend backend = Backend.REGISTRY.get(backendId);
|
||||
if (backend == null) {
|
||||
LOGGER.warn("Config contains non-existent backend with ID '" + backendId + "'!");
|
||||
FlwImpl.CONFIG_LOGGER.warn("Backend with ID '{}' is not registered", backendId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,15 +2,18 @@ package com.jozufozu.flywheel.impl.mixin;
|
|||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadEvent;
|
||||
import com.jozufozu.flywheel.impl.FlwImpl;
|
||||
import com.mojang.realmsclient.client.RealmsClient;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -25,6 +28,13 @@ abstract class MinecraftMixin {
|
|||
@Final
|
||||
private ReloadableResourceManager resourceManager;
|
||||
|
||||
// Inject at invoke cannot be used in constructors in vanilla Mixin, so use ModifyArg instead.
|
||||
@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ReloadableResourceManager;createReload(Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Ljava/util/List;)Lnet/minecraft/server/packs/resources/ReloadInstance;"), index = 0)
|
||||
private Executor flywheel$onBeginInitialResourceReload(Executor arg0) {
|
||||
FlwImpl.freezeRegistries();
|
||||
return arg0;
|
||||
}
|
||||
|
||||
@Inject(method = "lambda$new$5", at = @At("HEAD"))
|
||||
private void flywheel$onEndInitialResourceReload(RealmsClient realmsClient, ReloadInstance reloadInstance, GameConfig gameConfig, Optional<Throwable> error, CallbackInfo ci) {
|
||||
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error));
|
||||
|
|
Loading…
Reference in a new issue