Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.0 #5

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<h1 align="center">✨ Stellum<br></h1>
<p align="center">A general-purpose library that contains useful functions to reduce boilerplate.<br><br>
<p align="center">A general-purpose library that contains useful functions for our mods.<br><br>
<a href="https://modrinth.com/mod/stellum"><img src="https://github.com/intergrav/devins-badges/blob/v3/assets/compact/available/modrinth_46h.png?raw=true"/></a>
<a href="https://modrinth.com/mod/fabric-api"><img src="https://github.com/intergrav/devins-badges/blob/v3/assets/compact/requires/fabric-api_46h.png?raw=true"/>
<img src="https://github.com/intergrav/devins-badges/blob/v3/assets/compact/unsupported/forge_46h.png?raw=true"/>
</p></a>

## Planned features (not a solid list, can and will change):

- [x] ~~Easy screenshake API~~ (Added in 0.0.1-alpha)
- [ ] Functions to replace boilerplate item, block, tool, etc. code
- [ ] Simple event scheduler
- [x] ~~Easy screenshake API~~
- [x] ~~Simple event scheduler~~
- [ ] [AAA-Particles](https://modrinth.com/mod/aaa-particles) wrapper for ease of use
- [x] ~~Explosion API for large-scale, impactful explosions~~ (Added in 0.0.3-alpha, still heavily WIP)
- [x] ~~Block burning API (primarily for explosions)~~ (Added in 0.0.3-alpha)
- [x] ~~3D Perlin noise generator~~ (Added in 0.0.2-alpha)
- [x] ~~Easing functions~~ (Added in 0.0.2-alpha)
- [x] ~~Explosion API for large-scale, impactful explosions~~
- [x] ~~Block burning API (primarily for explosions)~~
- [x] ~~3D Perlin noise generator~~
- [x] ~~Easing functions~~

## Documentation:

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.21+build.9
loader_version=0.16.9

# Mod Properties
mod_version=0.0.3-alpha_1.21
mod_version=0.1.0
maven_group=astrinox.stellum
archives_base_name=stellum

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/astrinox/stellum/Stellum.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType;

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

import astrinox.stellum.command.StellumDebugCommand;
import astrinox.stellum.handlers.schedule.ScheduleHandler;
import astrinox.stellum.resource.StellumResourceReloadListener;

public class Stellum implements ModInitializer {
Expand All @@ -21,5 +23,6 @@ public void onInitialize() {

CommandRegistrationCallback.EVENT.register(StellumDebugCommand::register);
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new StellumResourceReloadListener());
ServerTickEvents.START_SERVER_TICK.register((server) -> ScheduleHandler.update());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package astrinox.stellum.handlers.schedule;

import java.util.HashMap;
import java.util.Map;

import net.minecraft.util.Identifier;

public class ScheduleHandler {
public static Map<Identifier, Task> tasks = new HashMap<>();

public static void update() {
for (Map.Entry<Identifier, Task> task : tasks.entrySet()) {
if (task.getValue().getDelay() <= 0) {
task.getValue().run();
if (task.getValue().getType() == TaskType.ONCE)
tasks.remove(task.getKey());
}
}
}

public static void addTask(Identifier id, Task task) {
tasks.put(id, task);
}

public static void removeTask(Identifier id) {
tasks.remove(id);
}
}
30 changes: 30 additions & 0 deletions src/main/java/astrinox/stellum/handlers/schedule/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package astrinox.stellum.handlers.schedule;

public class Task {
private final Runnable runnable;
private final TaskType type;
private final int delay;
private int currentDelay;

public Task(Runnable runnable, TaskType type, int delay) {
this.runnable = runnable;
this.type = type;
this.delay = delay;
this.currentDelay = delay + 1;
}

public void run() {
runnable.run();
}

public TaskType getType() {
return type;
}

public int getDelay() {
--currentDelay;
if (currentDelay < 0 && type == TaskType.REPEATING)
currentDelay = delay;
return currentDelay;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package astrinox.stellum.handlers.schedule;

public enum TaskType {
REPEATING,
ONCE
}