├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
└── main
│ ├── resources
│ ├── assets
│ │ └── cavedust
│ │ │ ├── particles
│ │ │ └── cave_dust.json
│ │ │ ├── icon.png
│ │ │ └── lang
│ │ │ ├── zh_cn.json
│ │ │ ├── en_us.json
│ │ │ ├── ru_ru.json
│ │ │ └── fr_fr.json
│ ├── cavedust.mixins.json
│ └── fabric.mod.json
│ └── java
│ └── net
│ └── lizistired
│ └── cavedust
│ ├── utils
│ ├── WindowFocusHelper.java
│ ├── KeybindingHelper.java
│ ├── MathHelper.java
│ ├── TranslatableTextHelper.java
│ ├── JsonFile.java
│ └── ParticleSpawnUtil.java
│ ├── mixin
│ ├── ClientWorldAccessor.java
│ └── MixinDebugScreenOverlay.java
│ ├── CaveDustModMenuFactory.java
│ ├── CaveDustServer.java
│ ├── CaveDustParticleFactory.java
│ ├── CaveDust.java
│ ├── ModMenuConfigScreen.java
│ └── CaveDustConfig.java
├── settings.gradle
├── .gitignore
├── gradle.properties
├── README.md
├── .github
└── workflows
│ ├── build-release.yml
│ └── build.yml
├── gradlew.bat
├── gradlew
└── LICENSE
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LizIsTired/cave_dust/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/particles/cave_dust.json:
--------------------------------------------------------------------------------
1 | {
2 | "textures": [
3 | "minecraft:generic_0"
4 | ]
5 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LizIsTired/cave_dust/HEAD/src/main/resources/assets/cavedust/icon.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = 'Fabric'
5 | url = 'https://maven.fabricmc.net/'
6 | }
7 | mavenCentral()
8 | gradlePluginPortal()
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/WindowFocusHelper.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import net.minecraft.client.MinecraftClient;
4 |
5 | public class WindowFocusHelper {
6 | private static boolean unpaused;
7 | public boolean unpausedMenu(MinecraftClient client){
8 | return unpaused;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # gradle
2 |
3 | .gradle/
4 | build/
5 | out/
6 | classes/
7 |
8 | # eclipse
9 |
10 | *.launch
11 |
12 | # idea
13 |
14 | .idea/
15 | *.iml
16 | *.ipr
17 | *.iws
18 |
19 | # vscode
20 |
21 | .settings/
22 | .vscode/
23 | bin/
24 | .classpath
25 | .project
26 |
27 | # macos
28 |
29 | *.DS_Store
30 |
31 | # fabric
32 |
33 | run/
34 | BackupSrc/
35 |
--------------------------------------------------------------------------------
/src/main/resources/cavedust.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "net.lizistired.cavedust.mixin",
5 | "compatibilityLevel": "JAVA_16",
6 | "mixins": [
7 | "ClientWorldAccessor",
8 | "MixinDebugScreenOverlay"
9 | ],
10 | "client": [
11 | ],
12 | "server": [
13 | ],
14 | "injectors": {
15 | "defaultRequire": 1
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/mixin/ClientWorldAccessor.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.mixin;
2 |
3 | import net.minecraft.client.world.ClientWorld;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.gen.Accessor;
6 |
7 | @Mixin(ClientWorld.Properties.class)
8 | public interface ClientWorldAccessor {
9 | @Accessor
10 | boolean getFlatWorld();
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/CaveDustModMenuFactory.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | import com.terraformersmc.modmenu.api.ConfigScreenFactory;
4 | import com.terraformersmc.modmenu.api.ModMenuApi;
5 |
6 | public class CaveDustModMenuFactory implements ModMenuApi {
7 | @Override
8 | public ConfigScreenFactory> getModConfigScreenFactory() {
9 | return ModMenuConfigScreen::new;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Done to increase the memory available to gradle.
2 | org.gradle.jvmargs=-Xmx1G
3 |
4 | # Fabric Properties
5 | # check these on https://fabricmc.net/develop
6 | minecraft_version=1.21.8
7 | yarn_mappings=1.21.8+build.1
8 | loader_version=0.17.2
9 | loom_version=1.11-SNAPSHOT
10 |
11 | # Mod Properties
12 | mod_version=3.0.1
13 | maven_group=com.lizistired
14 | archives_base_name=cave_dust
15 |
16 | # Dependencies
17 | fabric_version=0.133.0+1.21.8
18 | clothconfig_version=19.0.147
19 | modmenu_version=15.0.0
20 | kirin_version=1.21.0-beta.5+1.21.7
21 |
22 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/CaveDustServer.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | import net.fabricmc.api.ModInitializer;
4 | import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
5 | import net.minecraft.particle.SimpleParticleType;
6 | import net.minecraft.registry.Registries;
7 | import net.minecraft.registry.Registry;
8 | import net.minecraft.util.Identifier;
9 |
10 | public class CaveDustServer implements ModInitializer {
11 | public static final SimpleParticleType CAVE_DUST = FabricParticleTypes.simple();
12 | /**
13 | * Runs the mod initializer.
14 | */
15 | @Override
16 | public void onInitialize() {
17 | Registry.register(Registries.PARTICLE_TYPE, Identifier.of("cavedust", "cave_dust"), CAVE_DUST);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cave Dust
2 |
3 | ## What...what is "Cave Dust"?
4 |
5 | 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
6 |
7 | Now to the nitty gritty:
8 | It works by checking if the player has the sky above them while being below sea level and then scales the amount of particles based on depth.
9 |
It has a config system that you can access using Mod Menu.
10 |
11 | ## Dependencies
12 | Cave Dust requires the [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) but everything else Cave Dust *needs* is included.
13 | ***HOWEVER***, I recommend [Mod Menu](https://www.curseforge.com/minecraft/mc-mods/modmenu) to be able to use the config screen :p
14 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/mixin/MixinDebugScreenOverlay.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.mixin;
2 |
3 | import net.minecraft.client.gui.hud.DebugHud;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.injection.At;
6 | import org.spongepowered.asm.mixin.injection.Inject;
7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8 |
9 | import java.util.List;
10 |
11 | import static net.lizistired.cavedust.CaveDust.PARTICLE_AMOUNT;
12 | import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
13 |
14 | @Mixin(DebugHud.class)
15 | public abstract class MixinDebugScreenOverlay {
16 | @Inject(method = "getRightText", at = @At("RETURN"))
17 | private void appendDebugText(CallbackInfoReturnable> cir) {
18 | List messages = cir.getReturnValue();
19 |
20 | messages.add("");
21 | messages.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
22 | messages.add("");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "cavedust",
4 | "version": "${version}",
5 | "name": "Cave Dust",
6 | "description": "Makes dust underground that scales with depth!",
7 | "authors": [
8 | "LizIsTired"
9 | ],
10 | "contact": {
11 | "issues": "https://github.com/LizIsTired/dust/issues",
12 | "sources": "https://github.com/LizIsTired/dust"
13 | },
14 | "license": "MPL-2.0",
15 | "icon": "assets/cavedust/icon.png",
16 | "environment": "*",
17 | "entrypoints": {
18 | "client": [
19 | "net.lizistired.cavedust.CaveDust"
20 | ],
21 | "main": [
22 | "net.lizistired.cavedust.CaveDustServer"],
23 | "modmenu": [
24 | "net.lizistired.cavedust.CaveDustModMenuFactory"
25 | ]
26 | },
27 | "mixins": [
28 | "cavedust.mixins.json"
29 | ],
30 | "depends": {
31 | "fabricloader": ">=0.14.5",
32 | "fabric": "*",
33 | "minecraft": "1.21.8",
34 | "java": ">=17"
35 | },
36 | "suggests": {
37 | "modmenu": ">=3.0.1"
38 | },
39 | "custom": {
40 | "modmenu": {
41 | "links": {
42 | "modmenu.discord": "https://discord.gg/4m6kQSX6bx"
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/.github/workflows/build-release.yml:
--------------------------------------------------------------------------------
1 | name: build-release
2 |
3 | on:
4 | release:
5 | types:
6 | - published
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: Checkout sources
13 | uses: actions/checkout@v2
14 | - name: Set up JDK 16
15 | uses: actions/setup-java@v2
16 | with:
17 | distribution: 'temurin'
18 | java-version: 17
19 | - name: Cache Gradle packages
20 | uses: actions/cache@v2
21 | with:
22 | path: |
23 | ~/.gradle/caches
24 | ~/.gradle/loom-cache
25 | ~/.gradle/wrapper
26 | ~/.m2/repository
27 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
28 | restore-keys: ${{ runner.os }}-gradle
29 |
30 | - run: chmod +x gradlew
31 |
32 | - name: Build Release
33 | run: ./gradlew build --stacktrace
34 |
35 | - name: Upload artifacts to Modrinth, Curseforge and GitHub
36 | uses: Kir-Antipov/mc-publish@v3.3
37 | with:
38 | modrinth-id: jawg7zT1
39 | modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
40 |
41 | curseforge-id: 594750
42 | curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/KeybindingHelper.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
4 | import net.minecraft.client.option.KeyBinding;
5 | import net.minecraft.client.util.InputUtil;
6 | import org.lwjgl.glfw.GLFW;
7 |
8 | public class KeybindingHelper {
9 |
10 | public static KeyBinding keyBinding1;
11 | public static KeyBinding keyBinding2;
12 |
13 |
14 | public static void registerKeyBindings(){
15 | keyBinding1 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
16 | "key.cavedust.toggle",
17 | InputUtil.Type.KEYSYM,// The translation key of the keybinding's name // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
18 | GLFW.GLFW_KEY_KP_ADD, // The keycode of the key
19 | "category.cavedust.spook" // The translation key of the keybinding's category.
20 | ));
21 | keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
22 | "key.cavedust.reload", // The translation key of the keybinding's name
23 | InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
24 | GLFW.GLFW_KEY_KP_ENTER, // The keycode of the key
25 | "category.cavedust.spook" // The translation key of the keybinding's category.
26 | ));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/MathHelper.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import java.util.Random;
4 | import java.util.concurrent.ThreadLocalRandom;
5 |
6 | public class MathHelper {
7 | /**
8 | * Normalizes a value to between a range, eg. you want to map a value of 100 to 0 - 1, with 50 being 0.5.
9 | * @param min Minimum value
10 | * @param max Maximum value
11 | * @param val Value to be normalized
12 | * @return Normalized value (double)
13 | */
14 | public static double normalize(double min, double max, double val) {
15 | return 1 - ((val - min) / (max - min));
16 | }
17 |
18 | /**
19 | * Generates a random int between min and max
20 | * @param min Minimum value
21 | * @param max Maximum value
22 | * @return Random number (int)
23 | */
24 | public static int generateRandomInt(int min, int max) {
25 | Random random = new Random();
26 | return random.ints(min, max)
27 | .findFirst()
28 | .getAsInt();
29 | }
30 |
31 | /**
32 | * Generates a random double between min and max
33 | * @param min Minimum value
34 | * @param max Maximum value
35 | * @return Random number (double)
36 | */
37 | public static double generateRandomDouble(double min, double max) {
38 | try {
39 | return ThreadLocalRandom.current().nextDouble(min, max);
40 | } catch (IllegalArgumentException e) {
41 | return 0;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/TranslatableTextHelper.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import com.minelittlepony.common.client.gui.element.AbstractSlider;
4 | import net.minecraft.text.Text;
5 |
6 | public class TranslatableTextHelper {
7 | public Text formatMaxWidth(AbstractSlider slider) {
8 | return Text.translatable("menu.cavedust.width", (int)Math.floor(slider.getValue()));
9 | }
10 | public Text formatMaxHeight(AbstractSlider slider) {
11 | return Text.translatable("menu.cavedust.height", (int)Math.floor(slider.getValue()));
12 | }
13 | public Text formatUpperLimit(AbstractSlider slider) {
14 | return Text.translatable("menu.cavedust.upperlimit", (int)Math.floor(slider.getValue()));
15 | }
16 | public Text formatLowerLimit(AbstractSlider slider) {
17 | return Text.translatable("menu.cavedust.lowerlimit", (int)Math.floor(slider.getValue()));
18 | }
19 | public Text formatParticleMultiplier(AbstractSlider slider) {
20 | return Text.translatable("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
21 | }
22 |
23 | public Text formatParticleMultiplierMultiplier(AbstractSlider slider) {
24 | return Text.translatable("menu.cavedust.particlemultipliermultiplier", (int)Math.floor(slider.getValue()));
25 | }
26 | public Text formatVelocityRandomness(AbstractSlider slider) {
27 | return Text.translatable("menu.cavedust.velocityrandomness", (int) Math.floor(slider.getValue()));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/JsonFile.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.IOException;
5 | import java.io.Reader;
6 | import java.nio.file.Files;
7 | import java.nio.file.Path;
8 |
9 | import com.google.gson.Gson;
10 | import com.google.gson.GsonBuilder;
11 | import com.google.gson.InstanceCreator;
12 | import net.lizistired.cavedust.CaveDust;
13 |
14 | public class JsonFile {
15 | protected transient final Gson gson = new GsonBuilder()
16 | .registerTypeAdapter(getClass(), (InstanceCreator)t -> this)
17 | .setPrettyPrinting()
18 | .create();
19 |
20 | private transient Path file;
21 |
22 | JsonFile() { }
23 |
24 | public JsonFile(Path file) {
25 | this.file = file;
26 | }
27 |
28 | public final void load() {
29 | if (Files.isReadable(file)) {
30 | try (Reader reader = Files.newBufferedReader(file)) {
31 | load(reader);
32 | } catch (Exception e) {
33 | CaveDust.LOGGER.error("Invalid config", e);
34 | }
35 | }
36 |
37 | save();
38 | }
39 |
40 | public final void load(Reader reader) {
41 | gson.fromJson(reader, getClass());
42 | }
43 |
44 | public final void save() {
45 | try {
46 | Files.createDirectories(file.getParent());
47 | try (BufferedWriter writer = Files.newBufferedWriter(file)) {
48 | gson.toJson(this, writer);
49 | }
50 | } catch (IOException e) {
51 | e.printStackTrace();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # Automatically build the project and run any configured tests for every push
2 | # and submitted pull request. This can help catch issues that only occur on
3 | # certain platforms or Java versions, and provides a first line of defence
4 | # against bad commits.
5 |
6 | name: build
7 | on: [pull_request, push]
8 |
9 | jobs:
10 | build:
11 | strategy:
12 | matrix:
13 | # Use these Java versions
14 | java: [
15 | 17 # Minimum supported by Minecraft 1.18
16 | ]
17 | os: [ubuntu-20.04] # and run on Linux
18 | runs-on: ${{ matrix.os }}
19 |
20 | steps:
21 | - name: Checkout repository
22 | uses: actions/checkout@v2
23 |
24 | - name: Extract current branch name
25 | shell: bash
26 | # bash pattern expansion to grab branch name without slashes
27 | run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
28 | id: ref
29 |
30 | - name: Set outputs
31 | id: vars
32 | run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
33 | - name: Check outputs
34 | run: echo ${{ steps.vars.outputs.sha_short }}
35 |
36 | - name: Validate gradle wrapper
37 | uses: gradle/wrapper-validation-action@v1
38 |
39 | - name: Setup JDK${{ matrix.java }}
40 | uses: actions/setup-java@v1
41 | with:
42 | java-version: ${{ matrix.java }}
43 |
44 | - name: Make gradle wrapper executable
45 | if: ${{ runner.os != 'Windows' }}
46 | run: chmod +x gradlew
47 |
48 | - name: Build
49 | run: ./gradlew build
50 |
51 | - name: Capture build artifacts
52 | if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
53 | uses: actions/upload-artifact@v2
54 | with:
55 | name: dust-fabric-${{ steps.vars.outputs.sha_short }}
56 | path: build/libs/*[0-9].jar
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/lang/zh_cn.json:
--------------------------------------------------------------------------------
1 | {
2 | "menu.cavedust.title": "洞穴尘埃",
3 | "menu.cavedust.global.false": "洞穴尘埃: 功能启用",
4 | "menu.cavedust.global.true": "洞穴尘埃: 功能禁用",
5 | "menu.cavedust.global.tooltip.false": "启用洞穴尘埃粒子效果?",
6 | "menu.cavedust.global.tooltip.true": "禁用洞穴尘埃粒子效果?",
7 | "menu.cavedust.width": "边界宽度: %s",
8 | "menu.cavedust.height": "边界高度: %s",
9 | "menu.cavedust.width.tooltip": "生成粒子效果的最大宽度.",
10 | "menu.cavedust.height.tooltip": "生成粒子效果的最大高度.",
11 | "menu.cavedust.upperlimit": "最大高度限制: %s",
12 | "menu.cavedust.lowerlimit": "最低高度限制: %s",
13 | "menu.cavedust.upperlimit.tooltip": "粒子效果消失的高度 (读取玩家所在的 y 轴).",
14 | "menu.cavedust.lowerlimit.tooltip": "粒子效果出现最多的高度 (读取玩家所在的 y 轴).",
15 | "menu.cavedust.reset": "重置所有设置",
16 | "menu.cavedust.reset.tooltip": "你确定要这么做吗?",
17 | "menu.cavedust.particlemultiplier": "粒子数量: %s",
18 | "menu.cavedust.particlemultiplier.tooltip": "指定深度生成的粒子效果数量.",
19 | "menu.cavedust.particlemultipliermultiplier": "粒子效果倍率: %s",
20 | "menu.cavedust.particlemultipliermultiplier.tooltip": "粒子效果的生成倍率.",
21 | "menu.cavedust.velocityrandomness": "速度随机性: %s",
22 | "menu.cavedust.velocityrandomness.tooltip": "粒子效果的速度随机程度.",
23 | "menu.cavedust.enhanceddetection.true": "强化检测: 功能启用",
24 | "menu.cavedust.enhanceddetection.false": "强化检测: 功能禁用",
25 | "menu.cavedust.enhanceddetection.tooltip": "强化检测会使用粒子效果而非玩家的位置进行更精确的检测\n 对性能略有影响.",
26 | "menu.cavedust.superflatstatus.true": "超平坦粒子: 功能启用",
27 | "menu.cavedust.superflatstatus.false": "超平坦粒子: 功能禁用",
28 | "menu.cavedust.superflatstatus.tooltip": "是否允许超平坦世界生成洞穴尘埃?",
29 | "menu.cavedust.particle": "粒子效果: ",
30 | "menu.cavedust.particle.tooltip": "生成的粒子效果名称, 点击切换.",
31 |
32 | "key.cavedust.reload": "重载配置",
33 | "key.cavedust.toggle": "切换粒子",
34 | "category.cavedust.spook": "洞穴尘埃",
35 |
36 | "debug.cavedust.toggle.true": "(洞穴尘埃) 粒子效果已启用",
37 | "debug.cavedust.toggle.false": "(洞穴尘埃) 粒子效果已禁用",
38 | "debug.cavedust.reload": "(洞穴尘埃) 配置已重载",
39 | "debug.cavedust.particleerror": "(洞穴尘埃) 设置当前粒子效果时出现问题, 已自动切换至下一个粒子效果!"
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/CaveDustParticleFactory.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | import net.fabricmc.api.EnvType;
4 | import net.fabricmc.api.Environment;
5 | import net.minecraft.client.particle.*;
6 | import net.minecraft.client.world.ClientWorld;
7 | import net.minecraft.particle.SimpleParticleType;
8 |
9 | public class CaveDustParticleFactory extends SpriteBillboardParticle {
10 | private final SpriteProvider spriteProvider;
11 | CaveDustParticleFactory(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
12 | super(clientWorld, x, y, z);
13 | this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor method
14 | this.maxAge = 200; //20 ticks = 1 second
15 | this.scale = 0.1f;
16 | this.velocityX = velocityX; //The velX from the constructor parameters
17 | this.velocityY = -0.007f; //Allows the particle to slowly fall
18 | this.velocityZ = velocityZ;
19 | this.x = x; //The x from the constructor parameters
20 | this.y = y;
21 | this.z = z;
22 | this.collidesWithWorld = true;
23 | this.alpha = 1.0f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
24 | this.setSpriteForAge(spriteProvider); //Required
25 | }
26 |
27 | @Override
28 | public void tick() {
29 | super.tick();
30 | if(this.alpha < 0.0f){
31 | this.markDead();
32 | }
33 | this.alpha -= 0.005f;
34 | }
35 |
36 | @Override
37 | public ParticleTextureSheet getType() {
38 | return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
39 | }
40 |
41 | @Environment(EnvType.CLIENT)
42 | public static class Factory implements ParticleFactory {
43 | private final SpriteProvider spriteProvider;
44 |
45 | public Factory(SpriteProvider spriteProvider) {
46 | this.spriteProvider = spriteProvider;
47 | }
48 |
49 |
50 | public Particle createParticle(SimpleParticleType type, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
51 | return new CaveDustParticleFactory(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/lang/en_us.json:
--------------------------------------------------------------------------------
1 | {
2 | "menu.cavedust.title": "Cave Dust",
3 | "menu.cavedust.global.false": "Cave Dust: Disabled",
4 | "menu.cavedust.global.true": "Cave Dust: Enabled",
5 | "menu.cavedust.global.tooltip.false": "Enable cave dust particles?",
6 | "menu.cavedust.global.tooltip.true": "Disable cave dust particles?",
7 | "menu.cavedust.width": "Width bounds: %s",
8 | "menu.cavedust.height": "Height bounds: %s",
9 | "menu.cavedust.width.tooltip": "Maximum width to spawn particle.",
10 | "menu.cavedust.height.tooltip": "Maximum height to spawn particle.",
11 | "menu.cavedust.upperlimit": "Upper limit height: %s",
12 | "menu.cavedust.lowerlimit": "Lower limit height: %s",
13 | "menu.cavedust.upperlimit.tooltip": "The height where particles will fade out and stop spawning (uses player y).",
14 | "menu.cavedust.lowerlimit.tooltip": "The height where particles spawn the most (uses player y).",
15 | "menu.cavedust.reset": "Reset settings",
16 | "menu.cavedust.reset.tooltip": "Are you sure you want to reset all settings?",
17 | "menu.cavedust.particlemultiplier": "Particle amount: %s",
18 | "menu.cavedust.particlemultiplier.tooltip": "Amount of particles to spawn at any given depth.",
19 | "menu.cavedust.particlemultipliermultiplier": "Particle multiplier: %s",
20 | "menu.cavedust.particlemultipliermultiplier.tooltip": "Multiplies particle amount.",
21 | "menu.cavedust.velocityrandomness": "Velocity randomness: %s",
22 | "menu.cavedust.velocityrandomness.tooltip": "The randomness of the velocity of the particles.",
23 | "menu.cavedust.enhanceddetection.true": "Enhanced detection: Enabled",
24 | "menu.cavedust.enhanceddetection.false": "Enhanced detection: Disabled",
25 | "menu.cavedust.enhanceddetection.tooltip": "Enhanced detection enables more accurate checks, using the particles position\n instead of the player, has some performance impact.",
26 | "menu.cavedust.superflatstatus.true": "Superflat particles: Enabled",
27 | "menu.cavedust.superflatstatus.false": "Superflat particles: Disabled",
28 | "menu.cavedust.superflatstatus.tooltip": "Should particles spawn on superflat worlds?",
29 | "menu.cavedust.particle": "Particle: ",
30 | "menu.cavedust.particle.tooltip": "Particle to spawn. Click to cycle.",
31 |
32 | "key.cavedust.reload": "Reload Config",
33 | "key.cavedust.toggle": "Toggle Particles",
34 | "category.cavedust.spook": "Cave Dust",
35 |
36 | "debug.cavedust.toggle.true": "(Cave Dust) Enabled particles",
37 | "debug.cavedust.toggle.false": "(Cave Dust) Disabled particles",
38 | "debug.cavedust.reload": "(Cave Dust) Reloaded config",
39 | "debug.cavedust.particleerror": "(Cave Dust) Error setting particle, skipping to next particle!"
40 |
41 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/lang/ru_ru.json:
--------------------------------------------------------------------------------
1 | {
2 | "menu.cavedust.title": "Пещерная пыль",
3 | "menu.cavedust.global.false": "Пещерная пыль: отключена",
4 | "menu.cavedust.global.true": "Пещерная пыль: включена",
5 | "menu.cavedust.global.tooltip.false": "Включить частицы пещерной пыли?",
6 | "menu.cavedust.global.tooltip.true": "Отключить частицы пещерной пыли?",
7 | "menu.cavedust.minX": "Минимум по X: %s",
8 | "menu.cavedust.minY": "Минимум по Y: %s",
9 | "menu.cavedust.minZ": "Минимум по Z: %s",
10 | "menu.cavedust.maxX": "Максимум по X: %s",
11 | "menu.cavedust.maxY": "Максимум по Y: %s",
12 | "menu.cavedust.maxZ": "Максимум по Z: %s",
13 | "menu.cavedust.minX.tooltip": "Минимум по X: %s",
14 | "menu.cavedust.minY.tooltip": "Минимум по Y: %s",
15 | "menu.cavedust.minZ.tooltip": "Минимум по Z: %s",
16 | "menu.cavedust.maxX.tooltip": "Максимум по X: %s",
17 | "menu.cavedust.maxY.tooltip": "Максимум по Y: %s",
18 | "menu.cavedust.maxZ.tooltip": "Максимум по Z: %s",
19 | "menu.cavedust.upperlimit": "Верхний предел: %s",
20 | "menu.cavedust.lowerlimit": "Нижний предел: %s",
21 | "menu.cavedust.upperlimit.tooltip": "Высота, на которой частицы будут исчезать и перестанут появляться (испольует координату Y игрока).",
22 | "menu.cavedust.lowerlimit.tooltip": "The height where particles spawn the most (испольует координату Y игрока).",
23 | "menu.cavedust.reset": "Сброс настроек",
24 | "menu.cavedust.reset.tooltip": "Вы уверены, что хотите сбросить все настройки?",
25 | "menu.cavedust.particlemultiplier": "Множитель частиц: %s",
26 | "menu.cavedust.particlemultiplier.tooltip": "Увеличивает количество частиц на любой заданной глубине.",
27 | "menu.cavedust.velocityrandomness": "Случайность скорости: %s",
28 | "menu.cavedust.velocityrandomness.tooltip": "Случайность скорости движения частиц.",
29 | "menu.cavedust.enhanceddetection.true": "Улучшенное обнаружение: включено",
30 | "menu.cavedust.enhanceddetection.false": "Улучшенное обнаружение: отключено",
31 | "menu.cavedust.enhanceddetection.tooltip": "Улучшенное обнаружение позволяет проводить более точные проверки, используя положение частиц\nвместо положения игрока, что оказывает некоторое влияние на производительность.",
32 | "menu.cavedust.superflatstatus.true": "Частицы в суперплоскости: включены",
33 | "menu.cavedust.superflatstatus.false": "Частицы в суперплоскости: отключены",
34 | "menu.cavedust.superflatstatus.tooltip": "Должны ли частицы появляться в суперплоских мирах?",
35 |
36 | "key.cavedust.reload": "Перезагрузить конфигурацию",
37 | "key.cavedust.toggle": "Переключить частицы",
38 | "category.cavedust.spook": "Пещерная пыль",
39 |
40 | "debug.cavedust.toggle.true": "[Пещерная пыль] Включенные частицы",
41 | "debug.cavedust.toggle.false": "[Пещерная пыль] Отключенные частицы",
42 | "debug.cavedust.reload": "[Пещерная пыль] Конфигурация перезагружена"
43 |
44 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/cavedust/lang/fr_fr.json:
--------------------------------------------------------------------------------
1 | {
2 | "menu.cavedust.title": "Cave Dust",
3 | "menu.cavedust.global.false": "Cave Dust: Désactivée",
4 | "menu.cavedust.global.true": "Cave Dust: Activée",
5 | "menu.cavedust.global.tooltip.false": "Activer les particules de poussière de grotte ?",
6 | "menu.cavedust.global.tooltip.true": "Désactiver les particules de poussière de grotte ?",
7 | "menu.cavedust.minX": "Minimum X: %s",
8 | "menu.cavedust.minY": "Minimum Y: %s",
9 | "menu.cavedust.minZ": "Minimum Z: %s",
10 | "menu.cavedust.maxX": "Maximum X: %s",
11 | "menu.cavedust.maxY": "Maximum Y: %s",
12 | "menu.cavedust.maxZ": "Maximum Z: %s",
13 | "menu.cavedust.minX.tooltip": "Minimum X: %s",
14 | "menu.cavedust.minY.tooltip": "Minimum Y: %s",
15 | "menu.cavedust.minZ.tooltip": "Minimum Z: %s",
16 | "menu.cavedust.maxX.tooltip": "Maximum X: %s",
17 | "menu.cavedust.maxY.tooltip": "Maximum Y: %s",
18 | "menu.cavedust.maxZ.tooltip": "Maximum Z: %s",
19 | "menu.cavedust.upperlimit": "Limite supérieure : %s",
20 | "menu.cavedust.lowerlimit": "Limite inférieure : %s",
21 | "menu.cavedust.upperlimit.tooltip": "La hauteur à laquelle les particules s'estompent et cessent de spawner (utilise l'axe Y du joueur).",
22 | "menu.cavedust.lowerlimit.tooltip": "La hauteur où les particules apparaissent le plus (utilise l'axe Y du joueur).",
23 | "menu.cavedust.reset": "Réinitialiser les paramètres",
24 | "menu.cavedust.reset.tooltip": "Êtes-vous sûr de vouloir réinitialiser tous les paramètres ?",
25 | "menu.cavedust.particlemultiplier": "Multiplicateur de particules : %s",
26 | "menu.cavedust.particlemultiplier.tooltip": "Multiplie la quantité de particules à une profondeur donnée.",
27 | "menu.cavedust.velocityrandomness": "Aléatoire de la vélocité : %s",
28 | "menu.cavedust.velocityrandomness.tooltip": "Le niveau d'aléatoire de la vélocité des particules.",
29 | "menu.cavedust.enhanceddetection.true": "Détection améliorée : Activée",
30 | "menu.cavedust.enhanceddetection.false": "Détection améliorée : Désactivée",
31 | "menu.cavedust.enhanceddetection.tooltip": "La détection améliorée permet des vérifications plus précises en utilisant la position des particules\n plutôt que celle du joueur, mais impacte les performances.",
32 | "menu.cavedust.superflatstatus.true": "Particules sur monde Superflat : Activées",
33 | "menu.cavedust.superflatstatus.false": "Particules sur monde Superflat : Désactivées",
34 | "menu.cavedust.superflatstatus.tooltip": "Les particules doivent-elles apparaître sur les mondes Superflat ?",
35 |
36 | "key.cavedust.reload": "Recharger la configuration",
37 | "key.cavedust.toggle": "Activer/Désactiver les particules",
38 | "category.cavedust.spook": "Cave Dust",
39 |
40 | "debug.cavedust.toggle.true": "(Cave Dust) Particules activées",
41 | "debug.cavedust.toggle.false": "(Cave Dust) Particules désactivées",
42 | "debug.cavedust.reload": "(Cave Dust) Configuration rechargée"
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/utils/ParticleSpawnUtil.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust.utils;
2 |
3 | import net.lizistired.cavedust.CaveDustConfig;
4 | import net.lizistired.cavedust.mixin.ClientWorldAccessor;
5 | import net.minecraft.client.MinecraftClient;
6 | import net.minecraft.util.math.BlockPos;
7 | import net.minecraft.world.World;
8 |
9 | import java.util.Objects;
10 |
11 | import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES;
12 |
13 | public class ParticleSpawnUtil {
14 | private static float timer;
15 | public static boolean shouldParticlesSpawn;
16 |
17 |
18 | /**
19 | * Returns true if particles should spawn.
20 | * @param client MinecraftClient
21 | * @param config CaveDustConfig
22 | * @return boolean
23 | */
24 | public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
25 |
26 | //checks if the config is enabled, if the game isn't paused, if the world is valid, if the particle is valid and if the player isn't in a lush caves biome
27 | if (!config.getCaveDustEnabled()
28 | || client.isPaused()
29 | || client.world == null
30 | || !client.world.getDimension().bedWorks()
31 | || Objects.requireNonNull(client.player).isSubmergedInWater()
32 | || client.world.getBiome(Objects.requireNonNull(client.player.getBlockPos())).matchesKey(LUSH_CAVES))
33 | {
34 | timer = 0;
35 | shouldParticlesSpawn = false;
36 | return false;
37 | }
38 |
39 | World world = client.world;
40 | int seaLevel = world.getSeaLevel();
41 |
42 | if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
43 | if (client.player.getBlockPos().getY() + 2 < seaLevel){
44 | timer = timer + 1;
45 | if (timer > 10){
46 | timer = 10;
47 | shouldParticlesSpawn = true;
48 | return true;
49 | }
50 | }
51 | }
52 | shouldParticlesSpawn = false;
53 | return false;
54 | }
55 |
56 | /**
57 | * Returns true if particles should spawn (uses particle position instead of player).
58 | * @param client MinecraftClient
59 | * @param config CaveDustConfig
60 | * @param pos BlockPos
61 | * @return boolean
62 | */
63 | public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config, BlockPos pos) {
64 |
65 | //checks if the config is enabled, if the game isn't paused, if the world is valid, if the particle is valid and if the player isn't in a lush caves biome
66 | if (!config.getCaveDustEnabled()
67 | || client.isPaused()
68 | || client.world == null
69 | || !client.world.getDimension().bedWorks()
70 | || (client.world.getBottomY() > pos.getY())
71 | //|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
72 | || client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
73 |
74 | {
75 | timer = 0;
76 | shouldParticlesSpawn = false;
77 | return false;
78 | }
79 | if(!config.getSuperFlatStatus()) {
80 | if (((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()) {
81 | return false;
82 | }
83 | }
84 |
85 | World world = client.world;
86 | int seaLevel = world.getSeaLevel();
87 |
88 | if (!client.player.clientWorld.isSkyVisible(pos)) {
89 | if (pos.getY() + 2 < seaLevel){
90 | timer = timer + 1;
91 | if (timer > 10){
92 | timer = 10;
93 | shouldParticlesSpawn = true;
94 | return true;
95 | }
96 | }
97 | }
98 | shouldParticlesSpawn = false;
99 | return false;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/CaveDust.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | //minecraft imports
4 | import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
5 | import net.minecraft.client.MinecraftClient;
6 | import net.minecraft.particle.ParticleEffect;
7 | import net.minecraft.registry.Registries;
8 | import net.minecraft.registry.Registry;
9 | import net.minecraft.text.Text;
10 | import net.minecraft.util.Identifier;
11 | import net.minecraft.util.math.BlockPos;
12 | import net.minecraft.world.World;
13 | //other imports
14 | import com.minelittlepony.common.util.GamePaths;
15 | import net.fabricmc.api.ClientModInitializer;
16 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
17 | import org.slf4j.Logger;
18 | import org.slf4j.LoggerFactory;
19 | //java imports
20 | import java.nio.file.Path;
21 | //static imports
22 | import static net.lizistired.cavedust.utils.MathHelper.*;
23 | import static net.lizistired.cavedust.utils.MathHelper.generateRandomDouble;
24 | import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
25 | import static net.lizistired.cavedust.utils.KeybindingHelper.*;
26 |
27 |
28 | public class CaveDust implements ClientModInitializer {
29 | //logger
30 | public static final Logger LOGGER = LoggerFactory.getLogger("cavedust");
31 | //make class static
32 | private static CaveDust instance;
33 | public static CaveDust getInstance() {
34 | return instance;
35 | }
36 | public CaveDust() {
37 | instance = this;
38 | }
39 | //config assignment
40 | private static net.lizistired.cavedust.CaveDustConfig config;
41 | public net.lizistired.cavedust.CaveDustConfig getConfig() {
42 | return config;
43 | }
44 |
45 | public static ParticleEffect WHITE_ASH_ID = (ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust"));
46 | public static int PARTICLE_AMOUNT = 0;
47 |
48 |
49 |
50 |
51 | @Override
52 | public void onInitializeClient() {
53 | //config path and loading
54 | Path CaveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
55 | config = new CaveDustConfig(CaveDustFolder.getParent().resolve("cavedust.json"), this);
56 | config.load();
57 | registerKeyBindings();
58 | ParticleFactoryRegistry.getInstance().register(CaveDustServer.CAVE_DUST, CaveDustParticleFactory.Factory::new);
59 |
60 | //register end client tick to create cave dust function, using end client tick for async
61 | ClientTickEvents.END_CLIENT_TICK.register(this::createCaveDust);
62 | }
63 |
64 | private void createCaveDust(MinecraftClient client) {
65 | if (keyBinding1.wasPressed()){
66 | getConfig().toggleCaveDust();
67 | LOGGER.info("Toggled dust");
68 | client.player.sendMessage(Text.translatable("debug.cavedust.toggle." + config.getCaveDustEnabled()), false);
69 | }
70 | if (keyBinding2.wasPressed()){
71 | getConfig().load();
72 | LOGGER.info("Reloaded config");
73 | client.player.sendMessage(Text.translatable("debug.cavedust.reload"), false);
74 | }
75 |
76 | //ensure world is not null
77 | if (client.world == null) return;
78 | World world = client.world;
79 |
80 | //LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
81 | // )
82 | double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
83 | PARTICLE_AMOUNT = (int) (probabilityNormalized * config.getParticleMultiplier() * config.getParticleMultiplierMultiplier());
84 |
85 | for (int i = 0; i < PARTICLE_AMOUNT; i++) {
86 | int x = (int) (client.player.getPos().getX() + (int) generateRandomDouble(config.getDimensionWidth() *-1, config.getDimensionWidth()));
87 | int y = (int) (client.player.getEyePos().getY() + (int) generateRandomDouble(config.getDimensionHeight() *-1, config.getDimensionHeight()));
88 | int z = (int) (client.player.getPos().getZ() + (int) generateRandomDouble(config.getDimensionWidth() *-1, config.getDimensionWidth()));
89 | double miniX = (x + Math.random());
90 | double miniY = (y + Math.random());
91 | double miniZ = (z + Math.random());
92 | BlockPos particlePos = new BlockPos(x, y, z);
93 |
94 | if (shouldParticlesSpawn(client, config, particlePos)) {
95 | if (client.world.getBlockState(particlePos).isAir()) {
96 | world.addParticleClient(getConfig().getParticle(), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
97 | }
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/ModMenuConfigScreen.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | import com.minelittlepony.common.client.gui.GameGui;
4 | import com.minelittlepony.common.client.gui.element.*;
5 | import net.lizistired.cavedust.utils.TranslatableTextHelper;
6 | import net.minecraft.client.gui.DrawContext;
7 | import net.minecraft.client.gui.screen.Screen;
8 | import net.minecraft.particle.ParticleType;
9 | import net.minecraft.registry.Registries;
10 | import net.minecraft.text.Text;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.util.NoSuchElementException;
14 |
15 | public class ModMenuConfigScreen extends GameGui {
16 | public ModMenuConfigScreen(@Nullable Screen parent) {
17 | super(Text.translatable("menu.cavedust.title"), parent);
18 | }
19 |
20 | @Override
21 | public void init() {
22 | int left = width / 2 - 100;
23 | int row = height / 4 + 14;
24 |
25 | CaveDustConfig config = CaveDust.getInstance().getConfig();
26 | TranslatableTextHelper transText = new TranslatableTextHelper();;
27 | config.load();
28 |
29 | addButton(new Label(width / 2, 30)).setCentered().getStyle()
30 | .setText(getTitle());
31 |
32 | addButton(new Button(left += -110, row += -60).onClick(sender -> {
33 | sender.getStyle().setText("menu.cavedust.global." + config.toggleCaveDust()).setTooltip(Text.translatable("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
34 | })).getStyle()
35 | .setText("menu.cavedust.global." + config.getCaveDustEnabled())
36 | .setTooltip(Text.translatable("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
37 |
38 | /*addButton(new Button(left, row += 24).onClick(sender -> {
39 | sender.getStyle().setText("menu.cavedust.enhanceddetection." + config.setEnhancedDetection()).setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));
40 | })).getStyle()
41 | .setText("menu.cavedust.enhanceddetection." + config.getEnhancedDetection())
42 | .setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));*/
43 |
44 | addButton(new Button(left, row += 24).onClick(sender -> {
45 | sender.getStyle().setText("menu.cavedust.superflatstatus." + config.setSuperFlatStatus()).setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
46 | })).getStyle()
47 | .setText("menu.cavedust.superflatstatus." + config.getSuperFlatStatus())
48 | .setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
49 |
50 |
51 |
52 | /*addButton(new Slider(left, row += 48, -64, 319, config.getUpperLimit()))
53 | .onChange(config::setUpperLimit)
54 | .setTextFormat(transText::formatUpperLimit)
55 | .getStyle().setTooltip(Text.translatable("menu.cavedust.upperlimit.tooltip"));
56 |
57 | addButton(new Slider(left, row += 24, -64, 319, config.getLowerLimit()))
58 | .onChange(config::setLowerLimit)
59 | .setTextFormat(transText::formatLowerLimit)
60 | .getStyle().setTooltip(Text.translatable("menu.cavedust.lowerlimit.tooltip"));*/
61 |
62 | addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplier()))
63 | .onChange(config::setParticleMultiplier)
64 | .setTextFormat(transText::formatParticleMultiplier)
65 | .getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultiplier.tooltip"));
66 |
67 | addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplierMultiplier()))
68 | .onChange(config::setParticleMultiplierMultiplier)
69 | .setTextFormat(transText::formatParticleMultiplierMultiplier)
70 | .getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultipliermultiplier.tooltip"));
71 | addButton(new Button(left, row += 24).onClick(sender ->{
72 | config.iterateParticle();
73 | sender.getStyle().setText("Particle: " + (getNameOfParticle()));
74 | })).getStyle().setText("Particle: " + (getNameOfParticle()))
75 | .setTooltip(Text.translatable("menu.cavedust.particle.tooltip"));
76 |
77 | addButton(new Slider(left += 220, row -= 96, 1, 50, config.getDimensionWidth()))
78 | .onChange(config::setDimensionWidth)
79 | .setTextFormat(transText::formatMaxWidth)
80 | .getStyle().setTooltip(Text.translatable("menu.cavedust.width.tooltip"));
81 |
82 | addButton(new Slider(left, row += 24, 1, 50, config.getDimensionHeight()))
83 | .onChange(config::setDimensionHeight)
84 | .setTextFormat(transText::formatMaxHeight)
85 | .getStyle().setTooltip(Text.translatable("menu.cavedust.height.tooltip"));
86 |
87 | addButton(new Slider(left, row += 24, 0, 10, config.getVelocityRandomness()))
88 | .onChange(config::setVelocityRandomness)
89 | .setTextFormat(transText::formatVelocityRandomness)
90 | .getStyle().setTooltip(Text.translatable("menu.cavedust.velocityrandomness.tooltip"));
91 |
92 |
93 | addButton(new Button(left -= 110, row += 120).onClick(sender -> {
94 | config.resetConfig();
95 | finish();
96 | client.setScreen(new ModMenuConfigScreen(parent));
97 | })).getStyle().setText(Text.translatable("menu.cavedust.reset")).setTooltip(Text.translatable("menu.cavedust.reset.tooltip"));
98 |
99 | addButton(new Button(left, row += 24)
100 | .onClick(sender -> finish())).getStyle()
101 | .setText("gui.done");
102 |
103 | }
104 |
105 |
106 | @Override
107 | public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
108 | super.render(context, mouseX, mouseY, partialTicks);
109 | }
110 |
111 | private String getNameOfParticle(){
112 | CaveDustConfig config = CaveDust.getInstance().getConfig();
113 | config.load();
114 | try {
115 | return Registries.PARTICLE_TYPE.getEntry((ParticleType>) config.getParticleID()).getIdAsString();
116 | } catch (NoSuchElementException e){
117 | CaveDust.LOGGER.error(String.valueOf(e));
118 | return "null";
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/main/java/net/lizistired/cavedust/CaveDustConfig.java:
--------------------------------------------------------------------------------
1 | package net.lizistired.cavedust;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.lizistired.cavedust.utils.JsonFile;
5 | import net.minecraft.client.MinecraftClient;
6 | import net.minecraft.client.render.RenderLayer;
7 | import net.minecraft.particle.ParticleEffect;
8 | import net.minecraft.particle.ParticleType;
9 | import net.minecraft.particle.ParticleTypes;
10 | import net.minecraft.registry.Registries;
11 | import net.minecraft.registry.Registry;
12 | import net.minecraft.registry.RegistryKey;
13 | import net.minecraft.registry.RegistryKeys;
14 | import net.minecraft.text.Text;
15 | import net.minecraft.util.Identifier;
16 | import static net.lizistired.cavedust.CaveDust.*;
17 | import static net.lizistired.cavedust.utils.MathHelper.*;
18 |
19 | import java.nio.file.Path;
20 | import java.util.*;
21 |
22 | public class CaveDustConfig extends JsonFile {
23 | private transient final net.lizistired.cavedust.CaveDust CaveDust;
24 |
25 |
26 | private int width = 10;
27 | private int height = 10;
28 | private int velocityRandomness = 0;
29 |
30 | private boolean caveDustEnabled = true;
31 | private boolean seaLevelCheck = true;
32 | private boolean superFlatStatus = false;
33 | private float upperLimit = 64;
34 | private float lowerLimit = -64;
35 | private int particleMultiplier = 1;
36 |
37 | int listNumber = 0;
38 |
39 | private int particleMultiplierMultiplier = 10;
40 |
41 | List list = List.of(Registries.PARTICLE_TYPE.getIds().toArray(new Identifier[0]));
42 |
43 | Identifier newId = Identifier.of("cavedust", "cave_dust");
44 |
45 | public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
46 | super(file);
47 | this.CaveDust = caveDust;
48 | }
49 |
50 | public float setDimensionWidth(float size){
51 | if (this.width != size) {
52 | this.width = (int)size;
53 | save();
54 | }
55 | return getDimensionWidth();
56 | }
57 |
58 | public float setDimensionHeight(float size){
59 | if (this.height != size) {
60 | this.height = (int)size;
61 | save();
62 | }
63 | return getDimensionHeight();
64 | }
65 |
66 | public float getDimensionWidth(){
67 | return width;
68 | }
69 |
70 | public float getDimensionHeight(){
71 | return height;
72 | }
73 |
74 | public float setUpperLimit(float upperLimit){
75 | if (this.upperLimit - 1 < getLowerLimit())
76 | {
77 | return getUpperLimit();
78 | }
79 | if (this.upperLimit != upperLimit) {
80 | this.upperLimit = (int)upperLimit;
81 | save();
82 | }
83 | return getUpperLimit();
84 | }
85 |
86 | public float getUpperLimit(){
87 | return upperLimit;
88 | }
89 |
90 | public float setLowerLimit(float lowerLimit){
91 | if (this.lowerLimit + 1 > getUpperLimit())
92 | {
93 | return getLowerLimit();
94 | }
95 | if (this.lowerLimit != lowerLimit) {
96 | this.lowerLimit = (int)lowerLimit;
97 | save();
98 | }
99 | return getLowerLimit();
100 | }
101 |
102 | public float getLowerLimit(){
103 | return lowerLimit;
104 | }
105 |
106 | public int getParticleMultiplier(){
107 | return particleMultiplier;
108 | }
109 |
110 | public float setParticleMultiplier(float particleMultiplier){
111 | this.particleMultiplier = (int) particleMultiplier;
112 | save();
113 | return getParticleMultiplier();
114 | }
115 |
116 | public int getParticleMultiplierMultiplier(){
117 | return particleMultiplierMultiplier;
118 | }
119 |
120 | public float setParticleMultiplierMultiplier(float particleMultiplierMultiplier){
121 | this.particleMultiplierMultiplier = (int) particleMultiplierMultiplier;
122 | save();
123 | return getParticleMultiplierMultiplier();
124 | }
125 |
126 | public boolean toggleCaveDust(){
127 | caveDustEnabled = !caveDustEnabled;
128 | save();
129 | return caveDustEnabled;
130 | }
131 |
132 | public boolean getCaveDustEnabled(){
133 | return caveDustEnabled;
134 | }
135 |
136 | //todo
137 | //public Identifier setParticle(String particleType){
138 | //particleName = particleType;
139 | //save();
140 | //return getParticle().get().getKey().get().getValue();
141 | //}
142 |
143 | //public ParticleEffect getParticle(){
144 | // try {
145 | // return Registries.PARTICLE_TYPE.getOptional(Identifier.of(Registries.PARTICLE_TYPE.getOptional(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
146 | // } catch (ClassCastException e) {
147 | // MinecraftClient.getInstance().player.sendMessage(Text.translatable("debug.cavedust.particleerror"), true);
148 | // LOGGER.error("Cannot spawn particle, check config.");
149 | // iterateParticle();
150 | // save();
151 | // return getParticle();
152 | // }
153 | //}
154 |
155 | public ParticleEffect getParticle(){
156 | try{
157 | return (ParticleEffect) Registries.PARTICLE_TYPE.get(newId);
158 | }
159 | catch (ClassCastException e){
160 | iterateParticle();
161 | return getParticle();
162 | }
163 | }
164 |
165 | public boolean getSeaLevelCheck() {
166 | return seaLevelCheck;
167 | }
168 |
169 | public boolean setSeaLevelCheck() {
170 | seaLevelCheck = !seaLevelCheck;
171 | save();
172 | return getSeaLevelCheck();
173 | }
174 |
175 | public float getVelocityRandomnessRandom(){
176 | if (velocityRandomness == 0) {return 0;}
177 | return (float) generateRandomDouble(-velocityRandomness, velocityRandomness);
178 | }
179 |
180 | public float getVelocityRandomness(){
181 | return velocityRandomness;
182 | }
183 |
184 | public float setVelocityRandomness(float velocityRandomness){
185 | this.velocityRandomness = (int) velocityRandomness;
186 | save();
187 | return getVelocityRandomness();
188 | }
189 |
190 | public boolean getSuperFlatStatus(){
191 | return superFlatStatus;
192 | }
193 |
194 | public boolean setSuperFlatStatus(){
195 | superFlatStatus = !superFlatStatus;
196 | save();
197 | return getSuperFlatStatus();
198 | }
199 |
200 | public void iterateParticle() {
201 | try {
202 | listNumber = listNumber + 1;
203 | newId = list.get(listNumber);
204 | } catch (IndexOutOfBoundsException e){
205 | newId = list.get(0);
206 | listNumber = 0;
207 | }
208 | save();
209 | }
210 |
211 | public ParticleEffect getParticleID(){
212 | return getParticle();
213 | }
214 |
215 | public void resetConfig(){
216 | width = 10;
217 | height = 10;
218 |
219 | upperLimit = 64;
220 | lowerLimit = -64;
221 |
222 | particleMultiplier = 1;
223 | particleMultiplierMultiplier = 10;
224 | velocityRandomness = 0;
225 |
226 | newId = Identifier.of("cavedust", "cave_dust");
227 |
228 | seaLevelCheck = true;
229 | caveDustEnabled = true;
230 | save();
231 | }
232 | }
233 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90 | ' "$PWD" ) || exit
91 |
92 | # Use the maximum available, or set MAX_FD != -1 to use that value.
93 | MAX_FD=maximum
94 |
95 | warn () {
96 | echo "$*"
97 | } >&2
98 |
99 | die () {
100 | echo
101 | echo "$*"
102 | echo
103 | exit 1
104 | } >&2
105 |
106 | # OS specific support (must be 'true' or 'false').
107 | cygwin=false
108 | msys=false
109 | darwin=false
110 | nonstop=false
111 | case "$( uname )" in #(
112 | CYGWIN* ) cygwin=true ;; #(
113 | Darwin* ) darwin=true ;; #(
114 | MSYS* | MINGW* ) msys=true ;; #(
115 | NONSTOP* ) nonstop=true ;;
116 | esac
117 |
118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
119 |
120 |
121 | # Determine the Java command to use to start the JVM.
122 | if [ -n "$JAVA_HOME" ] ; then
123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
124 | # IBM's JDK on AIX uses strange locations for the executables
125 | JAVACMD=$JAVA_HOME/jre/sh/java
126 | else
127 | JAVACMD=$JAVA_HOME/bin/java
128 | fi
129 | if [ ! -x "$JAVACMD" ] ; then
130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
131 |
132 | Please set the JAVA_HOME variable in your environment to match the
133 | location of your Java installation."
134 | fi
135 | else
136 | JAVACMD=java
137 | if ! command -v java >/dev/null 2>&1
138 | then
139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
140 |
141 | Please set the JAVA_HOME variable in your environment to match the
142 | location of your Java installation."
143 | fi
144 | fi
145 |
146 | # Increase the maximum file descriptors if we can.
147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
148 | case $MAX_FD in #(
149 | max*)
150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151 | # shellcheck disable=SC2039,SC3045
152 | MAX_FD=$( ulimit -H -n ) ||
153 | warn "Could not query maximum file descriptor limit"
154 | esac
155 | case $MAX_FD in #(
156 | '' | soft) :;; #(
157 | *)
158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159 | # shellcheck disable=SC2039,SC3045
160 | ulimit -n "$MAX_FD" ||
161 | warn "Could not set maximum file descriptor limit to $MAX_FD"
162 | esac
163 | fi
164 |
165 | # Collect all arguments for the java command, stacking in reverse order:
166 | # * args from the command line
167 | # * the main class name
168 | # * -classpath
169 | # * -D...appname settings
170 | # * --module-path (only if needed)
171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
172 |
173 | # For Cygwin or MSYS, switch paths to Windows format before running java
174 | if "$cygwin" || "$msys" ; then
175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
177 |
178 | JAVACMD=$( cygpath --unix "$JAVACMD" )
179 |
180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
181 | for arg do
182 | if
183 | case $arg in #(
184 | -*) false ;; # don't mess with options #(
185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
186 | [ -e "$t" ] ;; #(
187 | *) false ;;
188 | esac
189 | then
190 | arg=$( cygpath --path --ignore --mixed "$arg" )
191 | fi
192 | # Roll the args list around exactly as many times as the number of
193 | # args, so each arg winds up back in the position where it started, but
194 | # possibly modified.
195 | #
196 | # NB: a `for` loop captures its iteration list before it begins, so
197 | # changing the positional parameters here affects neither the number of
198 | # iterations, nor the values presented in `arg`.
199 | shift # remove old arg
200 | set -- "$@" "$arg" # push replacement arg
201 | done
202 | fi
203 |
204 |
205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207 |
208 | # Collect all arguments for the java command:
209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210 | # and any embedded shellness will be escaped.
211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212 | # treated as '${Hostname}' itself on the command line.
213 |
214 | set -- \
215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
216 | -classpath "$CLASSPATH" \
217 | org.gradle.wrapper.GradleWrapperMain \
218 | "$@"
219 |
220 | # Stop when "xargs" is not available.
221 | if ! command -v xargs >/dev/null 2>&1
222 | then
223 | die "xargs is not available"
224 | fi
225 |
226 | # Use "xargs" to parse quoted args.
227 | #
228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
229 | #
230 | # In Bash we could simply go:
231 | #
232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
233 | # set -- "${ARGS[@]}" "$@"
234 | #
235 | # but POSIX shell has neither arrays nor command substitution, so instead we
236 | # post-process each arg (as a line of input to sed) to backslash-escape any
237 | # character that might be a shell metacharacter, then use eval to reverse
238 | # that process (while maintaining the separation between arguments), and wrap
239 | # the whole thing up as a single "set" statement.
240 | #
241 | # This will of course break if any of these variables contains a newline or
242 | # an unmatched quote.
243 | #
244 |
245 | eval "set -- $(
246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
247 | xargs -n1 |
248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
249 | tr '\n' ' '
250 | )" '"$@"'
251 |
252 | exec "$JAVACMD" "$@"
253 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------