diff --git a/gradle.properties b/gradle.properties
index b44a7ab59..b121f29ec 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
# mod version info
-mod_version = 0.6.0
+mod_version = 0.6.1
mc_update_version = 1.18
minecraft_version = 1.18.1
loader_version = 0.12.12
diff --git a/src/main/java/com/jozufozu/flywheel/Flywheel.java b/src/main/java/com/jozufozu/flywheel/Flywheel.java
index ba6a96e96..a01e46690 100644
--- a/src/main/java/com/jozufozu/flywheel/Flywheel.java
+++ b/src/main/java/com/jozufozu/flywheel/Flywheel.java
@@ -3,18 +3,42 @@ package com.jozufozu.flywheel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import com.jozufozu.flywheel.backend.Backend;
+import com.jozufozu.flywheel.backend.Loader;
+import com.jozufozu.flywheel.backend.RenderWork;
+import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
+import com.jozufozu.flywheel.config.FlwConfig;
+import com.jozufozu.flywheel.core.Contexts;
+import com.jozufozu.flywheel.core.PartialModel;
+import com.jozufozu.flywheel.core.QuadConverter;
+import com.jozufozu.flywheel.core.compile.ProgramCompiler;
+import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
+import com.jozufozu.flywheel.event.EntityWorldHandler;
+import com.jozufozu.flywheel.event.ForgeEvents;
+import com.jozufozu.flywheel.fabric.event.FlywheelEvents;
+import com.jozufozu.flywheel.mixin.PausedPartialTickAccessor;
+import com.jozufozu.flywheel.vanilla.VanillaInstances;
+
+import net.fabricmc.api.ClientModInitializer;
+import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
+import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
+import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
+import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.Version;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.packs.PackType;
-public class Flywheel {
+public class Flywheel implements ClientModInitializer {
public static final String ID = "flywheel";
public static final Logger LOGGER = LogManager.getLogger(Flywheel.class);
- public static SemanticVersion VERSION;
+ private static SemanticVersion version;
- static void initVersion() {
+ @Override
+ public void onInitializeClient() {
Version version = FabricLoader.getInstance()
.getModContainer(ID)
.orElseThrow(() -> new IllegalStateException("Could not get the mod container for Flywheel!"))
@@ -23,7 +47,43 @@ public class Flywheel {
if (!(version instanceof SemanticVersion semver)) {
throw new IllegalStateException("Got non-semantic version for Flywheel!");
}
- VERSION = semver;
+ Flywheel.version = semver;
+
+ FlwConfig.init();
+
+ Backend.init();
+
+ FlywheelEvents.GATHER_CONTEXT.register(Contexts::flwInit);
+ ModelLoadingRegistry.INSTANCE.registerModelProvider(PartialModel::onModelRegistry);
+ ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(PartialModel.ResourceReloadListener.INSTANCE);
+
+ FlywheelEvents.RELOAD_RENDERERS.register(ProgramCompiler::invalidateAll);
+
+ ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(Loader.ResourceReloadListener.INSTANCE);
+
+ WorldRenderEvents.END.register(RenderWork::onRenderWorldLast);
+ ClientTickEvents.END_CLIENT_TICK.register(InstancedRenderDispatcher::tick);
+ FlywheelEvents.BEGIN_FRAME.register(InstancedRenderDispatcher::onBeginFrame);
+ FlywheelEvents.RENDER_LAYER.register(InstancedRenderDispatcher::renderLayer);
+ FlywheelEvents.RELOAD_RENDERERS.register(InstancedRenderDispatcher::onReloadRenderers);
+ FlywheelEvents.RELOAD_RENDERERS.register(QuadConverter::onRendererReload);
+ FlywheelEvents.RELOAD_RENDERERS.register(CrumblingRenderer::onReloadRenderers);
+ ClientEntityEvents.ENTITY_LOAD.register(EntityWorldHandler::onEntityJoinWorld);
+ ClientEntityEvents.ENTITY_UNLOAD.register(EntityWorldHandler::onEntityLeaveWorld);
+ ClientTickEvents.END_CLIENT_TICK.register(ForgeEvents::tickLight);
+
+ VanillaInstances.init();
+
+ // https://github.com/Jozufozu/Flywheel/issues/69
+ // Weird issue with accessor loading.
+ // Only thing I've seen that's close to a fix is to force the class to load before trying to use it.
+ // From the SpongePowered discord:
+ // https://discord.com/channels/142425412096491520/626802111455297538/675007581168599041
+ LOGGER.debug("Successfully loaded {}", PausedPartialTickAccessor.class.getName());
+ }
+
+ public static SemanticVersion getVersion() {
+ return version;
}
public static ResourceLocation rl(String path) {
diff --git a/src/main/java/com/jozufozu/flywheel/FlywheelClient.java b/src/main/java/com/jozufozu/flywheel/FlywheelClient.java
deleted file mode 100644
index 98adf752e..000000000
--- a/src/main/java/com/jozufozu/flywheel/FlywheelClient.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.jozufozu.flywheel;
-
-import com.jozufozu.flywheel.backend.Backend;
-import com.jozufozu.flywheel.backend.Loader;
-import com.jozufozu.flywheel.backend.RenderWork;
-import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
-import com.jozufozu.flywheel.config.FlwConfig;
-import com.jozufozu.flywheel.core.Contexts;
-import com.jozufozu.flywheel.core.PartialModel;
-import com.jozufozu.flywheel.core.QuadConverter;
-import com.jozufozu.flywheel.core.compile.ProgramCompiler;
-import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
-import com.jozufozu.flywheel.event.EntityWorldHandler;
-import com.jozufozu.flywheel.event.ForgeEvents;
-import com.jozufozu.flywheel.fabric.event.FlywheelEvents;
-import com.jozufozu.flywheel.mixin.PausedPartialTickAccessor;
-import com.jozufozu.flywheel.vanilla.VanillaInstances;
-
-import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
-import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
-import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
-import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
-import net.minecraft.server.packs.PackType;
-
-public class FlywheelClient implements ClientModInitializer {
-
- @Override
- public void onInitializeClient() {
- Flywheel.initVersion();
-
- Backend.init();
-
- FlywheelEvents.GATHER_CONTEXT.register(Contexts::flwInit);
- ModelLoadingRegistry.INSTANCE.registerModelProvider(PartialModel::onModelRegistry);
- ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(PartialModel.ResourceReloadListener.INSTANCE);
-
- FlywheelEvents.RELOAD_RENDERERS.register(ProgramCompiler::invalidateAll);
-
- VanillaInstances.init();
-
- ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(Loader.ResourceReloadListener.INSTANCE);
-
- WorldRenderEvents.END.register(RenderWork::onRenderWorldLast);
- ClientTickEvents.END_CLIENT_TICK.register(InstancedRenderDispatcher::tick);
- FlywheelEvents.BEGIN_FRAME.register(InstancedRenderDispatcher::onBeginFrame);
- FlywheelEvents.RENDER_LAYER.register(InstancedRenderDispatcher::renderLayer);
- FlywheelEvents.RELOAD_RENDERERS.register(InstancedRenderDispatcher::onReloadRenderers);
- FlywheelEvents.RELOAD_RENDERERS.register(QuadConverter::onRendererReload);
- FlywheelEvents.RELOAD_RENDERERS.register(CrumblingRenderer::onReloadRenderers);
- ClientEntityEvents.ENTITY_LOAD.register(EntityWorldHandler::onEntityJoinWorld);
- ClientEntityEvents.ENTITY_UNLOAD.register(EntityWorldHandler::onEntityLeaveWorld);
- ClientTickEvents.END_CLIENT_TICK.register(ForgeEvents::tickLight);
-
- FlwConfig.init();
-
- // https://github.com/Jozufozu/Flywheel/issues/69
- // Weird issue with accessor loading.
- // Only thing I've seen that's close to a fix is to force the class to load before trying to use it.
- // From the SpongePowered discord:
- // https://discord.com/channels/142425412096491520/626802111455297538/675007581168599041
- Flywheel.LOGGER.info("Successfully loaded {}", PausedPartialTickAccessor.class.getName());
- }
-}
diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java
index f0ffd7935..254e7f081 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java
@@ -21,8 +21,6 @@ public class Backend {
private static FlwEngine engine;
- public static GlCompat compat;
-
private static final Loader loader = new Loader();
public static FlwEngine getEngine() {
@@ -43,9 +41,7 @@ public class Backend {
}
public static void refresh() {
- compat = new GlCompat();
-
- engine = chooseEngine(compat);
+ engine = chooseEngine();
}
public static boolean isOn() {
@@ -77,7 +73,7 @@ public class Backend {
RenderWork.enqueue(Minecraft.getInstance().levelRenderer::allChanged);
}
- private static FlwEngine chooseEngine(GlCompat compat) {
+ private static FlwEngine chooseEngine() {
FlwEngine preferredChoice = FlwConfig.get()
.getEngine();
@@ -85,7 +81,7 @@ public class Backend {
boolean canUseEngine = switch (preferredChoice) {
case OFF -> true;
case BATCHING -> !usingShaders;
- case INSTANCING -> !usingShaders && compat.instancedArraysSupported();
+ case INSTANCING -> !usingShaders && GlCompat.getInstance().instancedArraysSupported();
};
return canUseEngine ? preferredChoice : FlwEngine.OFF;
diff --git a/src/main/java/com/jozufozu/flywheel/backend/Loader.java b/src/main/java/com/jozufozu/flywheel/backend/Loader.java
index 10aafd3b4..3dbde897e 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/Loader.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/Loader.java
@@ -47,7 +47,7 @@ public class Loader {
public static final String PROGRAM_DIR = "flywheel/programs/";
private static final Gson GSON = new GsonBuilder().create();
- private final Map
implements MaterialG public InstancedMaterialGroup(InstancingEngine
owner, RenderType type) { this.owner = owner; this.type = type; - if (Backend.compat.onAMDWindows()) { + if (GlCompat.getInstance() + .onAMDWindows()) { this.allocator = FallbackAllocator.INSTANCE; } else { this.allocator = new ModelPool(Formats.POS_TEX_NORMAL, 2048); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java index 8a3c4c376..f0a696f02 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java @@ -155,9 +155,9 @@ public class InstancingEngine
implements Engine {
@Override
public void addDebugInfo(List extends Memoizer> cir) {
+ @Inject(method = "getSystemInformation", at = @At("RETURN"))
+ private void modifyRightText(CallbackInfoReturnable
> cir) {
ForgeEvents.addToDebugScreen(cir.getReturnValue());
}
}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index b4e42c927..ee0570f12 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -21,7 +21,7 @@
"environment": "client",
"entrypoints": {
"client": [
- "com.jozufozu.flywheel.FlywheelClient"
+ "com.jozufozu.flywheel.Flywheel"
]
},
"mixins": [