Fix bugs and fix #4
Particles can no longer spawn under the world. Particles no longer spawn in blocks, instead spawning in air. Fixed bug present since 1.2.0, which meant particle amount was dependant on blocks around player. New particle multiplier allowing greater control of particle amount. New F3 screen text, allows user to debug particle amount. Removed upper and lower limit buttons.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package net.lizistired.cavedust;
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
//minecraft imports
|
//minecraft imports
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
@@ -40,6 +41,7 @@ public class CaveDust implements ClientModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int WHITE_ASH_ID = Registries.PARTICLE_TYPE.getRawId(ParticleTypes.WHITE_ASH);
|
public static int WHITE_ASH_ID = Registries.PARTICLE_TYPE.getRawId(ParticleTypes.WHITE_ASH);
|
||||||
|
public static int PARTICLE_AMOUNT = 0;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,19 +74,21 @@ public class CaveDust implements ClientModInitializer {
|
|||||||
//LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
|
//LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
|
||||||
// )
|
// )
|
||||||
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||||
|
PARTICLE_AMOUNT = (int) (probabilityNormalized * config.getParticleMultiplier() * config.getParticleMultiplierMultiplier());
|
||||||
|
|
||||||
for (int i = 0; i < probabilityNormalized * config.getParticleMultiplier() * 10; i++) {
|
for (int i = 0; i < PARTICLE_AMOUNT; i++) {
|
||||||
try {
|
try {
|
||||||
double x = client.player.getPos().getX() + generateRandomDouble(config.getDimensionsX() * -1, config.getDimensionsX());
|
double x = client.player.getPos().getX() + generateRandomDouble(config.getDimensionsX() * -1, config.getDimensionsX());
|
||||||
double y = client.player.getPos().getY() + generateRandomDouble(config.getDimensionsY() * -1, config.getDimensionsY());
|
double y = client.player.getPos().getY() + generateRandomDouble(config.getDimensionsY() * -1, config.getDimensionsY());
|
||||||
double z = client.player.getPos().getZ() + generateRandomDouble(config.getDimensionsZ() * -1, config.getDimensionsZ());
|
double z = client.player.getPos().getZ() + generateRandomDouble(config.getDimensionsZ() * -1, config.getDimensionsZ());
|
||||||
BlockPos particlePos = new BlockPos(x, y, z);
|
BlockPos particlePos = new BlockPos(x, y, z);
|
||||||
|
|
||||||
if (!shouldParticlesSpawn(client, config, particlePos)){return;}
|
if (shouldParticlesSpawn(client, config, particlePos)) {
|
||||||
|
if (client.world.getBlockState(particlePos).isAir()) {
|
||||||
|
|
||||||
world.addParticle(config.getParticle(), x, y, z, config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom());
|
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().setParticleID(WHITE_ASH_ID);
|
getConfig().setParticleID(WHITE_ASH_ID);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
private float lowerLimit = -64;
|
private float lowerLimit = -64;
|
||||||
private int particleMultiplier = 1;
|
private int particleMultiplier = 1;
|
||||||
|
|
||||||
|
private int particleMultiplierMultiplier = 10;
|
||||||
|
|
||||||
private int particleID = WHITE_ASH_ID;
|
private int particleID = WHITE_ASH_ID;
|
||||||
|
|
||||||
public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
|
public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
|
||||||
@@ -111,6 +113,16 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
return getParticleMultiplier();
|
return getParticleMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getParticleMultiplierMultiplier(){
|
||||||
|
return particleMultiplierMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float setParticleMultiplierMultiplier(float particleMultiplierMultiplier){
|
||||||
|
this.particleMultiplierMultiplier = (int) particleMultiplierMultiplier;
|
||||||
|
save();
|
||||||
|
return getParticleMultiplierMultiplier();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean toggleCaveDust(){
|
public boolean toggleCaveDust(){
|
||||||
caveDustEnabled = !caveDustEnabled;
|
caveDustEnabled = !caveDustEnabled;
|
||||||
save();
|
save();
|
||||||
@@ -197,6 +209,7 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
lowerLimit = -64;
|
lowerLimit = -64;
|
||||||
|
|
||||||
particleMultiplier = 1;
|
particleMultiplier = 1;
|
||||||
|
particleMultiplierMultiplier = 10;
|
||||||
|
|
||||||
seaLevelCheck = true;
|
seaLevelCheck = true;
|
||||||
caveDustEnabled = true;
|
caveDustEnabled = true;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.lizistired.cavedust.CaveDust.PARTICLE_AMOUNT;
|
||||||
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
||||||
|
|
||||||
@Mixin(DebugHud.class)
|
@Mixin(DebugHud.class)
|
||||||
@@ -16,7 +18,7 @@ public abstract class MixinDebugScreenOverlay {
|
|||||||
List<String> messages = cir.getReturnValue();
|
List<String> messages = cir.getReturnValue();
|
||||||
|
|
||||||
messages.add("");
|
messages.add("");
|
||||||
messages.add("Should particles spawn: " + shouldParticlesSpawn);
|
messages.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
|
||||||
messages.add("");
|
messages.add("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class ParticleSpawnUtil {
|
|||||||
|| client.isPaused()
|
|| client.isPaused()
|
||||||
|| client.world == null
|
|| client.world == null
|
||||||
|| !client.world.getDimension().bedWorks()
|
|| !client.world.getDimension().bedWorks()
|
||||||
|| Objects.requireNonNull(client.player).isSubmergedInWater()
|
|| (client.world.getBottomY() > pos.getY())
|
||||||
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
|
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public class TranslatableTextHelper {
|
|||||||
public Text formatParticleMultiplier(AbstractSlider<Float> slider) {
|
public Text formatParticleMultiplier(AbstractSlider<Float> slider) {
|
||||||
return Text.translatable("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
|
return Text.translatable("menu.cavedust.particlemultiplier", (int)Math.floor(slider.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Text formatParticleMultiplierMultiplier(AbstractSlider<Float> slider) {
|
||||||
|
return Text.translatable("menu.cavedust.particlemultipliermultiplier", (int)Math.floor(slider.getValue()));
|
||||||
|
}
|
||||||
public Text formatVelocityRandomness(AbstractSlider<Float> slider) {
|
public Text formatVelocityRandomness(AbstractSlider<Float> slider) {
|
||||||
return Text.translatable("menu.cavedust.velocityrandomness", (int) Math.floor(slider.getValue()));
|
return Text.translatable("menu.cavedust.velocityrandomness", (int) Math.floor(slider.getValue()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
"menu.cavedust.lowerlimit.tooltip": "The height where particles spawn the most (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": "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 amount: %s",
|
||||||
"menu.cavedust.particlemultiplier.tooltip": "Multiplies the amount of particles at any given depth.",
|
"menu.cavedust.particlemultiplier.tooltip": "Amount of particles to spawn at any given depth.",
|
||||||
|
"menu.cavedust.particlemultipliermultiplier": "Particle multiplier: %s",
|
||||||
|
"menu.cavedust.particlemultipliermultiplier.tooltip": "Multiplies particle amount.",
|
||||||
"menu.cavedust.velocityrandomness": "Velocity randomness: %s",
|
"menu.cavedust.velocityrandomness": "Velocity randomness: %s",
|
||||||
"menu.cavedust.velocityrandomness.tooltip": "The randomness of the velocity of the particles.",
|
"menu.cavedust.velocityrandomness.tooltip": "The randomness of the velocity of the particles.",
|
||||||
"menu.cavedust.enhanceddetection.true": "Enhanced detection: Enabled",
|
"menu.cavedust.enhanceddetection.true": "Enhanced detection: Enabled",
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
"package": "net.lizistired.cavedust.mixin",
|
"package": "net.lizistired.cavedust.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ClientWorldAccessor"
|
"ClientWorldAccessor",
|
||||||
|
"MixinDebugScreenOverlay"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user