Skip to content

Commit

Permalink
break config, but now works in 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LizIsTired committed Nov 5, 2024
1 parent 99ffeb1 commit 4b4b2ad
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 68 deletions.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
Expand Down Expand Up @@ -61,14 +58,16 @@ processResources {

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.4
loader_version=0.15.11
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=3.0.0
maven_group=com.lizistired
archives_base_name=cave_dust

# Dependencies
fabric_version=0.100.4+1.21
clothconfig_version=15.0.127
modmenu_version=11.0.1
kirin_version=1.19.0+1.21
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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/lizistired/cavedust/CaveDust.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -90,12 +91,15 @@ private void createCaveDust(MinecraftClient client) {

if (shouldParticlesSpawn(client, config, particlePos)) {
if (client.world.getBlockState(particlePos).isAir()) {
world.addParticle(config.getParticle(), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
//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);
}
}
}
catch (NullPointerException e) {
LOGGER.error(String.valueOf(e));
//todo
//getConfig().setParticleID(WHITE_ASH_ID);
}
}
Expand Down
67 changes: 35 additions & 32 deletions src/main/java/net/lizistired/cavedust/CaveDustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import net.lizistired.cavedust.utils.JsonFile;
import net.minecraft.client.MinecraftClient;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import static net.lizistired.cavedust.CaveDust.*;
Expand Down Expand Up @@ -122,23 +122,24 @@ public boolean getCaveDustEnabled(){
return caveDustEnabled;
}

public ParticleEffect setParticle(String particleType){
//todo
//public Identifier setParticle(String particleType){
//particleName = particleType;
save();
return getParticle();
}

public ParticleEffect getParticle(){
try {
return (ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of(Registries.PARTICLE_TYPE.getEntry(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
} catch (ClassCastException e) {
MinecraftClient.getInstance().player.sendMessage(Text.translatable("debug.cavedust.particleerror"), true);
LOGGER.error("Cannot spawn particle, check config.");
iterateParticle();
save();
return getParticle();
}
}
//save();
//return getParticle().get().getKey().get().getValue();
//}

//public ParticleEffect getParticle(){
// try {
// return Registries.PARTICLE_TYPE.getOptional(Identifier.of(Registries.PARTICLE_TYPE.getOptional(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
// } catch (ClassCastException e) {
// MinecraftClient.getInstance().player.sendMessage(Text.translatable("debug.cavedust.particleerror"), true);
// LOGGER.error("Cannot spawn particle, check config.");
// iterateParticle();
// save();
// return getParticle();
// }
//}

public boolean getSeaLevelCheck() {
return seaLevelCheck;
Expand Down Expand Up @@ -175,27 +176,29 @@ public boolean setSuperFlatStatus(){
return getSuperFlatStatus();
}

public void iterateParticle(){
if(getParticleID() > Registries.PARTICLE_TYPE.size() - 2) {
particleID = 1;
save();
} else {
particleID = getParticleID() + 1;
save();
}
}
//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;
save();
}

public int getParticleID(){
if ((!Registries.PARTICLE_TYPE.getEntry(particleID).isPresent())) {
setParticleID(WHITE_ASH_ID);
}
return particleID;
}
//todo
//public int getParticleID(){
// if ((!Registries.PARTICLE_TYPE.getValueOrThrow())) {
// setParticleID(WHITE_ASH_ID);
// }
// return particleID;
//}

public void resetConfig(){
width = 10;
Expand Down
30 changes: 16 additions & 14 deletions src/main/java/net/lizistired/cavedust/ModMenuConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public void init() {
.onChange(config::setParticleMultiplierMultiplier)
.setTextFormat(transText::formatParticleMultiplierMultiplier)
.getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultipliermultiplier.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"));
//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 Slider(left += 220, row -= 96, 1, 50, config.getDimensionWidth()))
.onChange(config::setDimensionWidth)
Expand Down Expand Up @@ -107,13 +108,14 @@ public void render(DrawContext context, int mouseX, int mouseY, float partialTic
renderBackground(context, mouseX, mouseY, partialTicks);
super.render(context, mouseX, mouseY, partialTicks);
}
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";
}
}
//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";
// }
//}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.minelittlepony.common.client.gui.element.AbstractSlider;
import net.minecraft.text.Text;

import javax.swing.*;

public class TranslatableTextHelper {
public Text formatMaxWidth(AbstractSlider<Float> slider) {
return Text.translatable("menu.cavedust.width", (int)Math.floor(slider.getValue()));
Expand Down
7 changes: 2 additions & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@
"net.lizistired.cavedust.CaveDust"
],
"main": [
"net.lizistired.cavedust.CaveDustServer"],
"modmenu": [
"net.lizistired.cavedust.CaveDustModMenuFactory"
]
"net.lizistired.cavedust.CaveDustServer"]
},
"mixins": [
"dust.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.5",
"fabric": "*",
"minecraft": "1.21",
"minecraft": "1.21.3",
"java": ">=17"
},
"suggests": {
Expand Down

0 comments on commit 4b4b2ad

Please sign in to comment.