A whole load of shit
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
package net.lizistired.cavedust;
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
//minecraft imports
|
//minecraft imports
|
||||||
|
import net.lizistired.cavedust.mixin.ClientWorldAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
//other imports
|
//other imports
|
||||||
import com.minelittlepony.common.util.GamePaths;
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
@@ -13,6 +18,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
//static imports
|
//static imports
|
||||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||||
|
import static net.lizistired.cavedust.utils.MathHelper.generateRandomDouble;
|
||||||
|
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
||||||
|
import static net.lizistired.cavedust.utils.KeybindingHelper.*;
|
||||||
|
|
||||||
|
|
||||||
public class CaveDust implements ClientModInitializer {
|
public class CaveDust implements ClientModInitializer {
|
||||||
@@ -32,32 +40,50 @@ public class CaveDust implements ClientModInitializer {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
//config path and loading
|
//config path and loading
|
||||||
Path CaveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
|
Path CaveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
|
||||||
config = new CaveDustConfig(CaveDustFolder.getParent().resolve("cavedust.json"), this);
|
config = new CaveDustConfig(CaveDustFolder.getParent().resolve("cavedust.json"), this);
|
||||||
config.load();
|
config.load();
|
||||||
|
registerKeyBindings();
|
||||||
|
|
||||||
//register end client tick to create cave dust function, using end client tick for async
|
//register end client tick to create cave dust function, using end client tick for async
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(this::createCaveDust);
|
ClientTickEvents.END_CLIENT_TICK.register(this::createCaveDust);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCaveDust(MinecraftClient client) {
|
private void createCaveDust(MinecraftClient client) {
|
||||||
|
if (keyBinding1.wasPressed()){
|
||||||
|
getConfig().toggleCaveDust();
|
||||||
|
LOGGER.info("Toggled dust");
|
||||||
|
client.player.sendSystemMessage(new TranslatableText("debug.cavedust.toggle." + config.getCaveDustEnabled()), Util.NIL_UUID);
|
||||||
|
}
|
||||||
|
if (keyBinding2.wasPressed()){
|
||||||
|
getConfig().load();
|
||||||
|
LOGGER.info("Reloaded config");
|
||||||
|
client.player.sendSystemMessage(new TranslatableText("debug.cavedust.reload"), Util.NIL_UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
//ensure world is not null
|
||||||
if (client.world == null) return;
|
if (client.world == null) return;
|
||||||
World world = client.world;
|
World world = client.world;
|
||||||
|
//LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
|
||||||
if (shouldParticlesSpawn(client, config)) {
|
// )
|
||||||
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||||
|
|
||||||
for (int i = 0; i < probabilityNormalized * config.getParticleMultiplier(); i++) {
|
for (int i = 0; i < probabilityNormalized * config.getParticleMultiplier() * 10; i++) {
|
||||||
try {
|
try {
|
||||||
double x = client.player.getPos().getX() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxX());
|
double x = client.player.getPos().getX() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxX());
|
||||||
double y = client.player.getPos().getY() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxY());
|
double y = client.player.getPos().getY() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxY());
|
||||||
double z = client.player.getPos().getZ() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxZ());
|
double z = client.player.getPos().getZ() + generateRandomDouble(config.getDimensionsMinX(), config.getDimensionsMaxZ());
|
||||||
|
BlockPos particlePos = new BlockPos(x, y, z);
|
||||||
|
|
||||||
world.addParticle(config.getParticle(), x, y, z, 0, 0, 0);}
|
if (!shouldParticlesSpawn(client, config, particlePos)){return;}
|
||||||
|
|
||||||
|
|
||||||
|
world.addParticle(config.getParticle(), x, y, z, config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom());
|
||||||
|
}
|
||||||
catch (NullPointerException e) {
|
catch (NullPointerException e) {
|
||||||
LOGGER.error(String.valueOf(e));
|
LOGGER.error(String.valueOf(e));
|
||||||
getConfig().setParticle("minecraft:white_ash");
|
getConfig().setParticle("minecraft:white_ash");
|
||||||
@@ -65,4 +91,3 @@ public class CaveDust implements ClientModInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.minecraft.particle.ParticleTypes;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import static net.lizistired.cavedust.CaveDust.*;
|
import static net.lizistired.cavedust.CaveDust.*;
|
||||||
|
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
@@ -19,13 +20,16 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
private int dimensionMinX = -5;
|
private int dimensionMinX = -5;
|
||||||
private int dimensionMinY = -5;
|
private int dimensionMinY = -5;
|
||||||
private int dimensionMinZ = -5;
|
private int dimensionMinZ = -5;
|
||||||
|
private int velocityRandomness = 1;
|
||||||
|
|
||||||
private boolean caveDustEnabled = true;
|
private boolean caveDustEnabled = true;
|
||||||
private String particleName = "white_ash";
|
private String particleName = "white_ash";
|
||||||
private boolean seaLevelCheck = true;
|
private boolean seaLevelCheck = true;
|
||||||
|
private boolean superFlatStatus = false;
|
||||||
|
//private boolean enhancedDetection = true;
|
||||||
private float upperLimit = 64;
|
private float upperLimit = 64;
|
||||||
private float lowerLimit = -64;
|
private float lowerLimit = -64;
|
||||||
private float particleMultiplier = 1;
|
private int particleMultiplier = 1;
|
||||||
|
|
||||||
public CaveDustConfig(Path file, CaveDust caveDust) {
|
public CaveDustConfig(Path file, CaveDust caveDust) {
|
||||||
super(file);
|
super(file);
|
||||||
@@ -136,12 +140,12 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
return lowerLimit;
|
return lowerLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getParticleMultiplier(){
|
public int getParticleMultiplier(){
|
||||||
return particleMultiplier;
|
return particleMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float setParticleMultiplier(float particleMultiplier){
|
public float setParticleMultiplier(float particleMultiplier){
|
||||||
this.particleMultiplier = particleMultiplier;
|
this.particleMultiplier = (int) particleMultiplier;
|
||||||
save();
|
save();
|
||||||
return getParticleMultiplier();
|
return getParticleMultiplier();
|
||||||
}
|
}
|
||||||
@@ -183,6 +187,41 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
return getSeaLevelCheck();
|
return getSeaLevelCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getVelocityRandomnessRandom(){
|
||||||
|
if (velocityRandomness == 0) {return 0;}
|
||||||
|
return (float) generateRandomDouble(-velocityRandomness, velocityRandomness);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVelocityRandomness(){
|
||||||
|
return velocityRandomness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float setVelocityRandomness(float velocityRandomness){
|
||||||
|
this.velocityRandomness = (int) velocityRandomness;
|
||||||
|
save();
|
||||||
|
return getVelocityRandomness();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSuperFlatStatus(){
|
||||||
|
return superFlatStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setSuperFlatStatus(){
|
||||||
|
superFlatStatus = !superFlatStatus;
|
||||||
|
save();
|
||||||
|
return getSuperFlatStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public boolean getEnhancedDetection(){
|
||||||
|
return enhancedDetection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setEnhancedDetection(){
|
||||||
|
enhancedDetection = !enhancedDetection;
|
||||||
|
save();
|
||||||
|
return getEnhancedDetection();
|
||||||
|
}*/
|
||||||
|
|
||||||
public void resetConfig(){
|
public void resetConfig(){
|
||||||
dimensionMinX = -5;
|
dimensionMinX = -5;
|
||||||
dimensionMinY = -5;
|
dimensionMinY = -5;
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ import com.terraformersmc.modmenu.api.ModMenuApi;
|
|||||||
public class CaveDustModMenuFactory implements ModMenuApi {
|
public class CaveDustModMenuFactory implements ModMenuApi {
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return net.lizistired.cavedust.ModMenuScreen::new;
|
return ModMenuConfigScreen::new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import net.minecraft.text.TranslatableText;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ModMenuScreen extends GameGui {
|
public class ModMenuConfigScreen extends GameGui {
|
||||||
public ModMenuScreen(@Nullable Screen parent) {
|
public ModMenuConfigScreen(@Nullable Screen parent) {
|
||||||
super(new TranslatableText("menu.cavedust.title"), parent);
|
super(new TranslatableText("menu.cavedust.title"), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +32,18 @@ public class ModMenuScreen extends GameGui {
|
|||||||
.setText("menu.cavedust.global." + config.getCaveDustEnabled())
|
.setText("menu.cavedust.global." + config.getCaveDustEnabled())
|
||||||
.setTooltip(new TranslatableText("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
.setTooltip(new TranslatableText("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
||||||
|
|
||||||
|
/*addButton(new Button(left, row += 24).onClick(sender -> {
|
||||||
|
sender.getStyle().setText("menu.cavedust.enhanceddetection." + config.setEnhancedDetection()).setTooltip(new TranslatableText("menu.cavedust.enhanceddetection.tooltip"));
|
||||||
|
})).getStyle()
|
||||||
|
.setText("menu.cavedust.enhanceddetection." + config.getEnhancedDetection())
|
||||||
|
.setTooltip(new TranslatableText("menu.cavedust.enhanceddetection.tooltip"));*/
|
||||||
|
|
||||||
|
addButton(new Button(left, row += 24).onClick(sender -> {
|
||||||
|
sender.getStyle().setText("menu.cavedust.superflatstatus." + config.setSuperFlatStatus()).setTooltip(new TranslatableText("menu.cavedust.superflatstatus.tooltip"));
|
||||||
|
})).getStyle()
|
||||||
|
.setText("menu.cavedust.superflatstatus." + config.getSuperFlatStatus())
|
||||||
|
.setTooltip(new TranslatableText("menu.cavedust.superflatstatus.tooltip"));
|
||||||
|
|
||||||
addButton(new Slider(left += -110, row += 24, -50, 0, config.getDimensionsMinX()))
|
addButton(new Slider(left += -110, row += 24, -50, 0, config.getDimensionsMinX()))
|
||||||
.onChange(config::setDimensionsMinX)
|
.onChange(config::setDimensionsMinX)
|
||||||
.setTextFormat(transText::formatMinX)
|
.setTextFormat(transText::formatMinX)
|
||||||
@@ -72,18 +84,23 @@ public class ModMenuScreen extends GameGui {
|
|||||||
.setTextFormat(transText::formatLowerLimit)
|
.setTextFormat(transText::formatLowerLimit)
|
||||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.lowerlimit.tooltip"));
|
.getStyle().setTooltip(new TranslatableText("menu.cavedust.lowerlimit.tooltip"));
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, 0, 10, config.getParticleMultiplier()))
|
addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplier()))
|
||||||
.onChange(config::setParticleMultiplier)
|
.onChange(config::setParticleMultiplier)
|
||||||
.setTextFormat(transText::formatParticleMultiplier)
|
.setTextFormat(transText::formatParticleMultiplier)
|
||||||
.getStyle().setTooltip(new TranslatableText("menu.cavedust.particlemultiplier.tooltip"));
|
.getStyle().setTooltip(new TranslatableText("menu.cavedust.particlemultiplier.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, 0, 10, config.getVelocityRandomness()))
|
||||||
|
.onChange(config::setVelocityRandomness)
|
||||||
|
.setTextFormat(transText::formatVelocityRandomness)
|
||||||
|
.getStyle().setTooltip(new TranslatableText("menu.cavedust.velocityrandomness.tooltip"));
|
||||||
|
|
||||||
|
|
||||||
addButton(new Button(left, row += 24).onClick(sender -> {
|
addButton(new Button(left, row += 24).onClick(sender -> {
|
||||||
config.resetConfig();
|
config.resetConfig();
|
||||||
finish();
|
finish();
|
||||||
})).getStyle().setText(new TranslatableText("menu.cavedust.reset")).setTooltip(new TranslatableText("menu.cavedust.reset.tooltip"));
|
})).getStyle().setText(new TranslatableText("menu.cavedust.reset")).setTooltip(new TranslatableText("menu.cavedust.reset.tooltip"));
|
||||||
|
|
||||||
addButton(new Button(left, row += 180)
|
addButton(new Button(left, row += 60)
|
||||||
.onClick(sender -> finish())).getStyle()
|
.onClick(sender -> finish())).getStyle()
|
||||||
.setText("gui.done");
|
.setText("gui.done");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.lizistired.cavedust.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(ClientWorld.Properties.class)
|
||||||
|
public interface ClientWorldAccessor {
|
||||||
|
@Accessor
|
||||||
|
boolean getFlatWorld();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package net.lizistired.cavedust.mixin;
|
package net.lizistired.cavedust.mixin;
|
||||||
|
|
||||||
|
|
||||||
|
import net.lizistired.cavedust.CaveDustConfig;
|
||||||
import net.minecraft.client.gui.hud.DebugHud;
|
import net.minecraft.client.gui.hud.DebugHud;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -13,6 +15,7 @@ import java.lang.management.ManagementFactory;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||||
|
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
||||||
|
|
||||||
@Mixin(DebugHud.class)
|
@Mixin(DebugHud.class)
|
||||||
public abstract class MixinDebugScreenOverlay {
|
public abstract class MixinDebugScreenOverlay {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.lizistired.cavedust.utils;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
|
import net.minecraft.client.option.KeyBinding;
|
||||||
|
import net.minecraft.client.option.StickyKeyBinding;
|
||||||
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
public class KeybindingHelper {
|
||||||
|
|
||||||
|
public static KeyBinding keyBinding1;
|
||||||
|
public static KeyBinding keyBinding2;
|
||||||
|
|
||||||
|
|
||||||
|
public static void registerKeyBindings(){
|
||||||
|
keyBinding1 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
|
"key.cavedust.toggle",
|
||||||
|
InputUtil.Type.KEYSYM,// The translation key of the keybinding's name // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
||||||
|
GLFW.GLFW_KEY_KP_ADD, // The keycode of the key
|
||||||
|
"category.cavedust.spook" // The translation key of the keybinding's category.
|
||||||
|
));
|
||||||
|
keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
|
"key.cavedust.reload", // The translation key of the keybinding's name
|
||||||
|
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
||||||
|
GLFW.GLFW_KEY_KP_ENTER, // The keycode of the key
|
||||||
|
"category.cavedust.spook" // The translation key of the keybinding's category.
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package net.lizistired.cavedust.utils;
|
package net.lizistired.cavedust.utils;
|
||||||
|
|
||||||
import net.lizistired.cavedust.CaveDustConfig;
|
import net.lizistired.cavedust.CaveDustConfig;
|
||||||
|
import net.lizistired.cavedust.mixin.ClientWorldAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -12,6 +14,13 @@ import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES;
|
|||||||
public class ParticleSpawnUtil {
|
public class ParticleSpawnUtil {
|
||||||
private static float timer;
|
private static float timer;
|
||||||
public static boolean shouldParticlesSpawn;
|
public static boolean shouldParticlesSpawn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if particles should spawn.
|
||||||
|
* @param client MinecraftClient
|
||||||
|
* @param config CaveDustConfig
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
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
|
//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
|
||||||
@@ -19,7 +28,8 @@ public class ParticleSpawnUtil {
|
|||||||
|| client.isPaused()
|
|| client.isPaused()
|
||||||
|| client.world == null
|
|| client.world == null
|
||||||
|| !client.world.getDimension().isBedWorking()
|
|| !client.world.getDimension().isBedWorking()
|
||||||
|| Objects.requireNonNull(client.player).isSubmergedInWater())
|
|| Objects.requireNonNull(client.player).isSubmergedInWater()
|
||||||
|
|| Objects.equals(client.world.getBiomeKey(Objects.requireNonNull(client.player.getBlockPos())), Optional.of(LUSH_CAVES)))
|
||||||
{
|
{
|
||||||
timer = 0;
|
timer = 0;
|
||||||
shouldParticlesSpawn = false;
|
shouldParticlesSpawn = false;
|
||||||
@@ -30,7 +40,51 @@ public class ParticleSpawnUtil {
|
|||||||
int seaLevel = world.getSeaLevel();
|
int seaLevel = world.getSeaLevel();
|
||||||
|
|
||||||
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
||||||
if (client.player.getBlockPos().getY() < seaLevel){
|
if (client.player.getBlockPos().getY() + 2 < seaLevel){
|
||||||
|
timer = timer + 1;
|
||||||
|
if (timer > 10){
|
||||||
|
timer = 10;
|
||||||
|
shouldParticlesSpawn = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shouldParticlesSpawn = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if particles should spawn (uses particle position instead of player).
|
||||||
|
* @param client MinecraftClient
|
||||||
|
* @param config CaveDustConfig
|
||||||
|
* @param pos BlockPos
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config, BlockPos pos) {
|
||||||
|
|
||||||
|
//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()
|
||||||
|
|| Objects.equals(client.world.getBiomeKey(Objects.requireNonNull(pos)), Optional.of(LUSH_CAVES)))
|
||||||
|
{
|
||||||
|
timer = 0;
|
||||||
|
shouldParticlesSpawn = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!config.getSuperFlatStatus()) {
|
||||||
|
if (((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = client.world;
|
||||||
|
int seaLevel = world.getSeaLevel();
|
||||||
|
|
||||||
|
if (!client.player.clientWorld.isSkyVisible(pos)) {
|
||||||
|
if (pos.getY() + 2 < seaLevel){
|
||||||
timer = timer + 1;
|
timer = timer + 1;
|
||||||
if (timer > 10){
|
if (timer > 10){
|
||||||
timer = 10;
|
timer = 10;
|
||||||
|
|||||||
@@ -32,4 +32,7 @@ public class TranslatableTextHelper {
|
|||||||
public Text formatParticleMultiplier(AbstractSlider<Float> slider) {
|
public Text formatParticleMultiplier(AbstractSlider<Float> slider) {
|
||||||
return new TranslatableText("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
|
return new TranslatableText("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
|
||||||
}
|
}
|
||||||
|
public Text formatVelocityRandomness(AbstractSlider<Float> slider) {
|
||||||
|
return new TranslatableText("menu.cavedust.velocityrandomness", (int)Math.floor(slider.getValue()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lizistired.caveDust.utils;
|
package net.lizistired.cavedust.utils;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
|||||||
@@ -23,5 +23,22 @@
|
|||||||
"menu.cavedust.reset": "Reset settings",
|
"menu.cavedust.reset": "Reset settings",
|
||||||
"menu.cavedust.reset.tooltip": "Are you sure you want to reset all settings?",
|
"menu.cavedust.reset.tooltip": "Are you sure you want to reset all settings?",
|
||||||
"menu.cavedust.particlemultiplier": "Particle multiplier: %s",
|
"menu.cavedust.particlemultiplier": "Particle multiplier: %s",
|
||||||
"menu.cavedust.particlemultiplier.tooltip": "Multiplies the amount of particles at any given depth."
|
"menu.cavedust.particlemultiplier.tooltip": "Multiplies the amount of particles at any given depth.",
|
||||||
|
"menu.cavedust.velocityrandomness": "Velocity randomness: %s",
|
||||||
|
"menu.cavedust.velocityrandomness.tooltip": "The randomness of the velocity of the particles.",
|
||||||
|
"menu.cavedust.enhanceddetection.true": "Enhanced detection: Enabled",
|
||||||
|
"menu.cavedust.enhanceddetection.false": "Enhanced detection: Disabled",
|
||||||
|
"menu.cavedust.enhanceddetection.tooltip": "Enhanced detection enables more accurate checks, using the particles position\n instead of the player, has some performance impact.",
|
||||||
|
"menu.cavedust.superflatstatus.true": "Superflat particles: Enabled",
|
||||||
|
"menu.cavedust.superflatstatus.false": "Superflat particles: Disabled",
|
||||||
|
"menu.cavedust.superflatstatus.tooltip": "Should particles spawn on superflat worlds?",
|
||||||
|
|
||||||
|
"key.cavedust.reload": "Reload Config",
|
||||||
|
"key.cavedust.toggle": "Toggle Particles",
|
||||||
|
"category.cavedust.spook": "Cave Dust",
|
||||||
|
|
||||||
|
"debug.cavedust.toggle.true": "(Cave Dust) Enabled particles",
|
||||||
|
"debug.cavedust.toggle.false": "(Cave Dust) Disabled particles",
|
||||||
|
"debug.cavedust.reload": "(Cave Dust) Reloaded config"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
"package": "net.lizistired.cavedust.mixin",
|
"package": "net.lizistired.cavedust.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"ClientWorldAccessor"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user