Skip to content

Commit

Permalink
Convert to multiloader (Xplat + Forge) project, no Fabric yet
Browse files Browse the repository at this point in the history
  • Loading branch information
williewillus committed Jul 4, 2022
1 parent 373eee3 commit 513d410
Show file tree
Hide file tree
Showing 28 changed files with 221 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Thumbs.db

## gradle
/.gradle
/build
build/

## ForgeGradle
/run
Expand Down
84 changes: 84 additions & 0 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven {
url = 'https://repo.spongepowered.org/repository/maven-public/'
content { includeGroup "org.spongepowered" }
}
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'org.spongepowered.mixin'

version = "${project.neat_version}-${project.build_number}"

mixin {
add sourceSets.main, "neat.refmap.json"
config "neat.mixins.json"
}

minecraft {
mappings channel: "official", version: "${project.mc_version}"
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
workingDirectory project.file('../run')
property 'forge.logging.console.level', 'debug'
ideaModule "${rootProject.name}.${project.name}.main"

mods {
neat {
source sourceSets.main
source project(":Xplat").sourceSets.main
}
}
}
}
}

dependencies {
minecraft "net.minecraftforge:forge:${project.mc_version}-${project.forge_version}"
compileOnly project(":Xplat")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

compileJava {
source(project(":Xplat").sourceSets.main.allSource)
options.compilerArgs << "-Xlint:all,-classfile,-processing,-deprecation,-serial" << "-Werror"
}

sourcesJar {
from project(":Xplat").sourceSets.main.allJava
}

processResources {
from project(":Xplat").sourceSets.main.resources
inputs.property "version", project.version

filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}

jar {
manifest {
attributes([
"Specification-Title": "${project.mod_id}",
"Specification-Vendor": "vazkii",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": "${project.mod_id}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor" :"vazkii",
])
}
}

defaultTasks 'clean', 'build'
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,14 @@

import java.util.List;

public class NeatConfig {

public static final String MOD_ID = "neat";
public static boolean draw = true;

public interface ConfigAccess {
int maxDistance();
boolean renderInF1();
double heightAbove();
boolean drawBackground();
int backgroundPadding();
int backgroundHeight();
int barHeight();
int plateSize();
int plateSizeBoss();
boolean showAttributes();
boolean showArmor();
boolean groupArmor();
boolean colorByType();
int hpTextHeight();
boolean showMaxHP();
boolean showCurrentHP();
boolean showPercentage();
boolean showOnPlayers();
boolean showOnBosses();
boolean showOnlyFocused();
boolean showFullHealth();
boolean enableDebugInfo();
List<String> blacklist();
}

public static ConfigAccess instance;

public class NeatForgeConfig {
public static void init() {
Pair<ForgeNeatConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(ForgeNeatConfig::new);
instance = specPair.getLeft();
NeatConfig.instance = specPair.getLeft();
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, specPair.getRight());
}

private static class ForgeNeatConfig implements ConfigAccess {
private static class ForgeNeatConfig implements NeatConfig.ConfigAccess {
private final ConfigValue<Integer> maxDistance;
private final ConfigValue<Boolean> renderInF1;
private final ConfigValue<Double> heightAbove;
Expand Down Expand Up @@ -225,5 +193,4 @@ public List<String> blacklist() {
return (List<String>) blacklist.get();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class NeatForgeInitializer {
public NeatForgeInitializer() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (incoming, isNetwork) -> true));
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
NeatConfig.init();
NeatForgeConfig.init();
}

public void setup(FMLClientSetupEvent event) {
Expand Down
1 change: 1 addition & 0 deletions Forge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public net.minecraft.client.renderer.RenderType$CompositeRenderType
File renamed without changes.
17 changes: 17 additions & 0 deletions Xplat/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id('java')
id('org.spongepowered.gradle.vanilla') version '0.2.1-SNAPSHOT'
}

archivesBaseName = "${project.mod_name}-xplat"
version = "${project.neat_version}-${project.build_number}"

minecraft {
version(project.mc_version)
accessWideners 'src/main/resources/neat_xplat.accesswidener'
}

dependencies {
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
implementation "com.google.code.findbugs:jsr305:3.0.2"
}
37 changes: 37 additions & 0 deletions Xplat/src/main/java/vazkii/neat/NeatConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package vazkii.neat;

import java.util.List;

public class NeatConfig {

public static final String MOD_ID = "neat";
public static boolean draw = true;

public interface ConfigAccess {
int maxDistance();
boolean renderInF1();
double heightAbove();
boolean drawBackground();
int backgroundPadding();
int backgroundHeight();
int barHeight();
int plateSize();
int plateSizeBoss();
boolean showAttributes();
boolean showArmor();
boolean groupArmor();
boolean colorByType();
int hpTextHeight();
boolean showMaxHP();
boolean showCurrentHP();
boolean showPercentage();
boolean showOnPlayers();
boolean showOnBosses();
boolean showOnlyFocused();
boolean showFullHealth();
boolean enableDebugInfo();
List<String> blacklist();
}

public static ConfigAccess instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

import vazkii.neat.mixin.AccessorRenderType;

import static com.mojang.blaze3d.vertex.DefaultVertexFormat.*;

public class NeatRenderType extends RenderStateShard {
Expand All @@ -25,6 +27,6 @@ private static RenderType getHealthBarType() {
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setLightmapState(LIGHTMAP)
.createCompositeState(false);
return RenderType.create("neat_health_bar", POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, true, true, renderTypeState);
return AccessorRenderType.neat_create("neat_health_bar", POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, true, true, renderTypeState);
}
}
16 changes: 16 additions & 0 deletions Xplat/src/main/java/vazkii/neat/mixin/AccessorRenderType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package vazkii.neat.mixin;

import com.mojang.blaze3d.vertex.VertexFormat;

import net.minecraft.client.renderer.RenderType;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(RenderType.class)
public interface AccessorRenderType {
@Invoker("create")
static RenderType.CompositeRenderType neat_create(String name, VertexFormat format, VertexFormat.Mode mode, int bufSize, boolean affectsCrumbling, boolean sortOnUpload, RenderType.CompositeState glState) {
throw new IllegalStateException("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"mixins": [
],
"client": [
"AccessorRenderType",
"EntityRenderDispatcherMixin"
],
"injectors": {
Expand Down
5 changes: 5 additions & 0 deletions Xplat/src/main/resources/neat_xplat.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessWidener v1 named
# NOTE: These are access wideners needed by Xplat code.
# They must be duplicated in the loader-specific projects' AT/AW as well if not already done so by the loader.
accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
accessible class net/minecraft/client/renderer/RenderType$CompositeState
File renamed without changes.
Loading

0 comments on commit 513d410

Please sign in to comment.