@@ -16,4 +16,4 @@ org.gradle.jvmargs=-Xmx1G
|
||||
fabric_version=0.107.0+1.21.3
|
||||
clothconfig_version=16.0.141
|
||||
modmenu_version=12.0.0-beta.1
|
||||
kirin_version=1.19.1+1.21
|
||||
kirin_version=1.19.3+1.21.3
|
||||
|
||||
@@ -3,9 +3,11 @@ package net.lizistired.cavedust;
|
||||
//minecraft imports
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
//other imports
|
||||
@@ -40,7 +42,7 @@ public class CaveDust implements ClientModInitializer {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static int WHITE_ASH_ID = Registries.PARTICLE_TYPE.getRawId(CaveDustServer.CAVE_DUST);
|
||||
public static ParticleEffect WHITE_ASH_ID = (ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust"));
|
||||
public static int PARTICLE_AMOUNT = 0;
|
||||
|
||||
|
||||
@@ -74,13 +76,13 @@ public class CaveDust implements ClientModInitializer {
|
||||
//ensure world is not null
|
||||
if (client.world == null) return;
|
||||
World world = client.world;
|
||||
|
||||
//LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
|
||||
// )
|
||||
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||
PARTICLE_AMOUNT = (int) (probabilityNormalized * config.getParticleMultiplier() * config.getParticleMultiplierMultiplier());
|
||||
|
||||
for (int i = 0; i < PARTICLE_AMOUNT; i++) {
|
||||
try {
|
||||
int x = (int) (client.player.getPos().getX() + (int) generateRandomDouble(config.getDimensionWidth() *-1, config.getDimensionWidth()));
|
||||
int y = (int) (client.player.getEyePos().getY() + (int) generateRandomDouble(config.getDimensionHeight() *-1, config.getDimensionHeight()));
|
||||
int z = (int) (client.player.getPos().getZ() + (int) generateRandomDouble(config.getDimensionWidth() *-1, config.getDimensionWidth()));
|
||||
@@ -91,17 +93,9 @@ public class CaveDust implements ClientModInitializer {
|
||||
|
||||
if (shouldParticlesSpawn(client, config, particlePos)) {
|
||||
if (client.world.getBlockState(particlePos).isAir()) {
|
||||
//todo
|
||||
//world.addParticle(config.getParticle(), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
|
||||
world.addParticle(CaveDustServer.CAVE_DUST, miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
|
||||
world.addParticle(getConfig().getParticle(), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
LOGGER.error(String.valueOf(e));
|
||||
//todo
|
||||
//getConfig().setParticleID(WHITE_ASH_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.lizistired.cavedust.utils.JsonFile;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import static net.lizistired.cavedust.CaveDust.*;
|
||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public class CaveDustConfig extends JsonFile {
|
||||
private transient final net.lizistired.cavedust.CaveDust CaveDust;
|
||||
@@ -27,9 +34,13 @@ public class CaveDustConfig extends JsonFile {
|
||||
private float lowerLimit = -64;
|
||||
private int particleMultiplier = 1;
|
||||
|
||||
int listNumber = 0;
|
||||
|
||||
private int particleMultiplierMultiplier = 10;
|
||||
|
||||
private int particleID = WHITE_ASH_ID;
|
||||
List<Identifier> list = List.of(Registries.PARTICLE_TYPE.getIds().toArray(new Identifier[0]));
|
||||
|
||||
Identifier newId = Identifier.of("cavedust", "cave_dust");
|
||||
|
||||
public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
|
||||
super(file);
|
||||
@@ -141,6 +152,16 @@ public class CaveDustConfig extends JsonFile {
|
||||
// }
|
||||
//}
|
||||
|
||||
public ParticleEffect getParticle(){
|
||||
try{
|
||||
return (ParticleEffect) Registries.PARTICLE_TYPE.get(newId);
|
||||
}
|
||||
catch (ClassCastException e){
|
||||
iterateParticle();
|
||||
return getParticle();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSeaLevelCheck() {
|
||||
return seaLevelCheck;
|
||||
}
|
||||
@@ -176,29 +197,20 @@ public class CaveDustConfig extends JsonFile {
|
||||
return getSuperFlatStatus();
|
||||
}
|
||||
|
||||
//todo
|
||||
//public void iterateParticle(){
|
||||
// if(getParticleID() > Registries.PARTICLE_TYPE.size() - 2) {
|
||||
// particleID = 1;
|
||||
// save();
|
||||
// } else {
|
||||
// particleID = getParticleID() + 1;
|
||||
// save();
|
||||
// }
|
||||
//}
|
||||
|
||||
public void setParticleID(int particleID){
|
||||
this.particleID = particleID;
|
||||
public void iterateParticle() {
|
||||
try {
|
||||
listNumber = listNumber + 1;
|
||||
newId = list.get(listNumber);
|
||||
} catch (IndexOutOfBoundsException e){
|
||||
newId = list.get(0);
|
||||
listNumber = 0;
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
//todo
|
||||
//public int getParticleID(){
|
||||
// if ((!Registries.PARTICLE_TYPE.getValueOrThrow())) {
|
||||
// setParticleID(WHITE_ASH_ID);
|
||||
// }
|
||||
// return particleID;
|
||||
//}
|
||||
public ParticleEffect getParticleID(){
|
||||
return getParticle();
|
||||
}
|
||||
|
||||
public void resetConfig(){
|
||||
width = 10;
|
||||
@@ -211,9 +223,10 @@ public class CaveDustConfig extends JsonFile {
|
||||
particleMultiplierMultiplier = 10;
|
||||
velocityRandomness = 0;
|
||||
|
||||
newId = Identifier.of("cavedust", "cave_dust");
|
||||
|
||||
seaLevelCheck = true;
|
||||
caveDustEnabled = true;
|
||||
particleID = WHITE_ASH_ID;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.minelittlepony.common.client.gui.element.*;
|
||||
import net.lizistired.cavedust.utils.TranslatableTextHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -67,12 +68,11 @@ public class ModMenuConfigScreen extends GameGui {
|
||||
.onChange(config::setParticleMultiplierMultiplier)
|
||||
.setTextFormat(transText::formatParticleMultiplierMultiplier)
|
||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultipliermultiplier.tooltip"));
|
||||
//todo
|
||||
//addButton(new Button(left, row += 24).onClick(sender ->{
|
||||
// config.iterateParticle();
|
||||
// sender.getStyle().setText("Particle: " + (getNameOfParticle()));
|
||||
//})).getStyle().setText("Particle: " + (getNameOfParticle()))
|
||||
// .setTooltip(Text.translatable("menu.cavedust.particle.tooltip"));
|
||||
addButton(new Button(left, row += 24).onClick(sender ->{
|
||||
config.iterateParticle();
|
||||
sender.getStyle().setText("Particle: " + (getNameOfParticle()));
|
||||
})).getStyle().setText("Particle: " + (getNameOfParticle()))
|
||||
.setTooltip(Text.translatable("menu.cavedust.particle.tooltip"));
|
||||
|
||||
addButton(new Slider(left += 220, row -= 96, 1, 50, config.getDimensionWidth()))
|
||||
.onChange(config::setDimensionWidth)
|
||||
@@ -108,14 +108,15 @@ public class ModMenuConfigScreen extends GameGui {
|
||||
renderBackground(context, mouseX, mouseY, partialTicks);
|
||||
super.render(context, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
//todo
|
||||
//private String getNameOfParticle(){
|
||||
// CaveDustConfig config = CaveDust.getInstance().getConfig();
|
||||
// config.load();
|
||||
// try {
|
||||
// return Registries.PARTICLE_TYPE.getEntry(config.getParticleID()).get().getKey().get().getValue().toString();
|
||||
// } catch (NoSuchElementException e){
|
||||
// return "null";
|
||||
// }
|
||||
//}
|
||||
|
||||
private String getNameOfParticle(){
|
||||
CaveDustConfig config = CaveDust.getInstance().getConfig();
|
||||
config.load();
|
||||
try {
|
||||
return Registries.PARTICLE_TYPE.getEntry((ParticleType<?>) config.getParticleID()).getIdAsString();
|
||||
} catch (NoSuchElementException e){
|
||||
CaveDust.LOGGER.error(String.valueOf(e));
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
"net.lizistired.cavedust.CaveDust"
|
||||
],
|
||||
"main": [
|
||||
"net.lizistired.cavedust.CaveDustServer"]
|
||||
"net.lizistired.cavedust.CaveDustServer"],
|
||||
"modmenu": [
|
||||
"net.lizistired.cavedust.CaveDustModMenuFactory"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"dust.mixins.json"
|
||||
"cavedust.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.5",
|
||||
|
||||
Reference in New Issue
Block a user