Skip to content

Commit

Permalink
remove architectury dep
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Apr 21, 2024
1 parent 903e815 commit 3454575
Show file tree
Hide file tree
Showing 28 changed files with 280 additions and 163 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ classes/
.metadata
.vscode
.settings
*.launch
*.launch
.architectury-transformer/
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## Changelog
- `spruceui` -> `obsidianui`
- new icon
- remove architectury dep
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ A Minecraft mod API which adds some GUI utilities.

<img alt="fabric" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/supported/fabric_vector.svg">
<img alt="forge" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/supported/forge_vector.svg">
<img alt="architectury-api" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/requires/architectury-api_vector.svg">

</div></center>

Expand Down Expand Up @@ -43,5 +42,5 @@ dependencies {
And this to your `gradle.properties`:

```properties
obsidianui_version=0.1.0+1.20.4
obsidianui_version=0.2.2+1.20.4
```
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "com.github.johnrengelman.shadow" version "8.+" apply false
id "com.hypherionmc.modutils.modpublisher" version "2.0.+" apply false
}

architectury {
Expand All @@ -10,6 +11,8 @@ architectury {

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.hypherionmc.modutils.modpublisher"

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
Expand Down
1 change: 0 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

package org.thinkingstudio.obsidianui;

import org.thinkingstudio.obsidianui.hud.HudManager;

public class ObsidianUI {
public static final String MODID = "obsidianui";

public static void clientInit() {
new HudManager().initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@

package org.thinkingstudio.obsidianui.hud;

import dev.architectury.event.events.client.ClientGuiEvent;
import dev.architectury.event.events.client.ClientTickEvent;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.thinkingstudio.obsidianui.event.OpenScreenCallback;
import org.thinkingstudio.obsidianui.event.ResolutionChangeCallback;

import java.util.Collection;
import java.util.Map;
Expand All @@ -31,26 +27,9 @@
* @since 1.2.0
*/
public class HudManager {
private static final Map<Identifier, Hud> HUDS = new Object2ObjectOpenHashMap<>();
public static final Map<Identifier, Hud> HUDS = new Object2ObjectOpenHashMap<>();

public void initialize() {
ClientGuiEvent.RENDER_HUD.register((graphics, tickDelta) -> HUDS.forEach((id, hud) -> {
if (hud.isEnabled() && hud.isVisible())
hud.render(graphics, tickDelta);
}));
ClientTickEvent.CLIENT_POST.register(client -> {
if (!canRenderHuds(client))
return;
HUDS.forEach((id, hud) -> {
if (hud.isEnabled() && hud.isVisible() && hud.hasTicks())
hud.tick();
});
});
OpenScreenCallback.EVENT.register((client, screen) -> initAll(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()));
ResolutionChangeCallback.EVENT.register(client -> initAll(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()));
}

protected static void initAll(@NotNull MinecraftClient client, int screenWidth, int screenHeight) {
public static void initAll(@NotNull MinecraftClient client, int screenWidth, int screenHeight) {
if (!canRenderHuds(client))
return;
HUDS.forEach((id, hud) -> {
Expand Down
3 changes: 1 addition & 2 deletions fabric/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## Changelog
- `spruceui` -> `obsidianui`
- new icon
- remove architectury dep
57 changes: 16 additions & 41 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
plugins {
id "com.github.johnrengelman.shadow" version "8.1.1"
id "me.shedaniel.unified-publishing"
}

architectury {
platformSetupLoomIde()
fabric()
Expand All @@ -21,8 +16,6 @@ configurations {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand Down Expand Up @@ -80,39 +73,21 @@ publishing {
}
}

unifiedPublishing {
project {
displayName = "[Fabric] $rootProject.version"
releaseType = "alpha"
changelog = file("CHANGELOG.md").getText('UTF-8')
gameVersions = ["1.20.3", "1.20.4"]
gameLoaders = ["fabric"]

mainPublication remapJar
secondaryPublications.builtBy(sourcesJar)

relations {
depends {
curseforge = "architectury-api"
modrinth = "architectury-api"
}
}

var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
}
}

var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$rootProject.version-fabric"
}
}
publisher {
apiKeys {
modrinth System.getenv("MODRINTH_TOKEN")
curseforge System.getenv("CURSE_TOKEN")
}

setCurseID("${rootProject.curseforge_id}")
setModrinthID("${rootProject.modrinth_id}")
setVersionType("beta")
setChangelog(file("CHANGELOG.md").getText("UTF-8"))
setVersion("${rootProject.version}-neoforge")
setDisplayName("[Fabric] ${rootProject.version}")
setGameVersions("1.20.3", "1.20.4")
setLoaders("fabric")
setCurseEnvironment("client")
setArtifact(remapJar)
addAdditionalFile(sourcesJar)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
package org.thinkingstudio.obsidianui.fabric;

import net.fabricmc.api.ClientModInitializer;
import org.thinkingstudio.obsidianui.ObsidianUI;
import org.thinkingstudio.obsidianui.fabric.event.FabricEventHandler;

public class ObsidianUIFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
ObsidianUI.clientInit();
FabricEventHandler.registerEvents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* see the LICENSE file.
*/

package org.thinkingstudio.obsidianui.event;
package org.thinkingstudio.obsidianui.fabric.event;

import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

/**
* Represents a set of utilities for ObsidianUI's events.
Expand All @@ -26,7 +26,11 @@ private EventUtil() {
}

static Event<OpenScreenCallback> makeOpenScreenEvent() {
return EventFactory.createLoop();
return EventFactory.createArrayBacked(OpenScreenCallback.class, listeners -> (client, screen) -> {
for (OpenScreenCallback event : listeners) {
event.apply(client, screen);
}
});
}

/**
Expand All @@ -37,6 +41,6 @@ static Event<OpenScreenCallback> makeOpenScreenEvent() {
*/
public static void onOpenScreen(OpenScreenCallback pre, OpenScreenCallback post) {
OpenScreenCallback.PRE.register(pre);
OpenScreenCallback.EVENT.register(post);
OpenScreenCallback.POST.register(post);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.thinkingstudio.obsidianui.fabric.event;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import org.thinkingstudio.obsidianui.hud.HudManager;

public class FabricEventHandler {
public static void registerEvents() {
HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> {
HudManager.HUDS.forEach((id, hud) -> {
if (hud.isEnabled() && hud.isVisible())
hud.render(matrixStack, tickDelta);
});
});
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (!HudManager.canRenderHuds(client))
return;
HudManager.HUDS.forEach((id, hud) -> {
if (hud.isEnabled() && hud.isVisible() && hud.hasTicks())
hud.tick();
});
});
OpenScreenCallback.POST.register((client, screen) -> HudManager.initAll(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()));
ResolutionChangeCallback.EVENT.register(client -> HudManager.initAll(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* see the LICENSE file.
*/

package org.thinkingstudio.obsidianui.event;
package org.thinkingstudio.obsidianui.fabric.event;

import dev.architectury.event.Event;
import net.fabricmc.fabric.api.event.Event;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.jetbrains.annotations.Nullable;
Expand All @@ -25,7 +25,7 @@
@FunctionalInterface
public interface OpenScreenCallback {
Event<OpenScreenCallback> PRE = EventUtil.makeOpenScreenEvent();
Event<OpenScreenCallback> EVENT = EventUtil.makeOpenScreenEvent();
Event<OpenScreenCallback> POST = EventUtil.makeOpenScreenEvent();

void apply(MinecraftClient client, @Nullable Screen screen);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* see the LICENSE file.
*/

package org.thinkingstudio.obsidianui.event;
package org.thinkingstudio.obsidianui.fabric.event;

import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.client.MinecraftClient;

/**
Expand All @@ -23,7 +23,11 @@
*/
@FunctionalInterface
public interface ResolutionChangeCallback {
Event<ResolutionChangeCallback> EVENT = EventFactory.createEventResult();
Event<ResolutionChangeCallback> EVENT = EventFactory.createArrayBacked(ResolutionChangeCallback.class, listeners -> client -> {
for (ResolutionChangeCallback event : listeners) {
event.apply(client);
}
});

void apply(MinecraftClient client);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* see the LICENSE file.
*/

package org.thinkingstudio.obsidianui.mixin;
package org.thinkingstudio.obsidianui.fabric.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.thinkingstudio.obsidianui.event.OpenScreenCallback;
import org.thinkingstudio.obsidianui.event.ResolutionChangeCallback;
import org.thinkingstudio.obsidianui.fabric.event.OpenScreenCallback;
import org.thinkingstudio.obsidianui.fabric.event.ResolutionChangeCallback;

/**
* Represents the injection point for the {@link OpenScreenCallback} and {@link ResolutionChangeCallback} events.
Expand All @@ -35,7 +35,7 @@ private void onScreenPre(Screen screen, CallbackInfo ci) {

@Inject(method = "setScreen", at = @At("RETURN"))
private void onScreenChange(Screen screen, CallbackInfo ci) {
OpenScreenCallback.EVENT.invoker().apply((MinecraftClient) (Object) this, screen);
OpenScreenCallback.POST.invoker().apply((MinecraftClient) (Object) this, screen);
}

@Inject(method = "onResolutionChanged", at = @At("RETURN"))
Expand Down
5 changes: 2 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
]
},
"mixins": [
"obsidianui.mixins.json"
"obsidianui.fabric.mixins.json"
],
"depends": {
"fabric": "*",
"minecraft": ">=1.20.2",
"architectury": "*"
"minecraft": ">=1.20.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"required": true,
"package": "org.thinkingstudio.obsidianui.mixin",
"package": "org.thinkingstudio.obsidianui.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"MinecraftClientMixin"
Expand Down
7 changes: 1 addition & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.caching=true

minecraft_version=1.20.4
enabled_platforms=fabric,neoforge
quilt_mappings=1.20.4+build.3

archives_base_name=ObsidianUI
mod_version=0.2.2
mod_version=0.2.3
maven_group=org.thinkingstudio.obsidianui

architectury_version=11.0.8

fabric_loader_version=0.15.2
fabric_api_version=0.91.3+1.20.4

Expand Down
Loading

0 comments on commit 3454575

Please sign in to comment.