Compare commits
7 Commits
Crog
...
v1.0.1-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88b58f137b | ||
|
|
dbab825f90 | ||
|
|
87fb6b94f6 | ||
|
|
197a115673 | ||
|
|
3bf86d170c | ||
|
|
25c3ab29b0 | ||
|
|
3f34718284 |
35
.github/workflows/build.yml
vendored
35
.github/workflows/build.yml
vendored
@@ -12,28 +12,39 @@ jobs:
|
||||
matrix:
|
||||
# Use these Java versions
|
||||
java: [
|
||||
17, # Current Java LTS & minimum supported by Minecraft
|
||||
17 # Minimum supported by Minecraft 1.18
|
||||
]
|
||||
# and run on both Linux and Windows
|
||||
os: [ubuntu-20.04, windows-2022]
|
||||
os: [ubuntu-20.04] # and run on Linux
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: checkout repository
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: validate gradle wrapper
|
||||
|
||||
- name: Extract current branch name
|
||||
shell: bash
|
||||
# bash pattern expansion to grab branch name without slashes
|
||||
run: ref="${GITHUB_REF#refs/heads/}" && echo "::set-output name=branch::${ref////-}"
|
||||
id: ref
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: setup jdk ${{ matrix.java }}
|
||||
|
||||
- name: Setup JDK${{ matrix.java }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- name: make gradle wrapper executable
|
||||
|
||||
- name: Make gradle wrapper executable
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
|
||||
- name: Capture build artifacts
|
||||
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
name: dust-fabric-${{ github.sha }}
|
||||
path: build/libs/*[0-9].jar
|
||||
19
README.md
19
README.md
@@ -1,9 +1,16 @@
|
||||
# Fabric Example Mod
|
||||
# Dust
|
||||
|
||||
## Setup
|
||||
## What...what is "Dust"?
|
||||
|
||||
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.
|
||||
I'm glad you asked! It's just a mod that adds the white ash particle from the Basalt Deltas biome to the underground to simulate dust! After all, the air wouldn't be 100% clear in a real mineshaft :p
|
||||
|
||||
## License
|
||||
|
||||
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
|
||||
Now to the nitty gritty:
|
||||
It works by checking if the player has the sky above them and by scaling the amount of particles based on depth.
|
||||
<br>
|
||||
-64y lots of particles!
|
||||
<br>
|
||||
64y: less particles :(
|
||||
<br>
|
||||
## Dependencies
|
||||
Dust requires the [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) but everything else Dust *needs* is included.
|
||||
***HOWEVER***, I recommend [Mod Menu](https://www.curseforge.com/minecraft/mc-mods/modmenu) to be able to use the config screen :p
|
||||
|
||||
30
build.gradle
30
build.gradle
@@ -11,6 +11,27 @@ version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.shedaniel.me/"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.terraformersmc.com"
|
||||
}
|
||||
maven {
|
||||
name = 'minelp'
|
||||
url = 'https://repo.minelittlepony-mod.com/maven/snapshot'
|
||||
}
|
||||
maven {
|
||||
name = 'minelp-release'
|
||||
url = 'https://repo.minelittlepony-mod.com/maven/release'
|
||||
}
|
||||
// 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.
|
||||
@@ -26,6 +47,15 @@ dependencies {
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
modApi "com.minelittlepony:kirin:${project.kirin_version}"
|
||||
include "com.minelittlepony:kirin:${project.kirin_version}"
|
||||
|
||||
//modImplementation "com.minelittlepony:minelittlepony:${project.minelp_version}"
|
||||
modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
@@ -3,14 +3,18 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=1.18.2+build.1
|
||||
minecraft_version=1.18.1
|
||||
yarn_mappings=1.18.1+build.22
|
||||
loader_version=0.13.3
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0
|
||||
maven_group = com.example
|
||||
archives_base_name = fabric-example-mod
|
||||
mod_version = 1.0.1
|
||||
maven_group = com.lizistired
|
||||
archives_base_name = dust
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.47.8+1.18.2
|
||||
fabric_version=0.46.4+1.18
|
||||
clothconfig_version = 6.1.48
|
||||
modmenu_version = 3.0.1
|
||||
minelp_version=4.4.0-beta.2
|
||||
kirin_version=1.10.0-beta.2
|
||||
|
||||
76
src/main/java/net/fabricmc/example/Dust.java
Normal file
76
src/main/java/net/fabricmc/example/Dust.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Random;
|
||||
|
||||
public class Dust implements ClientModInitializer {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("dust");
|
||||
|
||||
private static Dust instance;
|
||||
|
||||
public static Dust getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Dust() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private DustConfig config;
|
||||
|
||||
public DustConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
Path dustFolder = GamePaths.getConfigDirectory().resolve("dust");
|
||||
config = new DustConfig(dustFolder.resolve("userconfig.json"), this);
|
||||
config.load();
|
||||
|
||||
ClientTickEvents.END_CLIENT_TICK.register(this::createDust);
|
||||
}
|
||||
|
||||
public int getRandomNumberUsingInts(int min, int max) {
|
||||
Random random = new Random();
|
||||
return random.ints(min, max)
|
||||
.findFirst()
|
||||
.getAsInt();
|
||||
}
|
||||
|
||||
public static double lerp(double min, double max, double val) {
|
||||
return 1 - ((val - min) / (max - min));
|
||||
}
|
||||
|
||||
private void createDust(MinecraftClient client) {
|
||||
if (getConfig().getDustEnabled()) {
|
||||
if (!client.isPaused()) {
|
||||
if (client.world != null) {
|
||||
World world = client.world;
|
||||
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double probabilityNormalized = lerp(64, -64, client.player.getBlockY());
|
||||
for (int i = 0; i < probabilityNormalized; i++) {
|
||||
x = client.player.getPos().getX() + getRandomNumberUsingInts(-5, 5);
|
||||
y = client.player.getPos().getY() + getRandomNumberUsingInts(-20, 20);
|
||||
z = client.player.getPos().getZ() + getRandomNumberUsingInts(-5, 5);
|
||||
world.addParticle(ParticleTypes.WHITE_ASH, x, y, z, getRandomNumberUsingInts(-5, 20), getRandomNumberUsingInts(-5, 20), getRandomNumberUsingInts(-5, 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/main/java/net/fabricmc/example/DustConfig.java
Normal file
38
src/main/java/net/fabricmc/example/DustConfig.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import net.fabricmc.example.utils.JsonFile;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Vector;
|
||||
|
||||
public class DustConfig extends JsonFile {
|
||||
private transient final Dust dust;
|
||||
private Vector dimensions;
|
||||
private boolean dustEnabled = true;
|
||||
|
||||
public DustConfig(Path file, Dust dust) {
|
||||
super(file);
|
||||
|
||||
this.dust = dust;
|
||||
}
|
||||
|
||||
public Vector setDimensions(){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Vector getDimensions(){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean toggleDust(){
|
||||
dustEnabled = !dustEnabled;
|
||||
save();
|
||||
return dustEnabled;
|
||||
}
|
||||
|
||||
public boolean getDustEnabled(){
|
||||
return dustEnabled;
|
||||
}
|
||||
}
|
||||
11
src/main/java/net/fabricmc/example/DustModMenuFactory.java
Normal file
11
src/main/java/net/fabricmc/example/DustModMenuFactory.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
public class DustModMenuFactory implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return ModMenuScreen::new;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package net.fabricmc.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!");
|
||||
}
|
||||
}
|
||||
41
src/main/java/net/fabricmc/example/ModMenuScreen.java
Normal file
41
src/main/java/net/fabricmc/example/ModMenuScreen.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import com.minelittlepony.common.client.gui.GameGui;
|
||||
import com.minelittlepony.common.client.gui.element.*;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ModMenuScreen extends GameGui {
|
||||
public ModMenuScreen(@Nullable Screen parent) {
|
||||
super(new TranslatableText("menu.dust.title"), parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
int left = width / 2 - 100;
|
||||
int row = height / 4 + 14;
|
||||
|
||||
DustConfig config = Dust.getInstance().getConfig();
|
||||
|
||||
addButton(new Label(width / 2, 30)).setCentered().getStyle()
|
||||
.setText(getTitle());
|
||||
|
||||
addButton(new Button(left, row += 24).onClick(sender -> {
|
||||
sender.getStyle().setText("menu.dust.global." + config.toggleDust());
|
||||
})).getStyle()
|
||||
.setText("menu.dust.global." + config.getDustEnabled());
|
||||
|
||||
addButton(new Button(left, row += 34)
|
||||
.onClick(sender -> finish())).getStyle()
|
||||
.setText("gui.done");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(matrices);
|
||||
super.render(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package net.fabricmc.example.mixin;
|
||||
|
||||
import net.fabricmc.example.ExampleMod;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
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(TitleScreen.class)
|
||||
public class ExampleMixin {
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
|
||||
}
|
||||
}
|
||||
54
src/main/java/net/fabricmc/example/utils/JsonFile.java
Normal file
54
src/main/java/net/fabricmc/example/utils/JsonFile.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package net.fabricmc.example.utils;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import net.fabricmc.example.Dust;
|
||||
|
||||
public class JsonFile {
|
||||
protected transient final Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(getClass(), (InstanceCreator<JsonFile>)t -> this)
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
private transient Path file;
|
||||
|
||||
JsonFile() { }
|
||||
|
||||
public JsonFile(Path file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public final void load() {
|
||||
if (Files.isReadable(file)) {
|
||||
try (Reader reader = Files.newBufferedReader(file)) {
|
||||
load(reader);
|
||||
} catch (Exception e) {
|
||||
Dust.LOGGER.error("Invalid config", e);
|
||||
}
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public final void load(Reader reader) {
|
||||
gson.fromJson(reader, getClass());
|
||||
}
|
||||
|
||||
public final void save() {
|
||||
try {
|
||||
Files.createDirectories(file.getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(file)) {
|
||||
gson.toJson(this, writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 126 KiB |
5
src/main/resources/assets/modid/lang/en_us.json
Normal file
5
src/main/resources/assets/modid/lang/en_us.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"menu.dust.title": "Dust",
|
||||
"menu.dust.global.false": "Dust: disabled",
|
||||
"menu.dust.global.true": "Dust: enabled"
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "modid",
|
||||
"id": "dust",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Example Mod",
|
||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||
"name": "Dust",
|
||||
"description": "Makes dust underground that scales with depth!",
|
||||
"authors": [
|
||||
"Me!"
|
||||
"LizIsTired"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
"issues": "https://github.com/LizIsTired/dust/issues",
|
||||
"sources": "https://github.com/LizIsTired/dust"
|
||||
},
|
||||
|
||||
"license": "CC0-1.0",
|
||||
@@ -18,21 +18,29 @@
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"net.fabricmc.example.ExampleMod"
|
||||
"client": [
|
||||
"net.fabricmc.example.Dust"
|
||||
],
|
||||
"modmenu": [
|
||||
"net.fabricmc.example.DustModMenuFactory"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"modid.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.13.3",
|
||||
"fabricloader": ">=0.12.11",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.18.x",
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
"clothconfig": ">=6.1.48",
|
||||
"modmenu": ">=3.0.1"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"modmenu.discord": "https://discord.gg/AgBfPFMJgX"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.fabricmc.example.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user