Compare commits
8 Commits
1.21.11_fa
...
v1.1.1-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f48759061 | ||
|
|
b32f492afc | ||
|
|
6e632fd070 | ||
|
|
8172ab95cf | ||
|
|
5a132871d8 | ||
|
|
616bb03a71 | ||
|
|
a014beab37 | ||
|
|
cc25e591de |
16
README.md
16
README.md
@@ -1,9 +1,13 @@
|
||||
# Fabric Example Mod
|
||||
# Cave Dust
|
||||
|
||||
## Setup
|
||||
## What...what is "Cave 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 while being below sea level and then scales the amount of particles based on depth.
|
||||
<br><br>It has a config system that you can access using Mod Menu, most things you can change in-game, but to change the particle you'll need to open the config file manually :)
|
||||
<br>
|
||||
## Dependencies
|
||||
Cave Dust requires the [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) but everything else Cave 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
|
||||
|
||||
@@ -18,9 +18,6 @@ repositories {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.shedaniel.me/"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.terraformersmc.com"
|
||||
}
|
||||
@@ -47,14 +44,10 @@ 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}")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.18.1
|
||||
yarn_mappings=1.18.1+build.22
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=1.18.2+build.1
|
||||
loader_version=0.13.3
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.1
|
||||
mod_version = 1.1.0
|
||||
maven_group = com.lizistired
|
||||
archives_base_name = dust
|
||||
archives_base_name = cave_dust
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.46.4+1.18
|
||||
fabric_version=0.47.8+1.18.2
|
||||
clothconfig_version = 6.1.48
|
||||
modmenu_version = 3.0.1
|
||||
minelp_version=4.4.0-beta.2
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
68
src/main/java/net/lizistired/cavedust/CaveDust.java
Normal file
68
src/main/java/net/lizistired/cavedust/CaveDust.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
//minecraft imports
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.world.World;
|
||||
//other imports
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
//java imports
|
||||
import java.nio.file.Path;
|
||||
//static imports
|
||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||
|
||||
|
||||
public class CaveDust implements ClientModInitializer {
|
||||
//logger
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("caveDust");
|
||||
//make class static
|
||||
private static CaveDust instance;
|
||||
public static CaveDust getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public CaveDust() {
|
||||
instance = this;
|
||||
}
|
||||
//config assignment
|
||||
private static CaveDustConfig config;
|
||||
public CaveDustConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
//config path and loading
|
||||
Path CaveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
|
||||
config = new CaveDustConfig(CaveDustFolder.getParent().resolve("cavedust.json"), this);
|
||||
config.load();
|
||||
//register end client tick to create cave dust function, using end client tick for async
|
||||
ClientTickEvents.END_CLIENT_TICK.register(this::createCaveDust);
|
||||
}
|
||||
|
||||
private void createCaveDust(MinecraftClient client) {
|
||||
|
||||
if (client.world == null) return;
|
||||
World world = client.world;
|
||||
|
||||
if (shouldParticlesSpawn(client, config)) {
|
||||
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||
|
||||
for (int i = 0; i < probabilityNormalized * config.getParticleMultiplier(); i++) {
|
||||
try {
|
||||
double x = client.player.getPos().getX() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxX());
|
||||
double y = client.player.getPos().getY() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxY());
|
||||
double z = client.player.getPos().getZ() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxZ());
|
||||
|
||||
world.addParticle(config.getParticle(), x, y, z, 0, 0, 0);}
|
||||
|
||||
catch (NullPointerException e) {
|
||||
LOGGER.error(String.valueOf(e));
|
||||
getConfig().setParticle("minecraft:white_ash");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
205
src/main/java/net/lizistired/cavedust/CaveDustConfig.java
Normal file
205
src/main/java/net/lizistired/cavedust/CaveDustConfig.java
Normal file
@@ -0,0 +1,205 @@
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
import net.lizistired.cavedust.utils.JsonFile;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import static net.lizistired.cavedust.CaveDust.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class CaveDustConfig extends JsonFile {
|
||||
private transient final CaveDust CaveDust;
|
||||
|
||||
|
||||
private int dimensionMaxX = 5;
|
||||
private int dimensionMaxY = 5;
|
||||
private int dimensionMaxZ = 5;
|
||||
private int dimensionMinX = -5;
|
||||
private int dimensionMinY = -5;
|
||||
private int dimensionMinZ = -5;
|
||||
|
||||
private boolean caveDustEnabled = true;
|
||||
private String particleName = "white_ash";
|
||||
private boolean seaLevelCheck = true;
|
||||
private float upperLimit = 64;
|
||||
private float lowerLimit = -64;
|
||||
private float particleMultiplier = 1;
|
||||
|
||||
public CaveDustConfig(Path file, CaveDust caveDust) {
|
||||
super(file);
|
||||
this.CaveDust = caveDust;
|
||||
}
|
||||
|
||||
public float setDimensionsMinX(float size){
|
||||
if (this.dimensionMinX != size) {
|
||||
this.dimensionMinX = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMinX();
|
||||
}
|
||||
|
||||
public float setDimensionsMinY(float size){
|
||||
if (this.dimensionMinY != size) {
|
||||
this.dimensionMinY = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMinY();
|
||||
}
|
||||
|
||||
public float setDimensionsMinZ(float size){
|
||||
if (this.dimensionMinZ != size) {
|
||||
this.dimensionMinZ = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMinZ();
|
||||
}
|
||||
|
||||
public float getDimensionsMinX(){
|
||||
return dimensionMinX;
|
||||
}
|
||||
|
||||
public float getDimensionsMinY(){
|
||||
return dimensionMinY;
|
||||
}
|
||||
|
||||
public float getDimensionsMinZ(){
|
||||
return dimensionMinZ;
|
||||
}
|
||||
|
||||
public float setDimensionsMaxX(float size){
|
||||
if (this.dimensionMaxX != size) {
|
||||
this.dimensionMaxX = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMaxX();
|
||||
}
|
||||
|
||||
public float setDimensionsMaxY(float size){
|
||||
if (this.dimensionMaxY != size) {
|
||||
this.dimensionMaxY = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMaxY();
|
||||
}
|
||||
|
||||
public float setDimensionsMaxZ(float size){
|
||||
if (this.dimensionMaxZ != size) {
|
||||
this.dimensionMaxZ = (int)size;
|
||||
save();
|
||||
}
|
||||
return getDimensionsMaxZ();
|
||||
}
|
||||
|
||||
public float getDimensionsMaxX(){
|
||||
return dimensionMaxX;
|
||||
}
|
||||
|
||||
public float getDimensionsMaxY(){
|
||||
return dimensionMaxY;
|
||||
}
|
||||
|
||||
public float getDimensionsMaxZ(){
|
||||
return dimensionMaxZ;
|
||||
}
|
||||
|
||||
public float setUpperLimit(float upperLimit){
|
||||
if (this.upperLimit - 1 < getLowerLimit())
|
||||
{
|
||||
return getUpperLimit();
|
||||
}
|
||||
if (this.upperLimit != upperLimit) {
|
||||
this.upperLimit = (int)upperLimit;
|
||||
save();
|
||||
}
|
||||
return getUpperLimit();
|
||||
}
|
||||
|
||||
public float getUpperLimit(){
|
||||
return upperLimit;
|
||||
}
|
||||
|
||||
public float setLowerLimit(float lowerLimit){
|
||||
if (this.lowerLimit + 1 > getUpperLimit())
|
||||
{
|
||||
return getLowerLimit();
|
||||
}
|
||||
if (this.lowerLimit != lowerLimit) {
|
||||
this.lowerLimit = (int)lowerLimit;
|
||||
save();
|
||||
}
|
||||
return getLowerLimit();
|
||||
}
|
||||
|
||||
public float getLowerLimit(){
|
||||
return lowerLimit;
|
||||
}
|
||||
|
||||
public float getParticleMultiplier(){
|
||||
return particleMultiplier;
|
||||
}
|
||||
|
||||
public float setParticleMultiplier(float particleMultiplier){
|
||||
this.particleMultiplier = particleMultiplier;
|
||||
save();
|
||||
return getParticleMultiplier();
|
||||
}
|
||||
|
||||
public boolean toggleCaveDust(){
|
||||
caveDustEnabled = !caveDustEnabled;
|
||||
save();
|
||||
return caveDustEnabled;
|
||||
}
|
||||
|
||||
public boolean getCaveDustEnabled(){
|
||||
return caveDustEnabled;
|
||||
}
|
||||
|
||||
public ParticleEffect setParticle(String particleType){
|
||||
particleName = particleType;
|
||||
save();
|
||||
return getParticle();
|
||||
}
|
||||
|
||||
public ParticleEffect getParticle(){
|
||||
try {
|
||||
return (ParticleEffect) Registry.PARTICLE_TYPE.get(Identifier.tryParse(particleName.toLowerCase()));
|
||||
} catch (ClassCastException e) {
|
||||
LOGGER.error(e + "\nThere was an error loading the specified particle from the config, make sure a valid particle name is specified. Falling back to \"minecraft:white_ash\".");
|
||||
particleName = "minecraft:white_ash";
|
||||
save();
|
||||
return ParticleTypes.WHITE_ASH;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSeaLevelCheck() {
|
||||
return seaLevelCheck;
|
||||
}
|
||||
|
||||
public boolean setSeaLevelCheck() {
|
||||
seaLevelCheck = !seaLevelCheck;
|
||||
save();
|
||||
return getSeaLevelCheck();
|
||||
}
|
||||
|
||||
public void resetConfig(){
|
||||
dimensionMinX = -5;
|
||||
dimensionMinY = -5;
|
||||
dimensionMinZ = -5;
|
||||
|
||||
dimensionMaxX = 5;
|
||||
dimensionMaxY = 5;
|
||||
dimensionMaxZ = 5;
|
||||
|
||||
upperLimit = 64;
|
||||
lowerLimit = -64;
|
||||
|
||||
particleMultiplier = 1;
|
||||
|
||||
seaLevelCheck = true;
|
||||
caveDustEnabled = true;
|
||||
particleName = "minecraft:white_ash";
|
||||
save();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.fabricmc.example;
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
public class DustModMenuFactory implements ModMenuApi {
|
||||
public class CaveDustModMenuFactory implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return ModMenuScreen::new;
|
||||
return net.lizistired.cavedust.ModMenuScreen::new;
|
||||
}
|
||||
}
|
||||
97
src/main/java/net/lizistired/cavedust/ModMenuScreen.java
Normal file
97
src/main/java/net/lizistired/cavedust/ModMenuScreen.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
import com.minelittlepony.common.client.gui.GameGui;
|
||||
import com.minelittlepony.common.client.gui.element.*;
|
||||
import net.lizistired.cavedust.utils.TranslatableTextHelper;
|
||||
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.cavedust.title"), parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
int left = width / 2 - 100;
|
||||
int row = height / 4 + 14;
|
||||
|
||||
CaveDustConfig config = CaveDust.getInstance().getConfig();
|
||||
TranslatableTextHelper transText = new TranslatableTextHelper();
|
||||
config.load();
|
||||
|
||||
addButton(new Label(width / 2, 30)).setCentered().getStyle()
|
||||
.setText(getTitle());
|
||||
|
||||
addButton(new Button(left, row += -60).onClick(sender -> {
|
||||
sender.getStyle().setText("menu.cavedust.global." + config.toggleCaveDust()).setTooltip(new TranslatableText("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
||||
})).getStyle()
|
||||
.setText("menu.cavedust.global." + config.getCaveDustEnabled())
|
||||
.setTooltip(new TranslatableText("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
||||
|
||||
addButton(new Slider(left += -110, row += 24, -50, 0, config.getDimensionsMinX()))
|
||||
.onChange(config::setDimensionsMinX)
|
||||
.setTextFormat(transText::formatMinX)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.minX.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, -50, 0, config.getDimensionsMinY()))
|
||||
.onChange(config::setDimensionsMinY)
|
||||
.setTextFormat(transText::formatMinY)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.minY.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, -50, 0, config.getDimensionsMinZ()))
|
||||
.onChange(config::setDimensionsMinZ)
|
||||
.setTextFormat(transText::formatMinZ)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.minZ.tooltip"));
|
||||
|
||||
addButton(new Slider(left += 220, row += -48, 0, 50, config.getDimensionsMaxX()))
|
||||
.onChange(config::setDimensionsMaxX)
|
||||
.setTextFormat(transText::formatMaxX)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.maxX.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, 0, 50, config.getDimensionsMaxY()))
|
||||
.onChange(config::setDimensionsMaxY)
|
||||
.setTextFormat(transText::formatMaxY)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.maxY.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, 0, 50, config.getDimensionsMaxZ()))
|
||||
.onChange(config::setDimensionsMaxZ)
|
||||
.setTextFormat(transText::formatMaxZ)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.maxZ.tooltip"));
|
||||
|
||||
addButton(new Slider(left += -110, row += 24, -64, 319, config.getUpperLimit()))
|
||||
.onChange(config::setUpperLimit)
|
||||
.setTextFormat(transText::formatUpperLimit)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.upperlimit.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, -64, 319, config.getLowerLimit()))
|
||||
.onChange(config::setLowerLimit)
|
||||
.setTextFormat(transText::formatLowerLimit)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.lowerlimit.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, 0, 10, config.getParticleMultiplier()))
|
||||
.onChange(config::setParticleMultiplier)
|
||||
.setTextFormat(transText::formatParticleMultiplier)
|
||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.particlemultiplier.tooltip"));
|
||||
|
||||
|
||||
addButton(new Button(left, row += 24).onClick(sender -> {
|
||||
config.resetConfig();
|
||||
finish();
|
||||
})).getStyle().setText(new TranslatableText("menu.cavedust.reset")).setTooltip(new TranslatableText("menu.cavedust.reset.tooltip"));
|
||||
|
||||
addButton(new Button(left, row += 180)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.lizistired.cavedust.mixin;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.lang.management.BufferPoolMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||
|
||||
@Mixin(DebugHud.class)
|
||||
public abstract class MixinDebugScreenOverlay {
|
||||
@Unique
|
||||
private static final List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
|
||||
|
||||
@Unique
|
||||
private static final BufferPoolMXBean directPool;
|
||||
|
||||
static {
|
||||
BufferPoolMXBean found = null;
|
||||
|
||||
for (BufferPoolMXBean pool : pools) {
|
||||
if (pool.getName().equals("direct")) {
|
||||
found = pool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
directPool = Objects.requireNonNull(found);
|
||||
}
|
||||
@Inject(method = "getRightText", at = @At("RETURN"))
|
||||
private void appendShaderPackText(CallbackInfoReturnable<List<String>> cir) {
|
||||
List<String> messages = cir.getReturnValue();
|
||||
|
||||
messages.add("");
|
||||
messages.add("Should particles spawn: " + shouldParticlesSpawn);
|
||||
messages.add("");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.fabricmc.example.utils;
|
||||
package net.lizistired.cavedust.utils;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
@@ -9,7 +9,7 @@ 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;
|
||||
import net.lizistired.cavedust.CaveDust;
|
||||
|
||||
public class JsonFile {
|
||||
protected transient final Gson gson = new GsonBuilder()
|
||||
@@ -30,7 +30,7 @@ public class JsonFile {
|
||||
try (Reader reader = Files.newBufferedReader(file)) {
|
||||
load(reader);
|
||||
} catch (Exception e) {
|
||||
Dust.LOGGER.error("Invalid config", e);
|
||||
CaveDust.LOGGER.error("Invalid config", e);
|
||||
}
|
||||
}
|
||||
|
||||
74
src/main/java/net/lizistired/cavedust/utils/MathHelper.java
Normal file
74
src/main/java/net/lizistired/cavedust/utils/MathHelper.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package net.lizistired.cavedust.utils;
|
||||
|
||||
import net.lizistired.cavedust.CaveDustConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.DimensionEffects;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.OverworldBiomeCreator;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.feature.OceanRuinFeature;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES;
|
||||
|
||||
public class MathHelper {
|
||||
private static float timer;
|
||||
public static boolean shouldParticlesSpawn;
|
||||
|
||||
public static double normalize(double min, double max, double val) {
|
||||
return 1 - ((val - min) / (max - min));
|
||||
}
|
||||
|
||||
public static int getRandomNumberUsingInts(int min, int max) {
|
||||
Random random = new Random();
|
||||
|
||||
return random.ints(min, max)
|
||||
.findFirst()
|
||||
.getAsInt();
|
||||
}
|
||||
|
||||
|
||||
public static double generateRandomDouble(double min, double max) {
|
||||
return ThreadLocalRandom.current().nextDouble(min, max);
|
||||
}
|
||||
|
||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
||||
|
||||
//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
|
||||
if (!config.getCaveDustEnabled()
|
||||
|| client.isPaused()
|
||||
|| client.world == null
|
||||
|| !client.world.getDimension().isBedWorking()
|
||||
|| Objects.requireNonNull(client.player).isSubmergedInWater()
|
||||
|| client.world.getBiome(Objects.requireNonNull(client.player).getBlockPos()).matchesKey(LUSH_CAVES))
|
||||
{
|
||||
timer = 0;
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = client.world;
|
||||
int seaLevel = world.getSeaLevel();
|
||||
|
||||
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
||||
if (client.player.getBlockPos().getY() < seaLevel){
|
||||
timer = timer + 1;
|
||||
if (timer > 10){
|
||||
timer = 10;
|
||||
shouldParticlesSpawn = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.lizistired.cavedust.utils;
|
||||
|
||||
import com.minelittlepony.common.client.gui.element.AbstractSlider;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public class TranslatableTextHelper {
|
||||
public Text formatMinX(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.minX", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMinY(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.minY", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMinZ(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.minZ", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMaxX(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.maxX", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMaxY(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.maxY", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMaxZ(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.maxZ", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatUpperLimit(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.upperlimit", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatLowerLimit(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.lowerlimit", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatParticleMultiplier(AbstractSlider<Float> slider) {
|
||||
return new TranslatableText("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.lizistired.caveDust.utils;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
public class WindowFocusHelper {
|
||||
private static boolean unpaused;
|
||||
public boolean unpausedMenu(MinecraftClient client){
|
||||
return unpaused;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,27 @@
|
||||
{
|
||||
"menu.dust.title": "Dust",
|
||||
"menu.dust.global.false": "Dust: disabled",
|
||||
"menu.dust.global.true": "Dust: enabled"
|
||||
"menu.cavedust.title": "Cave Dust",
|
||||
"menu.cavedust.global.false": "Cave Dust: Disabled",
|
||||
"menu.cavedust.global.true": "Cave Dust: Enabled",
|
||||
"menu.cavedust.global.tooltip.false": "Enable cave dust particles?",
|
||||
"menu.cavedust.global.tooltip.true": "Disable cave dust particles?",
|
||||
"menu.cavedust.minX": "Minimum X: %s",
|
||||
"menu.cavedust.minY": "Minimum Y: %s",
|
||||
"menu.cavedust.minZ": "Minimum Z: %s",
|
||||
"menu.cavedust.maxX": "Maximum X: %s",
|
||||
"menu.cavedust.maxY": "Maximum Y: %s",
|
||||
"menu.cavedust.maxZ": "Maximum Z: %s",
|
||||
"menu.cavedust.minX.tooltip": "Minimum X: %s",
|
||||
"menu.cavedust.minY.tooltip": "Minimum Y: %s",
|
||||
"menu.cavedust.minZ.tooltip": "Minimum Z: %s",
|
||||
"menu.cavedust.maxX.tooltip": "Maximum X: %s",
|
||||
"menu.cavedust.maxY.tooltip": "Maximum Y: %s",
|
||||
"menu.cavedust.maxZ.tooltip": "Maximum Z: %s",
|
||||
"menu.cavedust.upperlimit": "Upper limit: %s",
|
||||
"menu.cavedust.lowerlimit": "Lower limit: %s",
|
||||
"menu.cavedust.upperlimit.tooltip": "The height where particles will fade out and stop spawning (uses player y).",
|
||||
"menu.cavedust.lowerlimit.tooltip": "The height where particles spawn the most (uses player y).",
|
||||
"menu.cavedust.reset": "Reset settings",
|
||||
"menu.cavedust.reset.tooltip": "Are you sure you want to reset all settings?",
|
||||
"menu.cavedust.particlemultiplier": "Particle multiplier: %s",
|
||||
"menu.cavedust.particlemultiplier.tooltip": "Multiplies the amount of particles at any given depth."
|
||||
}
|
||||
15
src/main/resources/dust.mixins.json
Normal file
15
src/main/resources/dust.mixins.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.lizistired.cavedust.mixin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "modid",
|
||||
"id": "cavedust",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Dust",
|
||||
"name": "Cave Dust",
|
||||
"description": "Makes dust underground that scales with depth!",
|
||||
"authors": [
|
||||
"LizIsTired"
|
||||
@@ -12,20 +11,20 @@
|
||||
"issues": "https://github.com/LizIsTired/dust/issues",
|
||||
"sources": "https://github.com/LizIsTired/dust"
|
||||
},
|
||||
|
||||
"license": "CC0-1.0",
|
||||
"icon": "assets/modid/icon.png",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"net.fabricmc.example.Dust"
|
||||
"net.lizistired.cavedust.CaveDust"
|
||||
],
|
||||
"modmenu": [
|
||||
"net.fabricmc.example.DustModMenuFactory"
|
||||
"net.lizistired.cavedust.CaveDustModMenuFactory"
|
||||
]
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
"dust.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.11",
|
||||
"fabric": "*",
|
||||
@@ -33,7 +32,6 @@
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
"clothconfig": ">=6.1.48",
|
||||
"modmenu": ">=3.0.1"
|
||||
},
|
||||
"custom": {
|
||||
|
||||
Reference in New Issue
Block a user