Skip to content

Commit

Permalink
help its broken
Browse files Browse the repository at this point in the history
  • Loading branch information
grngxd committed Mar 8, 2024
1 parent 5bd4067 commit 6be721a
Show file tree
Hide file tree
Showing 26 changed files with 295 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pluginManagement {

rootProject.name = "void-ui"

//include("test-mod")
include("test-mod")
54 changes: 53 additions & 1 deletion src/main/kotlin/com/neptuneclient/voidui/rendering/Renderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,63 @@ import java.awt.Color
* and an [Int] version.
*/
interface Renderer {

/**
* Begins a new frame. This method should be called before any rendering operations.
*/
fun beginFrame()

/**
* Ends the current frame. This method should be called after all rendering operations.
*/
fun endFrame()

/**
* Frees all resources used by the renderer.
* This method should be called when the renderer is no longer needed.
* (Called before endFrame())
*/
fun freeResources()

/**
* Renders a frame with the given width and height and executes the given [frame] lambda.
* @param width width of the frame
* @param height height of the frame
* @param frame lambda to execute
*/
fun frame(width: Int, height: Int, frame: Runnable) {
beginFrame()
frame.run()
freeResources()
endFrame()
}

/**
* Renders a rectangle with the given dimensions, size and color.
* @param x x coordinate of the rectangle
* @param y y coordinate of the rectangle
* @param width width of the rectangle
* @param height height of the rectangle
* @param color color of the rectangle
*/
fun rectangle(x: Float, y: Float, width: Float, height: Float, color: Color)

fun rectangle(x: Int, y: Int, width: Int, height: Int, color: Color) {
rectangle(x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), color)
}

fun rectangle(x: Float, y: Float, width: Float, height: Float, color: Int) {
rectangle(x, y, width, height, Color(color))
}

/**
* Renders a rounded rectangle with the given dimensions, size, radius and color.
* @param x x coordinate of the rectangle
* @param y y coordinate of the rectangle
* @param width width of the rectangle
* @param height height of the rectangle
* @param radius radius of the rectangle
* @param color color of the rectangle
*/
fun roundedRectangle(x: Float, y: Float, width: Float, height: Float, radius: Float, color: Color)

}
2 changes: 0 additions & 2 deletions src/main/kotlin/com/neptuneclient/voidui/ui/Component.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ sealed class Component(
var width: Int? = null,
var height: Int? = null
) : Drawable {

abstract fun build(): Drawable

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ import kotlin.reflect.jvm.javaField
* @see Component
*/
abstract class ReactiveComponent : Component() {

/**
* Used to initialize a stateful variable. Whenever a stateful variable changes, the component gets rebuild.
*
* @param initialValue The initial value of the variable
*
* @param initial The initial value of the variable.
* @sample ``var testState by state(2)`` - Defines a stateful variable with an initial value of 2.
*/
fun <T> state(initialValue: T) = Delegates.observable(initialValue) { _, _, new ->
fun <T> state(initial: T) = Delegates.observable(initial) { _, _, new ->
println("gndfjldsfs: $new")
this.build()
// TODO handle component rebuilding properly
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ class MockRenderer : Renderer {
println("endFrame")
}

override fun freeResources() {
println("freeResources")
}

override fun rectangle(x: Float, y: Float, width: Float, height: Float, color: Color) {
println("rectangle: x=$x, y=$y, width=$width, height=$height, color=$color")
}

override fun roundedRectangle(x: Float, y: Float, width: Float, height: Float, radius: Float, color: Color) {
println("roundedRectangle: x=$x, y=$y, width=$width, height=$height, radius=$radius, color=$color")
}
}
84 changes: 84 additions & 0 deletions test-mod/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "1.9.22"
}

version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

loom {
splitEnvironmentSourceSets()

mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

}

dependencies {
implementation("org.lwjgl:lwjgl-nanovg:3.3.1")
implementation("org.lwjgl:lwjgl-nanovg:3.3.1:natives-windows")
implementation project(path: ':')

minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
36 changes: 0 additions & 36 deletions test-mod/build.gradle.kts

This file was deleted.

19 changes: 15 additions & 4 deletions test-mod/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
yarn_mappings=1.20.4+build.1
loader_version=0.15.0

# Mod Properties
mod_version=1.0.0
maven_group=com.example
archives_base_name=modid

# Fabric api
fabric_version=0.92.0+1.20.4
# Dependencies
fabric_version=0.91.1+1.20.4
10 changes: 10 additions & 0 deletions test-mod/src/client/java/com/example/ExampleModClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example;

import net.fabricmc.api.ClientModInitializer;

public class ExampleModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.mixin.client;

import net.minecraft.client.MinecraftClient;
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;

@Mixin(MinecraftClient.class)
public class ExampleClientMixin {
@Inject(at = @At("HEAD"), method = "run")
private void run(CallbackInfo info) {
// This code is injected into the start of MinecraftClient.run()V
}
}
4 changes: 4 additions & 0 deletions test-mod/src/client/kotlin/com/example/impl/IRenderer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.example.impl
import com.neptuneclient.voidui.rendering.Renderer
class IRenderer: Renderer {
}
11 changes: 11 additions & 0 deletions test-mod/src/client/resources/modid.client.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"required": true,
"package": "com.example.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
"ExampleClientMixin"
],
"injectors": {
"defaultRequire": 1
}
}
22 changes: 22 additions & 0 deletions test-mod/src/main/java/com/example/ExampleMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example;

import net.fabricmc.api.ModInitializer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExampleMod implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("modid");

@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.

LOGGER.info("Hello Fabric world!");
}
}
15 changes: 15 additions & 0 deletions test-mod/src/main/java/com/example/mixin/ExampleMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.mixin;

import net.minecraft.server.MinecraftServer;
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;

@Mixin(MinecraftServer.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "loadWorld")
private void init(CallbackInfo info) {
// This code is injected into the start of MinecraftServer.loadWorld()V
}
}
Loading

0 comments on commit 6be721a

Please sign in to comment.