-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@CallerAware; Identifiables; FabricMC compat; Cardinal Direction
- Loading branch information
1 parent
553a771
commit 4216937
Showing
12 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=1.0.0 | ||
version=1.2.0 |
15 changes: 15 additions & 0 deletions
15
src/main/java/net/rotgruengelb/nixienaut/annotation/CallerAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/net/rotgruengelb/nixienaut/math/CardinalDirection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/net/rotgruengelb/nixienaut/object/FloatIdentifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/net/rotgruengelb/nixienaut/object/IntIdentifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/net/rotgruengelb/nixienaut/object/StringIdentifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.