Compare commits
3 Commits
v1.0.0-1.2
...
1.21.8_fab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb3f0b8037 | ||
|
|
f91265d812 | ||
|
|
6e3fbc9069 |
19
build.gradle
19
build.gradle
@@ -1,12 +1,10 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.14.7'
|
id 'fabric-loom' version '1.11-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
|
id 'org.jetbrains.kotlin.jvm'
|
||||||
}
|
}
|
||||||
|
|
||||||
base {
|
archivesBaseName = project.archives_base_name
|
||||||
archivesName = project.archives_base_name
|
|
||||||
}
|
|
||||||
|
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
@@ -19,7 +17,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
url = "https://maven.terraformersmc.com/releases"
|
url = "https://maven.terraformersmc.com"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'minelp'
|
name = 'minelp'
|
||||||
@@ -29,6 +27,7 @@ repositories {
|
|||||||
name = 'minelp-release'
|
name = 'minelp-release'
|
||||||
url = 'https://repo.minelittlepony-mod.com/maven/release'
|
url = 'https://repo.minelittlepony-mod.com/maven/release'
|
||||||
}
|
}
|
||||||
|
mavenCentral()
|
||||||
// Add repositories to retrieve artifacts from in here.
|
// Add repositories to retrieve artifacts from in here.
|
||||||
// You should only use this when depending on other mods because
|
// You should only use this when depending on other mods because
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
@@ -49,6 +48,7 @@ dependencies {
|
|||||||
include "com.minelittlepony:kirin:${project.kirin_version}"
|
include "com.minelittlepony:kirin:${project.kirin_version}"
|
||||||
|
|
||||||
modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
|
modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
@@ -69,13 +69,11 @@ java {
|
|||||||
// if it is present.
|
// if it is present.
|
||||||
// If you remove this line, sources will not be generated.
|
// If you remove this line, sources will not be generated.
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from("LICENSE") {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.archives_base_name}" }
|
rename { "${it}_${project.archivesBaseName}"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,3 +93,6 @@ publishing {
|
|||||||
// retrieving dependencies.
|
// retrieving dependencies.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(21)
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,17 +2,20 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
minecraft_version=1.21.11
|
# check these on https://fabricmc.net/develop
|
||||||
yarn_mappings=1.21.11+build.3
|
minecraft_version=1.21.8
|
||||||
loader_version=0.18.4
|
yarn_mappings=1.21.8+build.1
|
||||||
loom_version=1.14-SNAPSHOT
|
loader_version=0.17.2
|
||||||
|
loom_version=1.11-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.0
|
mod_version=4.0.0
|
||||||
maven_group=com.straice
|
maven_group=com.lizistired
|
||||||
archives_base_name=cave_dust_reforged
|
archives_base_name=cave_dust
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.140.2+1.21.11
|
fabric_version=0.133.0+1.21.8
|
||||||
modmenu_version=17.0.0-beta.1
|
clothconfig_version=19.0.147
|
||||||
kirin_version=1.21.4+1.21.11
|
modmenu_version=15.0.0
|
||||||
|
kirin_version=1.21.0-beta.5+1.21.7
|
||||||
|
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -7,4 +7,10 @@ pluginManagement {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
|
plugins {
|
||||||
|
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plugins {
|
||||||
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,129 +1,168 @@
|
|||||||
package net.lizistired.cavedust;
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
//minecraft imports
|
//minecraft imports
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
|
||||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||||
|
import net.fabricmc.fabric.api.client.particle.v1.ParticleRenderEvents;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
|
import net.lizistired.cavedust.utils.CubeCreator;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
|
import net.minecraft.particle.ParticleType;
|
||||||
|
import net.minecraft.particle.ParticleUtil;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
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;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
|
import net.minecraft.world.event.GameEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
//java imports
|
//java imports
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
//static imports
|
//static imports
|
||||||
import static net.lizistired.cavedust.utils.KeybindingHelper.*;
|
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||||
import static net.lizistired.cavedust.utils.MathHelper.generateRandomDouble;
|
import static net.lizistired.cavedust.utils.MathHelper.generateRandomDouble;
|
||||||
import static net.lizistired.cavedust.utils.MathHelper.normalize;
|
|
||||||
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
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 {
|
||||||
//logger
|
//logger
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("cavedust");
|
public static final Logger LOGGER = LoggerFactory.getLogger("cavedust");
|
||||||
|
|
||||||
|
//modid
|
||||||
|
public static final String modid = "cave_dust";
|
||||||
|
|
||||||
//make class static
|
//make class static
|
||||||
private static CaveDust instance;
|
private static CaveDust instance;
|
||||||
|
|
||||||
public static CaveDust getInstance() {
|
public static CaveDust getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CaveDust() {
|
public CaveDust() {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//config assignment
|
//config assignment
|
||||||
private static CaveDustConfig config;
|
private static net.lizistired.cavedust.CaveDustConfig config;
|
||||||
|
public net.lizistired.cavedust.CaveDustConfig getConfig() {
|
||||||
public CaveDustConfig getConfig() {
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParticleEffect WHITE_ASH_ID =
|
public static ParticleEffect WHITE_ASH_ID = (ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of(modid, "cave_dust"));
|
||||||
(ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust"));
|
|
||||||
|
|
||||||
public static int PARTICLE_AMOUNT = 0;
|
public static int PARTICLE_AMOUNT = 0;
|
||||||
|
public static int PARTICLE_RADIUS_PLUME = 50;
|
||||||
|
CubeCreator cubeCreator = new CubeCreator();
|
||||||
|
MinecraftClient client;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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(modid);
|
||||||
config = new CaveDustConfig(caveDustFolder.getParent().resolve("cavedust.json"), this);
|
config = new CaveDustConfig(CaveDustFolder.getParent().resolve(modid + ".json"), this);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
registerKeyBindings();
|
registerKeyBindings();
|
||||||
|
ParticleFactoryRegistry.getInstance().register(CaveDustServer.CAVE_DUST_MOTE, CaveDustMoteParticleFactory.Factory::new);
|
||||||
ParticleFactoryRegistry.getInstance().register(CaveDustServer.CAVE_DUST, CaveDustParticleFactory.Factory::new);
|
ParticleFactoryRegistry.getInstance().register(CaveDustServer.CAVE_DUST_PLUME, CaveDustPlumeParticleFactory.Factory::new);
|
||||||
|
|
||||||
//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);
|
WorldRenderEvents.LAST.register(this::createCaveDust);
|
||||||
|
ServerLifecycleEvents.SERVER_STOPPING.register(this::nullClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCaveDust(MinecraftClient client) {
|
private void nullClient(MinecraftServer minecraftServer) {
|
||||||
if (client.player == null) return;
|
client = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCaveDust(WorldRenderContext worldRenderContext) {
|
||||||
|
if(client == null) {
|
||||||
|
try {
|
||||||
|
client = worldRenderContext.gameRenderer().getClient();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (keyBinding1.wasPressed()){
|
if (keyBinding1.wasPressed()){
|
||||||
getConfig().toggleCaveDust();
|
getConfig().toggleCaveDust();
|
||||||
LOGGER.info("Toggled dust");
|
LOGGER.info("Toggled dust");
|
||||||
client.player.sendMessage(
|
client.player.sendMessage(Text.translatable("debug.cavedust.toggle." + config.getCaveDustEnabled()), true);
|
||||||
Text.translatable("debug.cavedust.toggle." + config.getCaveDustEnabled()),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyBinding2.wasPressed()){
|
if (keyBinding2.wasPressed()){
|
||||||
getConfig().load();
|
getConfig().load();
|
||||||
LOGGER.info("Reloaded config");
|
LOGGER.info("Reloaded config");
|
||||||
client.player.sendMessage(Text.translatable("debug.cavedust.reload"), false);
|
client.player.sendMessage(Text.translatable("debug.cavedust.reload"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure world is not null
|
//ensure world is not null
|
||||||
if (client.world == null) return;
|
if (client.world == null) return;
|
||||||
World world = client.world;
|
World world = client.world;
|
||||||
|
|
||||||
double probabilityNormalized =
|
for (int i = 0; i < 5; i++) {
|
||||||
normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
cubeCreator.randomSphereCreator(5, 0, 0, 0, Identifier.of(modid, "cave_dust_mote"));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 1; i++) {
|
||||||
|
cubeCreator.randomSphereCreator(20, 0, 0, 0, Identifier.of(modid, "cave_dust_plume"));
|
||||||
|
}
|
||||||
|
|
||||||
PARTICLE_AMOUNT = (int) (probabilityNormalized
|
}
|
||||||
* config.getParticleMultiplier()
|
|
||||||
* config.getParticleMultiplierMultiplier());
|
|
||||||
|
|
||||||
for (int i = 0; i < PARTICLE_AMOUNT; i++) {
|
private void createCaveDust(MinecraftClient client) {
|
||||||
int x = (int) (client.player.getX()
|
|
||||||
+ generateRandomDouble(-config.getDimensionWidth(), config.getDimensionWidth()));
|
|
||||||
|
|
||||||
int y = (int) (client.player.getEyeY()
|
//LOGGER.info(String.valueOf(((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()));
|
||||||
+ generateRandomDouble(-config.getDimensionHeight(), config.getDimensionHeight()));
|
// )
|
||||||
|
double probabilityNormalized = normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||||
|
PARTICLE_AMOUNT = (int) (probabilityNormalized * config.getParticleMultiplier() * config.getParticleMultiplierMultiplier());
|
||||||
|
|
||||||
int z = (int) (client.player.getZ()
|
//for (int i = 0; i < PARTICLE_AMOUNT; i++) {
|
||||||
+ generateRandomDouble(-config.getDimensionWidth(), config.getDimensionWidth()));
|
// 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()));
|
||||||
|
// double miniX = (x + Math.random());
|
||||||
|
// double miniY = (y + Math.random());
|
||||||
|
// double miniZ = (z + Math.random());
|
||||||
|
// BlockPos particlePos = new BlockPos(x, y, z);
|
||||||
|
//
|
||||||
|
// if (shouldParticlesSpawn(client, config, particlePos)) {
|
||||||
|
// if (client.world.getBlockState(particlePos).isAir()) {
|
||||||
|
// world.addParticleClient((ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust_mote")), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
double miniX = x + Math.random();
|
//cubeCreator.cubeCreator(50, 0, 0, 0);
|
||||||
double miniY = y + Math.random();
|
for (int i = 0; i < 1; i++) {
|
||||||
double miniZ = z + Math.random();
|
cubeCreator.randomSphereCreator(5, 0, 0, 0, Identifier.of("cavedust", "cave_dust_mote"));
|
||||||
|
}
|
||||||
|
|
||||||
BlockPos particlePos = new BlockPos(x, y, z);
|
|
||||||
|
|
||||||
if (shouldParticlesSpawn(client, config, particlePos)) {
|
//Vec3d playerPos = client.player.getEyePos();
|
||||||
if (client.world.getBlockState(particlePos).isAir()) {
|
//int x = (int) (playerPos.getX() + (int) generateRandomDouble(generateRandomDouble(-50, -25), (generateRandomDouble(25, 50))));
|
||||||
world.addParticleClient(
|
////int y = (int) (playerPos.getY() + (int) generateRandomDouble(PARTICLE_RADIUS_PLUME *-1, PARTICLE_RADIUS_PLUME));
|
||||||
getConfig().getParticle(),
|
//int z = (int) (playerPos.getZ() + (int) generateRandomDouble(PARTICLE_RADIUS_PLUME *-1, PARTICLE_RADIUS_PLUME));
|
||||||
miniX, miniY, miniZ,
|
//BlockPos particlePos = new BlockPos(x, (int) playerPos.y, z);
|
||||||
config.getVelocityRandomnessRandom() * 0.01,
|
//
|
||||||
config.getVelocityRandomnessRandom() * 0.01,
|
//
|
||||||
config.getVelocityRandomnessRandom() * 0.01
|
//if (shouldParticlesSpawn(client, config, particlePos)) {
|
||||||
);
|
//
|
||||||
}
|
// if (playerPos.distanceTo(particlePos.toCenterPos()) >= 45 && playerPos.distanceTo(particlePos.toCenterPos()) <= 55) {
|
||||||
}
|
// if (client.world.getBlockState(particlePos).isAir()) {
|
||||||
}
|
// world.addParticleClient((ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust_mote")), x, playerPos.y, z, 0, 0, 0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CaveDustConfig extends JsonFile {
|
|||||||
|
|
||||||
List<Identifier> list = List.of(Registries.PARTICLE_TYPE.getIds().toArray(new Identifier[0]));
|
List<Identifier> list = List.of(Registries.PARTICLE_TYPE.getIds().toArray(new Identifier[0]));
|
||||||
|
|
||||||
Identifier newId = Identifier.of("cavedust", "cave_dust");
|
Identifier newId = Identifier.of("cavedust", "cave_dust_mote");
|
||||||
|
|
||||||
public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
|
public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
|
||||||
super(file);
|
super(file);
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.particle.*;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.particle.SimpleParticleType;
|
||||||
|
|
||||||
|
public class CaveDustMoteParticleFactory extends SpriteBillboardParticle {
|
||||||
|
private final SpriteProvider spriteProvider;
|
||||||
|
CaveDustMoteParticleFactory(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
|
||||||
|
super(clientWorld, x, y, z);
|
||||||
|
this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor method
|
||||||
|
this.maxAge = 200; //20 ticks = 1 second
|
||||||
|
this.scale = 0.1f;
|
||||||
|
this.velocityX = velocityX; //The velX from the constructor parameters
|
||||||
|
this.velocityY = -0.007f; //Allows the particle to slowly fall
|
||||||
|
this.velocityZ = velocityZ;
|
||||||
|
this.x = x; //The x from the constructor parameters
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.collidesWithWorld = true;
|
||||||
|
this.alpha = 1.0f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
|
||||||
|
this.setSpriteForAge(spriteProvider); //Required
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if(this.alpha < 0.0f){
|
||||||
|
this.markDead();
|
||||||
|
}
|
||||||
|
this.alpha -= 0.005f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParticleTextureSheet getType() {
|
||||||
|
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||||
|
private final SpriteProvider spriteProvider;
|
||||||
|
|
||||||
|
public Factory(SpriteProvider spriteProvider) {
|
||||||
|
this.spriteProvider = spriteProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Particle createParticle(SimpleParticleType type, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||||
|
return new CaveDustMoteParticleFactory(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package net.lizistired.cavedust;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.client.particle.BillboardParticle;
|
|
||||||
import net.minecraft.client.particle.Particle;
|
|
||||||
import net.minecraft.client.particle.ParticleFactory;
|
|
||||||
import net.minecraft.client.particle.SpriteProvider;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import net.minecraft.particle.SimpleParticleType;
|
|
||||||
import net.minecraft.util.math.random.Random;
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class CaveDustParticleFactory extends BillboardParticle {
|
|
||||||
private final SpriteProvider spriteProvider;
|
|
||||||
|
|
||||||
CaveDustParticleFactory(
|
|
||||||
ClientWorld world,
|
|
||||||
double x, double y, double z,
|
|
||||||
double velocityX, double velocityY, double velocityZ,
|
|
||||||
SpriteProvider spriteProvider
|
|
||||||
) {
|
|
||||||
// En 1.21.9+ BillboardParticle puede recibir sprite inicial
|
|
||||||
super(world, x, y, z, velocityX, velocityY, velocityZ, spriteProvider.getFirst());
|
|
||||||
|
|
||||||
this.spriteProvider = spriteProvider;
|
|
||||||
|
|
||||||
this.maxAge = 200; // 20 ticks = 1s
|
|
||||||
this.scale = 0.1f;
|
|
||||||
|
|
||||||
this.velocityX = velocityX;
|
|
||||||
this.velocityY = -0.007f;
|
|
||||||
this.velocityZ = velocityZ;
|
|
||||||
|
|
||||||
this.collidesWithWorld = true;
|
|
||||||
this.alpha = 1.0f;
|
|
||||||
|
|
||||||
// Selecciona el sprite correcto según edad/maxAge (equivalente a setSpriteForAge)
|
|
||||||
this.updateSprite(spriteProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BillboardParticle.RenderType getRenderType() {
|
|
||||||
return BillboardParticle.RenderType.PARTICLE_ATLAS_TRANSLUCENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
|
|
||||||
if (!this.isAlive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.alpha -= 0.005f;
|
|
||||||
if (this.alpha <= 0.0f) {
|
|
||||||
this.markDead();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateSprite(this.spriteProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
|
||||||
private final SpriteProvider spriteProvider;
|
|
||||||
|
|
||||||
public Factory(SpriteProvider spriteProvider) {
|
|
||||||
this.spriteProvider = spriteProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Particle createParticle(
|
|
||||||
SimpleParticleType type,
|
|
||||||
ClientWorld world,
|
|
||||||
double x, double y, double z,
|
|
||||||
double velocityX, double velocityY, double velocityZ,
|
|
||||||
Random random
|
|
||||||
) {
|
|
||||||
return new CaveDustParticleFactory(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.lizistired.cavedust.utils.MathHelper;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.particle.*;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.particle.SimpleParticleType;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
public class CaveDustPlumeParticleFactory extends SpriteBillboardParticle {
|
||||||
|
private final SpriteProvider spriteProvider;
|
||||||
|
CaveDustPlumeParticleFactory(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
|
||||||
|
super(clientWorld, x, y, z);
|
||||||
|
this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor method
|
||||||
|
this.maxAge = 60; //20 ticks = 1 second
|
||||||
|
this.scale = 10f;
|
||||||
|
this.velocityX = velocityX; //The velX from the constructor parameters
|
||||||
|
this.velocityY = -0.007f; //Allows the particle to slowly fall
|
||||||
|
this.velocityZ = velocityZ;
|
||||||
|
this.x = x; //The x from the constructor parameters
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.collidesWithWorld = false;
|
||||||
|
this.alpha = 0.5f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
|
||||||
|
this.setSprite(spriteProvider); //Required
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
Vec3d particlePos = new Vec3d(this.x, this.y, this.z);
|
||||||
|
double distanceFromParticleToPlayer = particlePos.distanceTo(player.getEyePos());
|
||||||
|
this.alpha = net.minecraft.util.math.MathHelper.clamp((float) MathHelper.normalize(0, 50, distanceFromParticleToPlayer) * -1, -1, 1);
|
||||||
|
if(this.alpha < 0.001f){
|
||||||
|
this.markDead();
|
||||||
|
}
|
||||||
|
this.alpha -= 0.00005f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParticleTextureSheet getType() {
|
||||||
|
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||||
|
private final SpriteProvider spriteProvider;
|
||||||
|
|
||||||
|
public Factory(SpriteProvider spriteProvider) {
|
||||||
|
this.spriteProvider = spriteProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Particle createParticle(SimpleParticleType type, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||||
|
return new CaveDustPlumeParticleFactory(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,12 +8,14 @@ import net.minecraft.registry.Registry;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class CaveDustServer implements ModInitializer {
|
public class CaveDustServer implements ModInitializer {
|
||||||
public static final SimpleParticleType CAVE_DUST = FabricParticleTypes.simple();
|
public static final SimpleParticleType CAVE_DUST_MOTE = FabricParticleTypes.simple();
|
||||||
|
public static final SimpleParticleType CAVE_DUST_PLUME = FabricParticleTypes.simple();
|
||||||
/**
|
/**
|
||||||
* Runs the mod initializer.
|
* Runs the mod initializer.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
Registry.register(Registries.PARTICLE_TYPE, Identifier.of("cavedust", "cave_dust"), CAVE_DUST);
|
Registry.register(Registries.PARTICLE_TYPE, Identifier.of("cavedust", "cave_dust_mote"), CAVE_DUST_MOTE);
|
||||||
|
Registry.register(Registries.PARTICLE_TYPE, Identifier.of("cavedust", "cave_dust_plume"), CAVE_DUST_PLUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,66 +35,10 @@ public class ModMenuConfigScreen extends GameGui {
|
|||||||
.setText("menu.cavedust.global." + config.getCaveDustEnabled())
|
.setText("menu.cavedust.global." + config.getCaveDustEnabled())
|
||||||
.setTooltip(Text.translatable("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
.setTooltip(Text.translatable("menu.cavedust.global.tooltip." + config.getCaveDustEnabled()));
|
||||||
|
|
||||||
/*addButton(new Button(left, row += 24).onClick(sender -> {
|
addButton(new Button(left, row += 120)
|
||||||
sender.getStyle().setText("menu.cavedust.enhanceddetection." + config.setEnhancedDetection()).setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));
|
.onClick(sender ->
|
||||||
})).getStyle()
|
client.setScreen(new ModMenuConfigScreenAdvanced(parent)
|
||||||
.setText("menu.cavedust.enhanceddetection." + config.getEnhancedDetection())
|
)));
|
||||||
.setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));*/
|
|
||||||
|
|
||||||
addButton(new Button(left, row += 24).onClick(sender -> {
|
|
||||||
sender.getStyle().setText("menu.cavedust.superflatstatus." + config.setSuperFlatStatus()).setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
|
|
||||||
})).getStyle()
|
|
||||||
.setText("menu.cavedust.superflatstatus." + config.getSuperFlatStatus())
|
|
||||||
.setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*addButton(new Slider(left, row += 48, -64, 319, config.getUpperLimit()))
|
|
||||||
.onChange(config::setUpperLimit)
|
|
||||||
.setTextFormat(transText::formatUpperLimit)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.upperlimit.tooltip"));
|
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, -64, 319, config.getLowerLimit()))
|
|
||||||
.onChange(config::setLowerLimit)
|
|
||||||
.setTextFormat(transText::formatLowerLimit)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.lowerlimit.tooltip"));*/
|
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplier()))
|
|
||||||
.onChange(config::setParticleMultiplier)
|
|
||||||
.setTextFormat(transText::formatParticleMultiplier)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultiplier.tooltip"));
|
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplierMultiplier()))
|
|
||||||
.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"));
|
|
||||||
|
|
||||||
addButton(new Slider(left += 220, row -= 96, 1, 50, config.getDimensionWidth()))
|
|
||||||
.onChange(config::setDimensionWidth)
|
|
||||||
.setTextFormat(transText::formatMaxWidth)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.width.tooltip"));
|
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, 1, 50, config.getDimensionHeight()))
|
|
||||||
.onChange(config::setDimensionHeight)
|
|
||||||
.setTextFormat(transText::formatMaxHeight)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.height.tooltip"));
|
|
||||||
|
|
||||||
addButton(new Slider(left, row += 24, 0, 10, config.getVelocityRandomness()))
|
|
||||||
.onChange(config::setVelocityRandomness)
|
|
||||||
.setTextFormat(transText::formatVelocityRandomness)
|
|
||||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.velocityrandomness.tooltip"));
|
|
||||||
|
|
||||||
|
|
||||||
addButton(new Button(left -= 110, row += 120).onClick(sender -> {
|
|
||||||
config.resetConfig();
|
|
||||||
finish();
|
|
||||||
client.setScreen(new ModMenuConfigScreen(parent));
|
|
||||||
})).getStyle().setText(Text.translatable("menu.cavedust.reset")).setTooltip(Text.translatable("menu.cavedust.reset.tooltip"));
|
|
||||||
|
|
||||||
addButton(new Button(left, row += 24)
|
addButton(new Button(left, row += 24)
|
||||||
.onClick(sender -> finish())).getStyle()
|
.onClick(sender -> finish())).getStyle()
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package net.lizistired.cavedust;
|
||||||
|
|
||||||
|
import com.minelittlepony.common.client.gui.GameGui;
|
||||||
|
import com.minelittlepony.common.client.gui.element.Button;
|
||||||
|
import com.minelittlepony.common.client.gui.element.Label;
|
||||||
|
import com.minelittlepony.common.client.gui.element.Slider;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
public class ModMenuConfigScreenAdvanced extends GameGui {
|
||||||
|
public ModMenuConfigScreenAdvanced(@Nullable Screen parent) {
|
||||||
|
super(Text.translatable("menu.cavedust.title.advanced"), 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 += 24).onClick(sender -> {
|
||||||
|
sender.getStyle().setText("menu.cavedust.enhanceddetection." + config.setEnhancedDetection()).setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));
|
||||||
|
})).getStyle()
|
||||||
|
.setText("menu.cavedust.enhanceddetection." + config.getEnhancedDetection())
|
||||||
|
.setTooltip(Text.translatable("menu.cavedust.enhanceddetection.tooltip"));*/
|
||||||
|
|
||||||
|
addButton(new Button(left, row += 24).onClick(sender -> {
|
||||||
|
sender.getStyle().setText("menu.cavedust.superflatstatus." + config.setSuperFlatStatus()).setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
|
||||||
|
})).getStyle()
|
||||||
|
.setText("menu.cavedust.superflatstatus." + config.getSuperFlatStatus())
|
||||||
|
.setTooltip(Text.translatable("menu.cavedust.superflatstatus.tooltip"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*addButton(new Slider(left, row += 48, -64, 319, config.getUpperLimit()))
|
||||||
|
.onChange(config::setUpperLimit)
|
||||||
|
.setTextFormat(transText::formatUpperLimit)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.upperlimit.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, -64, 319, config.getLowerLimit()))
|
||||||
|
.onChange(config::setLowerLimit)
|
||||||
|
.setTextFormat(transText::formatLowerLimit)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.lowerlimit.tooltip"));*/
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplier()))
|
||||||
|
.onChange(config::setParticleMultiplier)
|
||||||
|
.setTextFormat(transText::formatParticleMultiplier)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.particlemultiplier.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, 1, 100, config.getParticleMultiplierMultiplier()))
|
||||||
|
.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"));
|
||||||
|
|
||||||
|
addButton(new Slider(left += 220, row -= 96, 1, 50, config.getDimensionWidth()))
|
||||||
|
.onChange(config::setDimensionWidth)
|
||||||
|
.setTextFormat(transText::formatMaxWidth)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.width.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, 1, 50, config.getDimensionHeight()))
|
||||||
|
.onChange(config::setDimensionHeight)
|
||||||
|
.setTextFormat(transText::formatMaxHeight)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.height.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Slider(left, row += 24, 0, 10, config.getVelocityRandomness()))
|
||||||
|
.onChange(config::setVelocityRandomness)
|
||||||
|
.setTextFormat(transText::formatVelocityRandomness)
|
||||||
|
.getStyle().setTooltip(Text.translatable("menu.cavedust.velocityrandomness.tooltip"));
|
||||||
|
|
||||||
|
|
||||||
|
addButton(new Button(left -= 110, row += 120).onClick(sender -> {
|
||||||
|
config.resetConfig();
|
||||||
|
finish();
|
||||||
|
client.setScreen(new ModMenuConfigScreenAdvanced(parent));
|
||||||
|
})).getStyle().setText(Text.translatable("menu.cavedust.reset")).setTooltip(Text.translatable("menu.cavedust.reset.tooltip"));
|
||||||
|
|
||||||
|
addButton(new Button(left, row += 24)
|
||||||
|
.onClick(sender -> finish())).getStyle()
|
||||||
|
.setText("gui.done");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
super.render(context, mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,31 +6,19 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
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.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.lizistired.cavedust.CaveDust.PARTICLE_AMOUNT;
|
import static net.lizistired.cavedust.CaveDust.PARTICLE_AMOUNT;
|
||||||
|
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
||||||
|
|
||||||
@Mixin(DebugHud.class)
|
@Mixin(DebugHud.class)
|
||||||
public abstract class MixinDebugScreenOverlay {
|
public abstract class MixinDebugScreenOverlay {
|
||||||
|
@Inject(method = "getRightText", at = @At("RETURN"))
|
||||||
@Inject(
|
|
||||||
method = "getRightText()Ljava/util/List;",
|
|
||||||
at = @At("RETURN"),
|
|
||||||
cancellable = true,
|
|
||||||
require = 0
|
|
||||||
)
|
|
||||||
private void appendDebugText(CallbackInfoReturnable<List<String>> cir) {
|
private void appendDebugText(CallbackInfoReturnable<List<String>> cir) {
|
||||||
List<String> messages = cir.getReturnValue();
|
List<String> messages = cir.getReturnValue();
|
||||||
if (messages == null) return;
|
|
||||||
|
|
||||||
// Evita modificar una lista inmutable/compartida
|
messages.add("");
|
||||||
List<String> out = new ArrayList<>(messages);
|
messages.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
|
||||||
|
messages.add("");
|
||||||
out.add("");
|
|
||||||
out.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
|
|
||||||
out.add("");
|
|
||||||
|
|
||||||
cir.setReturnValue(out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
89
src/main/java/net/lizistired/cavedust/utils/CubeCreator.java
Normal file
89
src/main/java/net/lizistired/cavedust/utils/CubeCreator.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package net.lizistired.cavedust.utils;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.particle.ParticleEffect;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class CubeCreator {
|
||||||
|
|
||||||
|
|
||||||
|
// 3 nesting for loops to create a hollow border cube around the player
|
||||||
|
public void cubeCreator(int steps, int offsetXInitial, int offsetYInitial, int offsetZInitial, Identifier caveDust) {
|
||||||
|
BlockPos playerPos = MinecraftClient.getInstance().player.getBlockPos();
|
||||||
|
|
||||||
|
// Loop over the range of steps around the player
|
||||||
|
for (int x = -steps / 2 + offsetXInitial; x < steps / 2 + offsetXInitial; x++) {
|
||||||
|
for (int y = -steps / 2 + offsetYInitial; y < steps / 2 + offsetYInitial; y++) {
|
||||||
|
for (int z = -steps / 2 + offsetZInitial; z < steps / 2 + offsetZInitial; z++) {
|
||||||
|
|
||||||
|
// Check if the particle is on the border of the cube
|
||||||
|
boolean onBorder = x == -steps / 2 + offsetXInitial || x == steps / 2 + offsetXInitial - 1
|
||||||
|
|| y == -steps / 2 + offsetYInitial || y == steps / 2 + offsetYInitial - 1
|
||||||
|
|| z == -steps / 2 + offsetZInitial || z == steps / 2 + offsetZInitial - 1;
|
||||||
|
|
||||||
|
// If it's on the border, spawn the particle
|
||||||
|
if (onBorder) {
|
||||||
|
spawnParticleClient(playerPos.getX() + x, playerPos.getY() + y, playerPos.getZ() + z, caveDust);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a hollow sphere around the player
|
||||||
|
public void sphereCreator(int radius, int offsetXInitial, int offsetYInitial, int offsetZInitial, Identifier caveDust) {
|
||||||
|
BlockPos playerPos = MinecraftClient.getInstance().player.getBlockPos();
|
||||||
|
|
||||||
|
// Loop over the range of steps around the player (we are using a cube bounding box to check)
|
||||||
|
for (int x = -radius; x <= radius; x++) {
|
||||||
|
for (int y = -radius; y <= radius; y++) {
|
||||||
|
for (int z = -radius; z <= radius; z++) {
|
||||||
|
|
||||||
|
// Calculate the distance from the center (player position)
|
||||||
|
double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
|
||||||
|
|
||||||
|
// If the distance is close to the radius, spawn the particle (create the border)
|
||||||
|
if (Math.abs(distance - radius) < 1.5) { // Threshold for thickness of the border
|
||||||
|
spawnParticleClient(playerPos.getX() + x + offsetXInitial,
|
||||||
|
playerPos.getY() + y + offsetYInitial,
|
||||||
|
playerPos.getZ() + z + offsetZInitial,
|
||||||
|
caveDust);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomSphereCreator(int radius, int offsetXInitial, int offsetYInitial, int offsetZInitial, Identifier caveDust) {
|
||||||
|
Random random = new Random(); // Random number generator
|
||||||
|
|
||||||
|
// Generate random spherical angles
|
||||||
|
double theta = Math.acos(2 * random.nextDouble() - 1); // Random polar angle (0 to pi)
|
||||||
|
double phi = 2 * Math.PI * random.nextDouble(); // Random azimuthal angle (0 to 2*pi)
|
||||||
|
|
||||||
|
// Convert spherical coordinates to Cartesian coordinates
|
||||||
|
double x = radius * Math.sin(theta) * Math.cos(phi);
|
||||||
|
double y = radius * Math.sin(theta) * Math.sin(phi);
|
||||||
|
double z = radius * Math.cos(theta);
|
||||||
|
|
||||||
|
// Offset the generated point to be around the player
|
||||||
|
BlockPos playerPos = MinecraftClient.getInstance().player.getBlockPos();
|
||||||
|
int spawnX = playerPos.getX() + (int) (x + offsetXInitial);
|
||||||
|
int spawnY = playerPos.getY() + (int) (y + offsetYInitial);
|
||||||
|
int spawnZ = playerPos.getZ() + (int) (z + offsetZInitial);
|
||||||
|
|
||||||
|
// Spawn a particle at the random position
|
||||||
|
float randomX = random.nextFloat() + spawnX;
|
||||||
|
float randomY = random.nextFloat() + spawnY;
|
||||||
|
float randomZ = random.nextFloat() + spawnZ;
|
||||||
|
spawnParticleClient(randomX, randomY, randomZ, caveDust);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawnParticleClient(float x, float y, float z, Identifier caveDust) {
|
||||||
|
MinecraftClient.getInstance().world.addParticleClient((ParticleEffect) Registries.PARTICLE_TYPE.get(caveDust), x, y, z, 0.0D, 0.0D, 0.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package net.lizistired.cavedust.utils;
|
|||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.minecraft.client.option.KeyBinding;
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class KeybindingHelper {
|
public class KeybindingHelper {
|
||||||
@@ -11,23 +10,19 @@ public class KeybindingHelper {
|
|||||||
public static KeyBinding keyBinding1;
|
public static KeyBinding keyBinding1;
|
||||||
public static KeyBinding keyBinding2;
|
public static KeyBinding keyBinding2;
|
||||||
|
|
||||||
// 1.21.9+ requiere Category (no String)
|
|
||||||
private static final KeyBinding.Category CATEGORY =
|
|
||||||
KeyBinding.Category.create(Identifier.of("cavedust", "spook"));
|
|
||||||
|
|
||||||
public static void registerKeyBindings(){
|
public static void registerKeyBindings(){
|
||||||
keyBinding1 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
keyBinding1 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
"key.cavedust.toggle",
|
"key.cavedust.toggle",
|
||||||
InputUtil.Type.KEYSYM,
|
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,
|
GLFW.GLFW_KEY_KP_ADD, // The keycode of the key
|
||||||
CATEGORY
|
"category.cavedust.spook" // The translation key of the keybinding's category.
|
||||||
));
|
));
|
||||||
|
|
||||||
keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
"key.cavedust.reload",
|
"key.cavedust.reload", // The translation key of the keybinding's name
|
||||||
InputUtil.Type.KEYSYM,
|
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
||||||
GLFW.GLFW_KEY_KP_ENTER,
|
GLFW.GLFW_KEY_KP_ENTER, // The keycode of the key
|
||||||
CATEGORY
|
"category.cavedust.spook" // The translation key of the keybinding's category.
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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.
|
* Returns true if particles should spawn.
|
||||||
* @param client MinecraftClient
|
* @param client MinecraftClient
|
||||||
@@ -22,21 +23,14 @@ public class ParticleSpawnUtil {
|
|||||||
*/
|
*/
|
||||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
||||||
|
|
||||||
if (client.player == null) {
|
//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
|
||||||
timer = 0;
|
|
||||||
shouldParticlesSpawn = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// checks if the config is enabled, if the game isn't paused, if the world is valid,
|
|
||||||
// only in overworld, and if the player isn't in a lush caves biome
|
|
||||||
if (!config.getCaveDustEnabled()
|
if (!config.getCaveDustEnabled()
|
||||||
|| client.isPaused()
|
|| client.isPaused()
|
||||||
|| client.world == null
|
|| client.world == null
|
||||||
|| !client.world.getRegistryKey().equals(World.OVERWORLD)
|
|| !client.world.getDimension().bedWorks()
|
||||||
|| client.player.isSubmergedInWater()
|
|| Objects.requireNonNull(client.player).isSubmergedInWater()
|
||||||
|| client.world.getBiome(client.player.getBlockPos()).matchesKey(LUSH_CAVES)) {
|
|| client.world.getBiome(Objects.requireNonNull(client.player.getBlockPos())).matchesKey(LUSH_CAVES))
|
||||||
|
{
|
||||||
timer = 0;
|
timer = 0;
|
||||||
shouldParticlesSpawn = false;
|
shouldParticlesSpawn = false;
|
||||||
return false;
|
return false;
|
||||||
@@ -45,7 +39,7 @@ public class ParticleSpawnUtil {
|
|||||||
World world = client.world;
|
World world = client.world;
|
||||||
int seaLevel = world.getSeaLevel();
|
int seaLevel = world.getSeaLevel();
|
||||||
|
|
||||||
if (!world.isSkyVisible(client.player.getBlockPos())) {
|
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
||||||
if (client.player.getBlockPos().getY() + 2 < seaLevel){
|
if (client.player.getBlockPos().getY() + 2 < seaLevel){
|
||||||
timer = timer + 1;
|
timer = timer + 1;
|
||||||
if (timer > 10){
|
if (timer > 10){
|
||||||
@@ -55,7 +49,6 @@ public class ParticleSpawnUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldParticlesSpawn = false;
|
shouldParticlesSpawn = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -69,26 +62,20 @@ public class ParticleSpawnUtil {
|
|||||||
*/
|
*/
|
||||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config, BlockPos pos) {
|
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,
|
//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
|
||||||
// only in overworld, and if the particle position isn't in lush caves
|
|
||||||
if (!config.getCaveDustEnabled()
|
if (!config.getCaveDustEnabled()
|
||||||
|| client.isPaused()
|
|| client.isPaused()
|
||||||
|| client.world == null
|
|| client.world == null
|
||||||
|| !client.world.getRegistryKey().equals(World.OVERWORLD)
|
|| !client.world.getDimension().bedWorks()
|
||||||
|| (client.world.getBottomY() > pos.getY())
|
|| (client.world.getBottomY() > pos.getY())
|
||||||
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES)) {
|
//|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
|
||||||
|
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
|
||||||
|
|
||||||
|
{
|
||||||
timer = 0;
|
timer = 0;
|
||||||
shouldParticlesSpawn = false;
|
shouldParticlesSpawn = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.player == null) {
|
|
||||||
timer = 0;
|
|
||||||
shouldParticlesSpawn = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!config.getSuperFlatStatus()) {
|
if(!config.getSuperFlatStatus()) {
|
||||||
if (((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()) {
|
if (((ClientWorldAccessor) client.world.getLevelProperties()).getFlatWorld()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -98,7 +85,7 @@ public class ParticleSpawnUtil {
|
|||||||
World world = client.world;
|
World world = client.world;
|
||||||
int seaLevel = world.getSeaLevel();
|
int seaLevel = world.getSeaLevel();
|
||||||
|
|
||||||
if (!world.isSkyVisible(pos)) {
|
if (!client.player.clientWorld.isSkyVisible(pos)) {
|
||||||
if (pos.getY() + 2 < seaLevel){
|
if (pos.getY() + 2 < seaLevel){
|
||||||
timer = timer + 1;
|
timer = timer + 1;
|
||||||
if (timer > 10){
|
if (timer > 10){
|
||||||
@@ -108,7 +95,6 @@ public class ParticleSpawnUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldParticlesSpawn = false;
|
shouldParticlesSpawn = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 116 KiB |
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"menu.cavedust.title": "Cave Dust",
|
"menu.cavedust.title": "Cave Dust",
|
||||||
|
"menu.cavedust.title.advanced": "Cave Dust Advanced Options",
|
||||||
"menu.cavedust.global.false": "Cave Dust: Disabled",
|
"menu.cavedust.global.false": "Cave Dust: Disabled",
|
||||||
"menu.cavedust.global.true": "Cave Dust: Enabled",
|
"menu.cavedust.global.true": "Cave Dust: Enabled",
|
||||||
"menu.cavedust.global.tooltip.false": "Enable cave dust particles?",
|
"menu.cavedust.global.tooltip.false": "Enable cave dust particles?",
|
||||||
@@ -38,4 +39,5 @@
|
|||||||
"debug.cavedust.reload": "(Cave Dust) Reloaded config",
|
"debug.cavedust.reload": "(Cave Dust) Reloaded config",
|
||||||
"debug.cavedust.particleerror": "(Cave Dust) Error setting particle, skipping to next particle!"
|
"debug.cavedust.particleerror": "(Cave Dust) Error setting particle, skipping to next particle!"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"textures": [
|
||||||
|
"minecraft:big_smoke_0",
|
||||||
|
"minecraft:big_smoke_1",
|
||||||
|
"minecraft:big_smoke_2",
|
||||||
|
"minecraft:big_smoke_3",
|
||||||
|
"minecraft:big_smoke_4",
|
||||||
|
"minecraft:big_smoke_5",
|
||||||
|
"minecraft:big_smoke_6",
|
||||||
|
"minecraft:big_smoke_7",
|
||||||
|
"minecraft:big_smoke_8",
|
||||||
|
"minecraft:big_smoke_9",
|
||||||
|
"minecraft:big_smoke_10",
|
||||||
|
"minecraft:big_smoke_11"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "cavedustreforged",
|
"id": "cavedust",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "Cave Dust Reforged",
|
"name": "Cave Dust",
|
||||||
"description": "Makes dust underground that scales with depth!",
|
"description": "Makes dust underground that scales with depth!",
|
||||||
"authors": [
|
"authors": [
|
||||||
"DekinDev"
|
"LizIsTired"
|
||||||
],
|
|
||||||
"contributors": [
|
|
||||||
"LizIsTired (Original mod)"
|
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"issues": "https://git.straice.com/DekinDev/cave_dust_reforged/issues",
|
"issues": "https://github.com/LizIsTired/dust/issues",
|
||||||
"sources": "https://git.straice.com/DekinDev/cave_dust_reforged",
|
"sources": "https://github.com/LizIsTired/dust"
|
||||||
"homepage": "https://modrinth.com/project/cave-dust-reforged"
|
|
||||||
},
|
},
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"icon": "assets/cavedust/icon.png",
|
"icon": "assets/cavedust/icon.png",
|
||||||
@@ -32,12 +28,19 @@
|
|||||||
"cavedust.mixins.json"
|
"cavedust.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.17.2",
|
"fabricloader": ">=0.14.5",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.21.11",
|
"minecraft": "1.21.8",
|
||||||
"java": ">=17"
|
"java": ">=17"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"modmenu": ">=3.0.1"
|
"modmenu": ">=3.0.1"
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"modmenu": {
|
||||||
|
"links": {
|
||||||
|
"modmenu.discord": "https://discord.gg/4m6kQSX6bx"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user