Skip to content

Commit

Permalink
@CallerAware; Identifiables; FabricMC compat; Cardinal Direction
Browse files Browse the repository at this point in the history
  • Loading branch information
rotgruengelb committed Mar 24, 2024
1 parent 553a771 commit 4216937
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

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

3 changes: 2 additions & 1 deletion .idea/misc.xml

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

9 changes: 9 additions & 0 deletions build.gradle
Expand Up @@ -28,6 +28,15 @@ tasks.withType(JavaCompile).configureEach {
options.compilerArgs << "-Xlint:unchecked"
}

processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"

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

def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1 +1 @@
version=1.0.0
version=1.2.0
@@ -0,0 +1,15 @@
package net.rotgruengelb.nixienaut.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation to indicate that the method is aware of the caller.<br>
* <h2>ALWAYS AVOID WRAPPING THE ANNOTATED METHOD!</h2>
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface CallerAware {
}
@@ -0,0 +1,21 @@
package net.rotgruengelb.nixienaut.math;

import net.rotgruengelb.nixienaut.object.StringIdentifiable;

public enum CardinalDirection implements StringIdentifiable {
NORTH("north"),
EAST("east"),
SOUTH("south"),
WEST("west");

private final String stringRepresentation;

CardinalDirection(String stringRepresentation) {
this.stringRepresentation = stringRepresentation;
}

@Override
public String getStringRepresentation() {
return stringRepresentation;
}
}
@@ -0,0 +1,32 @@
package net.rotgruengelb.nixienaut.object;

public interface FloatIdentifiable {

/**
* The float representation of the object.
*
* @return The float representation of the object.
*/
float getFloatRepresentation();

static float getFloatRepresentation(FloatIdentifiable identifiable) {
if (identifiable == null) {
return Float.NaN;
}
return identifiable.getFloatRepresentation();
}

static float getFloatRepresentation(IntIdentifiable identifiable) {
if (identifiable == null) {
return Float.NaN;
}
return identifiable.getIntRepresentation();
}

static float getFloatRepresentation(StringIdentifiable identifiable) {
if (identifiable == null) {
return Float.NaN;
}
return Float.parseFloat(identifiable.getStringRepresentation());
}
}
@@ -0,0 +1,25 @@
package net.rotgruengelb.nixienaut.object;

public interface IntIdentifiable {

/**
* The integer representation of the object.
*
* @return The integer representation of the object.
*/
int getIntRepresentation();

static int getIntRepresentation(IntIdentifiable identifiable) {
if (identifiable == null) {
return 0;
}
return identifiable.getIntRepresentation();
}

static int getIntRepresentation(StringIdentifiable identifiable) {
if (identifiable == null) {
return 0;
}
return Integer.parseInt(identifiable.getStringRepresentation());
}
}
@@ -0,0 +1,32 @@
package net.rotgruengelb.nixienaut.object;

public interface StringIdentifiable {

/**
* The string representation of the object.
*
* @return The string representation of the object.
*/
String getStringRepresentation();

static String getStringRepresentation(StringIdentifiable identifiable) {
if (identifiable == null) {
return "";
}
return identifiable.getStringRepresentation();
}

static String getStringRepresentation(IntIdentifiable identifiable) {
if (identifiable == null) {
return "0";
}
return Integer.toString(identifiable.getIntRepresentation());
}

static String getStringRepresentation(FloatIdentifiable identifiable) {
if (identifiable == null) {
return "0.0";
}
return Float.toString(identifiable.getFloatRepresentation());
}
}
27 changes: 27 additions & 0 deletions src/main/resources/fabric.mod.json
@@ -0,0 +1,27 @@
{
"schemaVersion": 1,
"id": "nixienaut",
"version": "${version}",
"name": "Nixienaut",
"description": "A common code Libary.",
"authors": [
"rotgruengelb"
],
"contact": {
"homepage": "https://github.com/rotgruengelb/Nixienaut",
"sources": "https://github.com/rotgruengelb/Nixienaut"
},
"license": "MIT",
"icon": "nixienaut.png",
"environment": "*",
"entrypoints": {},
"mixins": [],
"depends": {
"java": ">=17"
},
"custom": {
"modmenu": {
"badges": [ "library" ]
}
}
}
Binary file added src/main/resources/nixienaut.aseprite
Binary file not shown.
Binary file added src/main/resources/nixienaut.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4216937

Please sign in to comment.