mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-04 09:14:59 +01:00
Deduplication and stubs
- Move common gradle business from each subproject into the rootProject.subprojects closure - Add fabric.mod.json - Register forge mixin configs - Make blaze3d mixins remap = false - Separate common, forge, and fabric mod entrypoints
This commit is contained in:
parent
c027023709
commit
5e7e867bcd
11 changed files with 327 additions and 465 deletions
122
build.gradle
122
build.gradle
|
@ -7,14 +7,24 @@ plugins {
|
|||
|
||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||
|
||||
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equalsIgnoreCase('false');
|
||||
|
||||
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||
|
||||
subprojects {
|
||||
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equalsIgnoreCase('false');
|
||||
|
||||
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||
|
||||
group = 'com.jozufozu.flywheel'
|
||||
version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '')
|
||||
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
apply from: rootProject.file('gradle/package-infos.gradle')
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
|
||||
ideaSyncTask.finalizedBy(generatePackageInfos)
|
||||
|
||||
tasks {
|
||||
// make builds reproducible
|
||||
withType(AbstractArchiveTask).configureEach {
|
||||
|
@ -27,6 +37,110 @@ subprojects {
|
|||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
processResources.configure {
|
||||
from(project(':common').sourceSets.main.resources)
|
||||
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version,
|
||||
forge_version_range : forge_version_range,
|
||||
loader_version_range : loader_version_range,
|
||||
mod_version : mod_version
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'pack.mcmeta', 'fabric.mod.json']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
url 'https://www.cursemaven.com'
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name 'tterrag maven'
|
||||
url 'https://maven.tterrag.com/'
|
||||
}
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$minecraft_version"
|
||||
mappings(loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
|
||||
})
|
||||
}
|
||||
|
||||
java {
|
||||
JavaVersion javaVersion = JavaVersion.toVersion(java_version)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = Integer.parseInt(java_version)
|
||||
options.compilerArgs = ['-Xdiags:verbose']
|
||||
}
|
||||
|
||||
jar.configure {
|
||||
archiveClassifier = ''
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
sourcesJar.configure {
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
javadoc.configure {
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
}
|
||||
|
||||
void addLicense(jarTask) {
|
||||
jarTask.from('LICENSE.md') {
|
||||
rename '(.*)\\.(.*)', '$1_' + jarTask.archiveBaseName + '.$2'
|
||||
}
|
||||
}
|
||||
|
||||
void addManifest(jarTask) {
|
||||
jarTask.manifest {
|
||||
attributes([
|
||||
'Specification-Title' : 'flywheel',
|
||||
// 'Specification-Vendor': 'flywheel authors',
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : jarTask.archiveBaseName,
|
||||
'Implementation-Version' : jarTask.archiveVersion,
|
||||
// 'Implementation-Vendor': 'flywheel authors',
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
|
|
|
@ -1,126 +1,17 @@
|
|||
plugins {
|
||||
id 'maven-publish'
|
||||
id 'dev.architectury.loom'
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "flywheel-${project.name}-${artifact_minecraft_version}"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
url 'https://www.cursemaven.com'
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name 'tterrag maven'
|
||||
url 'https://maven.tterrag.com/'
|
||||
}
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$minecraft_version"
|
||||
mappings(loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
|
||||
})
|
||||
|
||||
modCompileOnly "net.fabricmc:fabric-loader:$fabric_loader_version"
|
||||
|
||||
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
|
||||
}
|
||||
|
||||
java {
|
||||
JavaVersion javaVersion = JavaVersion.toVersion(java_version)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
processResources.configure {
|
||||
from(project(':common').sourceSets.main.resources)
|
||||
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version,
|
||||
forge_version_range : forge_version_range,
|
||||
loader_version_range : loader_version_range,
|
||||
mod_version : mod_version
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'pack.mcmeta', 'fabric.mod.json']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = Integer.parseInt(java_version)
|
||||
options.compilerArgs = ['-Xdiags:verbose']
|
||||
}
|
||||
|
||||
jar.configure {
|
||||
archiveClassifier = ''
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
sourcesJar.configure {
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
javadoc.configure {
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
|
||||
test.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
void addLicense(jarTask) {
|
||||
jarTask.from('LICENSE.md') {
|
||||
rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2'
|
||||
}
|
||||
}
|
||||
|
||||
void addManifest(jarTask) {
|
||||
jarTask.manifest {
|
||||
attributes([
|
||||
'Specification-Title' : 'flywheel',
|
||||
// 'Specification-Vendor': 'flywheel authors',
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.jar.archiveBaseName,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
// 'Implementation-Vendor': 'flywheel authors',
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/package-infos.gradle')
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register('mavenJava', MavenPublication) {
|
||||
|
|
|
@ -1,120 +1,30 @@
|
|||
package com.jozufozu.flywheel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadEvent;
|
||||
import com.jozufozu.flywheel.api.visualization.VisualizationManager;
|
||||
import com.jozufozu.flywheel.backend.Backends;
|
||||
import com.jozufozu.flywheel.backend.ShaderIndices;
|
||||
import com.jozufozu.flywheel.backend.compile.FlwPrograms;
|
||||
import com.jozufozu.flywheel.backend.engine.uniform.Uniforms;
|
||||
import com.jozufozu.flywheel.config.BackendArgument;
|
||||
import com.jozufozu.flywheel.config.FlwCommands;
|
||||
import com.jozufozu.flywheel.config.FlwConfig;
|
||||
import com.jozufozu.flywheel.impl.BackendManagerImpl;
|
||||
import com.jozufozu.flywheel.impl.registry.IdRegistryImpl;
|
||||
import com.jozufozu.flywheel.impl.registry.RegistryImpl;
|
||||
import com.jozufozu.flywheel.impl.visualization.VisualizationEventHandler;
|
||||
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
|
||||
import com.jozufozu.flywheel.lib.material.CutoutShaders;
|
||||
import com.jozufozu.flywheel.lib.material.FogShaders;
|
||||
import com.jozufozu.flywheel.lib.material.StandardMaterialShaders;
|
||||
import com.jozufozu.flywheel.lib.memory.FlwMemoryTracker;
|
||||
import com.jozufozu.flywheel.lib.model.ModelCache;
|
||||
import com.jozufozu.flywheel.lib.model.ModelHolder;
|
||||
import com.jozufozu.flywheel.lib.model.baked.PartialModel;
|
||||
import com.jozufozu.flywheel.lib.util.LevelAttached;
|
||||
import com.jozufozu.flywheel.lib.util.ShadersModHandler;
|
||||
import com.jozufozu.flywheel.lib.util.StringUtil;
|
||||
import com.jozufozu.flywheel.vanilla.VanillaVisuals;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
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;
|
||||
|
||||
@Mod(Flywheel.ID)
|
||||
public class Flywheel {
|
||||
public static final String ID = "flywheel";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
|
||||
private static ArtifactVersion version;
|
||||
|
||||
public Flywheel() {
|
||||
ModLoadingContext modLoadingContext = ModLoadingContext.get();
|
||||
|
||||
version = modLoadingContext
|
||||
.getActiveContainer()
|
||||
.getModInfo()
|
||||
.getVersion();
|
||||
|
||||
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get()
|
||||
.getModEventBus();
|
||||
modEventBus.addListener(Flywheel::onCommonSetup);
|
||||
modEventBus.addListener(Flywheel::onRegister);
|
||||
|
||||
FlwConfig.get().registerSpecs(modLoadingContext);
|
||||
|
||||
modLoadingContext.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(
|
||||
() -> "any",
|
||||
(serverVersion, isNetwork) -> true
|
||||
));
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Flywheel.clientInit(forgeEventBus, modEventBus));
|
||||
public static ResourceLocation rl(String path) {
|
||||
return new ResourceLocation(ID, path);
|
||||
}
|
||||
|
||||
private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
|
||||
forgeEventBus.addListener(Flywheel::addDebugInfo);
|
||||
|
||||
forgeEventBus.addListener(BackendManagerImpl::onReloadLevelRenderer);
|
||||
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onClientTick);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onBeginFrame);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onRenderStage);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onEntityJoinLevel);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onEntityLeaveLevel);
|
||||
|
||||
forgeEventBus.addListener(FlwCommands::registerClientCommands);
|
||||
|
||||
forgeEventBus.addListener(Uniforms::onReloadLevelRenderer);
|
||||
|
||||
forgeEventBus.addListener((LevelEvent.Unload e) -> LevelAttached.onUnloadLevel(e));
|
||||
|
||||
// forgeEventBus.addListener(ExampleEffect::tick);
|
||||
// forgeEventBus.addListener(ExampleEffect::onReload);
|
||||
|
||||
modEventBus.addListener(Flywheel::registerClientReloadListeners);
|
||||
modEventBus.addListener(Flywheel::onClientSetup);
|
||||
modEventBus.addListener(Flywheel::onLoadComplete);
|
||||
|
||||
modEventBus.addListener(BackendManagerImpl::onEndClientResourceReload);
|
||||
|
||||
modEventBus.addListener((EndClientResourceReloadEvent e) -> ModelCache.onEndClientResourceReload(e));
|
||||
modEventBus.addListener(ModelHolder::onEndClientResourceReload);
|
||||
|
||||
modEventBus.addListener(PartialModel::onModelRegistry);
|
||||
modEventBus.addListener(PartialModel::onModelBake);
|
||||
|
||||
public static void earlyInit() {
|
||||
BackendManagerImpl.init();
|
||||
|
||||
ShadersModHandler.init();
|
||||
|
@ -122,64 +32,17 @@ public class Flywheel {
|
|||
Backends.init();
|
||||
}
|
||||
|
||||
private static void registerClientReloadListeners(RegisterClientReloadListenersEvent event) {
|
||||
event.registerReloadListener(FlwPrograms.ResourceReloadListener.INSTANCE);
|
||||
}
|
||||
|
||||
private static void onClientSetup(FMLClientSetupEvent event) {
|
||||
public static void init() {
|
||||
InstanceTypes.init();
|
||||
CutoutShaders.init();
|
||||
FogShaders.init();
|
||||
StandardMaterialShaders.init();
|
||||
|
||||
ShaderIndices.init();
|
||||
|
||||
VanillaVisuals.init();
|
||||
}
|
||||
|
||||
private static void onLoadComplete(FMLLoadCompleteEvent event) {
|
||||
public static void freeze() {
|
||||
RegistryImpl.freezeAll();
|
||||
IdRegistryImpl.freezeAll();
|
||||
}
|
||||
|
||||
private static void onCommonSetup(FMLCommonSetupEvent event) {
|
||||
ArgumentTypeInfos.registerByClass(BackendArgument.class, BackendArgument.INFO);
|
||||
}
|
||||
|
||||
private static void onRegister(RegisterEvent event) {
|
||||
event.register(ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES, rl("backend"), () -> BackendArgument.INFO);
|
||||
}
|
||||
|
||||
private static void addDebugInfo(CustomizeGuiOverlayEvent.DebugText event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
if (!mc.options.renderDebug) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> info = event.getRight();
|
||||
info.add("");
|
||||
info.add("Flywheel: " + getVersion());
|
||||
info.add("Backend: " + BackendManagerImpl.getBackendString());
|
||||
info.add("Update limiting: " + (FlwConfig.get().limitUpdates() ? "on" : "off"));
|
||||
|
||||
VisualizationManager manager = VisualizationManager.get(mc.level);
|
||||
if (manager != null) {
|
||||
info.add("B: " + manager.getBlockEntities().getVisualCount()
|
||||
+ ", E: " + manager.getEntities().getVisualCount()
|
||||
+ ", F: " + manager.getEffects().getVisualCount());
|
||||
Vec3i renderOrigin = manager.getRenderOrigin();
|
||||
info.add("Origin: " + renderOrigin.getX() + ", " + renderOrigin.getY() + ", " + renderOrigin.getZ());
|
||||
}
|
||||
|
||||
info.add("Memory Usage: CPU: " + StringUtil.formatBytes(FlwMemoryTracker.getCPUMemory()) + ", GPU: " + StringUtil.formatBytes(FlwMemoryTracker.getGPUMemory()));
|
||||
}
|
||||
|
||||
public static ArtifactVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public static ResourceLocation rl(String path) {
|
||||
return new ResourceLocation(ID, path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
|||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mixin(GlStateManager.class)
|
||||
@Mixin(value = GlStateManager.class, remap = false)
|
||||
abstract class GlStateManagerMixin {
|
||||
@Inject(method = "_glBindBuffer(II)V", at = @At("RETURN"))
|
||||
private static void flywheel$onBindBuffer(int target, int buffer, CallbackInfo ci) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.engine.uniform.FogUniforms;
|
|||
import com.jozufozu.flywheel.backend.gl.GlCompat;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
@Mixin(RenderSystem.class)
|
||||
@Mixin(value = RenderSystem.class, remap = false)
|
||||
abstract class RenderSystemMixin {
|
||||
@Inject(method = "initRenderer(IZ)V", at = @At("RETURN"))
|
||||
private static void flywheel$onInitRenderer(CallbackInfo ci) {
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
plugins {
|
||||
id 'maven-publish'
|
||||
id 'dev.architectury.loom'
|
||||
}
|
||||
|
||||
evaluationDependsOn(':common')
|
||||
|
||||
base {
|
||||
|
@ -30,38 +25,7 @@ loom {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
url 'https://www.cursemaven.com'
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name 'tterrag maven'
|
||||
url 'https://maven.tterrag.com/'
|
||||
}
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$minecraft_version"
|
||||
mappings(loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
|
||||
})
|
||||
|
||||
modCompileOnly "net.fabricmc:fabric-loader:$fabric_loader_version"
|
||||
modLocalRuntime "net.fabricmc:fabric-loader:$fabric_loader_version"
|
||||
|
||||
|
@ -79,86 +43,18 @@ dependencies {
|
|||
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
|
||||
}
|
||||
|
||||
java {
|
||||
JavaVersion javaVersion = JavaVersion.toVersion(java_version)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
processResources.configure {
|
||||
from(project(':common').sourceSets.main.resources)
|
||||
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version,
|
||||
forge_version_range : forge_version_range,
|
||||
loader_version_range : loader_version_range,
|
||||
mod_version : mod_version
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'pack.mcmeta', 'fabric.mod.json']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(':common').sourceSets.main.allSource)
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = Integer.parseInt(java_version)
|
||||
options.compilerArgs = ['-Xdiags:verbose']
|
||||
}
|
||||
|
||||
jar.configure {
|
||||
archiveClassifier = ''
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
sourcesJar.configure {
|
||||
from(project(':common').sourceSets.main.allSource)
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
javadoc.configure {
|
||||
source(project(':common').sourceSets.main.allJava)
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
|
||||
test.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
void addLicense(jarTask) {
|
||||
jarTask.from('LICENSE.md') {
|
||||
rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2'
|
||||
}
|
||||
}
|
||||
|
||||
void addManifest(jarTask) {
|
||||
jarTask.manifest {
|
||||
attributes([
|
||||
'Specification-Title' : 'flywheel',
|
||||
// 'Specification-Vendor': 'flywheel authors',
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.jar.archiveBaseName,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
// 'Implementation-Vendor': 'flywheel authors',
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/package-infos.gradle')
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register('mavenJava', MavenPublication) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.jozufozu.flywheel;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class FlywheelFabric implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
||||
}
|
||||
}
|
32
fabric/src/main/resources/fabric.mod.json
Normal file
32
fabric/src/main/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "flywheel",
|
||||
"version": "${version}",
|
||||
"name": "Flywheel",
|
||||
"description": "A modern engine for modded minecraft.",
|
||||
"authors": [
|
||||
"Jozufozu",
|
||||
"PepperCode1"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/flywheel/logo.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.jozufozu.flywheel.FlywheelFabric"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"flywheel.backend.mixins.json",
|
||||
"flywheel.impl.mixins.json",
|
||||
"flywheel.impl.sodium.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.20.1"
|
||||
}
|
||||
}
|
|
@ -1,8 +1,3 @@
|
|||
plugins {
|
||||
id 'maven-publish'
|
||||
id 'dev.architectury.loom'
|
||||
}
|
||||
|
||||
evaluationDependsOn(':common')
|
||||
|
||||
base {
|
||||
|
@ -10,6 +5,12 @@ base {
|
|||
}
|
||||
|
||||
loom {
|
||||
forge {
|
||||
mixinConfig "flywheel.backend.mixins.json"
|
||||
mixinConfig "flywheel.impl.mixins.json"
|
||||
mixinConfig "flywheel.impl.sodium.mixins.json"
|
||||
}
|
||||
|
||||
runs {
|
||||
configureEach {
|
||||
property 'forge.logging.markers', ''
|
||||
|
@ -30,38 +31,7 @@ loom {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
url 'https://www.cursemaven.com'
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name 'tterrag maven'
|
||||
url 'https://maven.tterrag.com/'
|
||||
}
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$minecraft_version"
|
||||
mappings(loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
|
||||
})
|
||||
|
||||
forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
compileOnly project(path: ':common', configuration: 'namedElements')
|
||||
|
@ -72,86 +42,18 @@ dependencies {
|
|||
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
|
||||
}
|
||||
|
||||
java {
|
||||
JavaVersion javaVersion = JavaVersion.toVersion(java_version)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
processResources.configure {
|
||||
from(project(':common').sourceSets.main.resources)
|
||||
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version,
|
||||
forge_version_range : forge_version_range,
|
||||
loader_version_range : loader_version_range,
|
||||
mod_version : mod_version
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'pack.mcmeta', 'fabric.mod.json']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(':common').sourceSets.main.allSource)
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = Integer.parseInt(java_version)
|
||||
options.compilerArgs = ['-Xdiags:verbose']
|
||||
}
|
||||
|
||||
jar.configure {
|
||||
archiveClassifier = ''
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
sourcesJar.configure {
|
||||
from(project(':common').sourceSets.main.allSource)
|
||||
addManifest(it)
|
||||
addLicense(it)
|
||||
}
|
||||
|
||||
javadoc.configure {
|
||||
source(project(':common').sourceSets.main.allJava)
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
|
||||
test.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
void addLicense(jarTask) {
|
||||
jarTask.from('LICENSE.md') {
|
||||
rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2'
|
||||
}
|
||||
}
|
||||
|
||||
void addManifest(jarTask) {
|
||||
jarTask.manifest {
|
||||
attributes([
|
||||
'Specification-Title' : 'flywheel',
|
||||
// 'Specification-Vendor': 'flywheel authors',
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.jar.archiveBaseName,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
// 'Implementation-Vendor': 'flywheel authors',
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/package-infos.gradle')
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register('mavenJava', MavenPublication) {
|
||||
|
|
154
forge/src/main/java/com/jozufozu/flywheel/FlywheelForge.java
Normal file
154
forge/src/main/java/com/jozufozu/flywheel/FlywheelForge.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
package com.jozufozu.flywheel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
|
||||
import com.jozufozu.flywheel.api.event.EndClientResourceReloadEvent;
|
||||
import com.jozufozu.flywheel.api.visualization.VisualizationManager;
|
||||
import com.jozufozu.flywheel.backend.compile.FlwPrograms;
|
||||
import com.jozufozu.flywheel.backend.engine.uniform.Uniforms;
|
||||
import com.jozufozu.flywheel.config.BackendArgument;
|
||||
import com.jozufozu.flywheel.config.FlwCommands;
|
||||
import com.jozufozu.flywheel.config.FlwConfig;
|
||||
import com.jozufozu.flywheel.impl.BackendManagerImpl;
|
||||
import com.jozufozu.flywheel.impl.visualization.VisualizationEventHandler;
|
||||
import com.jozufozu.flywheel.lib.memory.FlwMemoryTracker;
|
||||
import com.jozufozu.flywheel.lib.model.ModelCache;
|
||||
import com.jozufozu.flywheel.lib.model.ModelHolder;
|
||||
import com.jozufozu.flywheel.lib.model.baked.PartialModel;
|
||||
import com.jozufozu.flywheel.lib.util.LevelAttached;
|
||||
import com.jozufozu.flywheel.lib.util.StringUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
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;
|
||||
|
||||
@Mod(Flywheel.ID)
|
||||
public class FlywheelForge {
|
||||
private static ArtifactVersion version;
|
||||
|
||||
public FlywheelForge() {
|
||||
ModLoadingContext modLoadingContext = ModLoadingContext.get();
|
||||
|
||||
version = modLoadingContext
|
||||
.getActiveContainer()
|
||||
.getModInfo()
|
||||
.getVersion();
|
||||
|
||||
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get()
|
||||
.getModEventBus();
|
||||
modEventBus.addListener(FlywheelForge::onCommonSetup);
|
||||
modEventBus.addListener(FlywheelForge::onRegister);
|
||||
|
||||
FlwConfig.get().registerSpecs(modLoadingContext);
|
||||
|
||||
modLoadingContext.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(
|
||||
() -> "any",
|
||||
(serverVersion, isNetwork) -> true
|
||||
));
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FlywheelForge.clientInit(forgeEventBus, modEventBus));
|
||||
}
|
||||
|
||||
private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
|
||||
forgeEventBus.addListener(FlywheelForge::addDebugInfo);
|
||||
|
||||
forgeEventBus.addListener(BackendManagerImpl::onReloadLevelRenderer);
|
||||
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onClientTick);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onBeginFrame);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onRenderStage);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onEntityJoinLevel);
|
||||
forgeEventBus.addListener(VisualizationEventHandler::onEntityLeaveLevel);
|
||||
|
||||
forgeEventBus.addListener(FlwCommands::registerClientCommands);
|
||||
|
||||
forgeEventBus.addListener(Uniforms::onReloadLevelRenderer);
|
||||
|
||||
forgeEventBus.addListener((LevelEvent.Unload e) -> LevelAttached.onUnloadLevel(e));
|
||||
|
||||
// forgeEventBus.addListener(ExampleEffect::tick);
|
||||
// forgeEventBus.addListener(ExampleEffect::onReload);
|
||||
|
||||
modEventBus.addListener(FlywheelForge::registerClientReloadListeners);
|
||||
modEventBus.addListener(FlywheelForge::onClientSetup);
|
||||
modEventBus.addListener(FlywheelForge::onLoadComplete);
|
||||
|
||||
modEventBus.addListener(BackendManagerImpl::onEndClientResourceReload);
|
||||
|
||||
modEventBus.addListener((EndClientResourceReloadEvent e) -> ModelCache.onEndClientResourceReload(e));
|
||||
modEventBus.addListener(ModelHolder::onEndClientResourceReload);
|
||||
|
||||
modEventBus.addListener(PartialModel::onModelRegistry);
|
||||
modEventBus.addListener(PartialModel::onModelBake);
|
||||
|
||||
Flywheel.earlyInit();
|
||||
}
|
||||
|
||||
private static void registerClientReloadListeners(RegisterClientReloadListenersEvent event) {
|
||||
event.registerReloadListener(FlwPrograms.ResourceReloadListener.INSTANCE);
|
||||
}
|
||||
|
||||
private static void onClientSetup(FMLClientSetupEvent event) {
|
||||
Flywheel.init();
|
||||
}
|
||||
|
||||
private static void onLoadComplete(FMLLoadCompleteEvent event) {
|
||||
Flywheel.freeze();
|
||||
}
|
||||
|
||||
private static void onCommonSetup(FMLCommonSetupEvent event) {
|
||||
ArgumentTypeInfos.registerByClass(BackendArgument.class, BackendArgument.INFO);
|
||||
}
|
||||
|
||||
private static void onRegister(RegisterEvent event) {
|
||||
event.register(ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES, Flywheel.rl("backend"), () -> BackendArgument.INFO);
|
||||
}
|
||||
|
||||
private static void addDebugInfo(CustomizeGuiOverlayEvent.DebugText event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
if (!mc.options.renderDebug) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> info = event.getRight();
|
||||
info.add("");
|
||||
info.add("Flywheel: " + getVersion());
|
||||
info.add("Backend: " + BackendManagerImpl.getBackendString());
|
||||
info.add("Update limiting: " + (FlwConfig.get().limitUpdates() ? "on" : "off"));
|
||||
|
||||
VisualizationManager manager = VisualizationManager.get(mc.level);
|
||||
if (manager != null) {
|
||||
info.add("B: " + manager.getBlockEntities().getVisualCount()
|
||||
+ ", E: " + manager.getEntities().getVisualCount()
|
||||
+ ", F: " + manager.getEffects().getVisualCount());
|
||||
Vec3i renderOrigin = manager.getRenderOrigin();
|
||||
info.add("Origin: " + renderOrigin.getX() + ", " + renderOrigin.getY() + ", " + renderOrigin.getZ());
|
||||
}
|
||||
|
||||
info.add("Memory Usage: CPU: " + StringUtil.formatBytes(FlwMemoryTracker.getCPUMemory()) + ", GPU: " + StringUtil.formatBytes(FlwMemoryTracker.getGPUMemory()));
|
||||
}
|
||||
|
||||
public static ArtifactVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue