Compare commits
2 Commits
v1.0.0_1.2
...
1.20.1_fab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06959e79fb | ||
|
|
31611ea626 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
||||
- name: Extract current branch name
|
||||
shell: bash
|
||||
# bash pattern expansion to grab branch name without slashes
|
||||
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
|
||||
run: ref="${GITHUB_REF#refs/heads/}" && echo "::set-output name=branch::${ref////-}"
|
||||
id: ref
|
||||
|
||||
- name: Set outputs
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||
- name: Check outputs
|
||||
run: echo ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.11-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.6-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
|
||||
@@ -58,7 +61,7 @@ processResources {
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||
it.options.release = 21
|
||||
it.options.release = 17
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -66,8 +69,6 @@ java {
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
@@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.9
|
||||
yarn_mappings=1.21.9+build.1
|
||||
loader_version=0.18.4
|
||||
loom_version=1.14-SNAPSHOT
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.10
|
||||
loader_version=0.15.11
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
maven_group=com.straice
|
||||
archives_base_name=cave_dust_reforged
|
||||
mod_version=3.0.1
|
||||
maven_group=com.lizistired
|
||||
archives_base_name=cave_dust
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.134.1+1.21.9
|
||||
modmenu_version=16.0.0-rc.2
|
||||
kirin_version=1.21.1+1.21.7
|
||||
fabric_version=0.92.2+1.20.1
|
||||
clothconfig_version=11.1.118
|
||||
modmenu_version=7.2.2
|
||||
kirin_version=1.15.6+1.20.1
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,7 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
27
gradlew
vendored
27
gradlew
vendored
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -85,9 +83,7 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -134,13 +130,10 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -148,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -156,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -205,11 +198,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
22
gradlew.bat
vendored
22
gradlew.bat
vendored
@@ -13,8 +13,6 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
@@ -1,129 +1,103 @@
|
||||
package net.lizistired.cavedust;
|
||||
|
||||
// minecraft imports
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
//minecraft imports
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// other imports
|
||||
//other imports
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
// java imports
|
||||
//java imports
|
||||
import java.nio.file.Path;
|
||||
|
||||
// static imports
|
||||
import static net.lizistired.cavedust.utils.KeybindingHelper.*;
|
||||
//static imports
|
||||
import static net.lizistired.cavedust.utils.MathHelper.*;
|
||||
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.KeybindingHelper.*;
|
||||
|
||||
|
||||
public class CaveDust implements ClientModInitializer {
|
||||
// logger
|
||||
//logger
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("cavedust");
|
||||
|
||||
// make class static
|
||||
//make class static
|
||||
private static CaveDust instance;
|
||||
|
||||
public static CaveDust getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public CaveDust() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// config assignment
|
||||
private static CaveDustConfig config;
|
||||
|
||||
public CaveDustConfig getConfig() {
|
||||
//config assignment
|
||||
private static net.lizistired.cavedust.CaveDustConfig config;
|
||||
public net.lizistired.cavedust.CaveDustConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static ParticleEffect WHITE_ASH_ID =
|
||||
(ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust"));
|
||||
|
||||
public static ParticleEffect WHITE_ASH_ID = (ParticleEffect) Registries.PARTICLE_TYPE.get(Identifier.of("cavedust", "cave_dust"));
|
||||
public static int PARTICLE_AMOUNT = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// config path and loading
|
||||
Path caveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
|
||||
config = new CaveDustConfig(caveDustFolder.getParent().resolve("cavedust.json"), this);
|
||||
//config path and loading
|
||||
Path CaveDustFolder = GamePaths.getConfigDirectory().resolve("cavedust");
|
||||
config = new CaveDustConfig(CaveDustFolder.getParent().resolve("cavedust.json"), this);
|
||||
config.load();
|
||||
|
||||
registerKeyBindings();
|
||||
|
||||
ParticleFactoryRegistry.getInstance().register(CaveDustServer.CAVE_DUST, CaveDustParticleFactory.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);
|
||||
}
|
||||
|
||||
private void createCaveDust(MinecraftClient client) {
|
||||
if (client.player == null) return;
|
||||
|
||||
if (keyBinding1.wasPressed()) {
|
||||
if (keyBinding1.wasPressed()){
|
||||
getConfig().toggleCaveDust();
|
||||
LOGGER.info("Toggled dust");
|
||||
client.player.sendMessage(
|
||||
Text.translatable("debug.cavedust.toggle." + config.getCaveDustEnabled()),
|
||||
false
|
||||
);
|
||||
client.player.sendMessage(Text.translatable("debug.cavedust.toggle." + config.getCaveDustEnabled()), false);
|
||||
}
|
||||
|
||||
if (keyBinding2.wasPressed()) {
|
||||
if (keyBinding2.wasPressed()){
|
||||
getConfig().load();
|
||||
LOGGER.info("Reloaded config");
|
||||
client.player.sendMessage(Text.translatable("debug.cavedust.reload"), false);
|
||||
}
|
||||
|
||||
// ensure world is not null
|
||||
//ensure world is not null
|
||||
if (client.world == null) return;
|
||||
World world = client.world;
|
||||
|
||||
double probabilityNormalized =
|
||||
normalize(config.getLowerLimit(), config.getUpperLimit(), client.player.getBlockY());
|
||||
|
||||
PARTICLE_AMOUNT = (int) (probabilityNormalized
|
||||
* config.getParticleMultiplier()
|
||||
* config.getParticleMultiplierMultiplier());
|
||||
//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++) {
|
||||
int x = (int) (client.player.getX()
|
||||
+ generateRandomDouble(-config.getDimensionWidth(), config.getDimensionWidth()));
|
||||
|
||||
int y = (int) (client.player.getEyeY()
|
||||
+ generateRandomDouble(-config.getDimensionHeight(), config.getDimensionHeight()));
|
||||
|
||||
int z = (int) (client.player.getZ()
|
||||
+ generateRandomDouble(-config.getDimensionWidth(), config.getDimensionWidth()));
|
||||
|
||||
double miniX = x + Math.random();
|
||||
double miniY = y + Math.random();
|
||||
double miniZ = z + Math.random();
|
||||
|
||||
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()));
|
||||
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(
|
||||
getConfig().getParticle(),
|
||||
miniX, miniY, miniZ,
|
||||
config.getVelocityRandomnessRandom() * 0.01,
|
||||
config.getVelocityRandomnessRandom() * 0.01,
|
||||
config.getVelocityRandomnessRandom() * 0.01
|
||||
);
|
||||
world.addParticle(config.getParticle(), miniX, miniY, miniZ, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01, config.getVelocityRandomnessRandom() * 0.01);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
LOGGER.error(String.valueOf(e));
|
||||
//getConfig().setParticleID(WHITE_ASH_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,81 +2,55 @@ 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.lizistired.cavedust.utils.MathHelper;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class CaveDustParticleFactory extends BillboardParticle {
|
||||
public class CaveDustParticleFactory extends SpriteBillboardParticle {
|
||||
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;
|
||||
CaveDustParticleFactory(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.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;
|
||||
|
||||
// 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;
|
||||
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.isAlive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.alpha -= 0.005f;
|
||||
if (this.alpha <= 0.0f) {
|
||||
if(this.alpha < 0.0f){
|
||||
this.markDead();
|
||||
return;
|
||||
}
|
||||
this.alpha -= 0.005f;
|
||||
}
|
||||
|
||||
this.updateSprite(this.spriteProvider);
|
||||
@Override
|
||||
public ParticleTextureSheet getType() {
|
||||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||
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
|
||||
) {
|
||||
public @Nullable Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||
return new CaveDustParticleFactory(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,19 @@ package net.lizistired.cavedust;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CaveDustServer implements ModInitializer {
|
||||
public static final SimpleParticleType CAVE_DUST = FabricParticleTypes.simple();
|
||||
public static final DefaultParticleType CAVE_DUST = FabricParticleTypes.simple();
|
||||
/**
|
||||
* Runs the mod initializer.
|
||||
*/
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Registry.register(Registries.PARTICLE_TYPE, Identifier.of("cavedust", "cave_dust"), CAVE_DUST);
|
||||
Registry.register(Registries.PARTICLE_TYPE, new Identifier("cavedust", "cave_dust"), CAVE_DUST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -76,13 +77,13 @@ public class ModMenuConfigScreen extends GameGui {
|
||||
|
||||
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"));
|
||||
.setTextFormat(transText::formatMaxX)
|
||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.X.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"));
|
||||
.setTextFormat(transText::formatMaxY)
|
||||
.getStyle().setTooltip(Text.translatable("menu.cavedust.Y.tooltip"));
|
||||
|
||||
addButton(new Slider(left, row += 24, 0, 10, config.getVelocityRandomness()))
|
||||
.onChange(config::setVelocityRandomness)
|
||||
@@ -105,17 +106,18 @@ public class ModMenuConfigScreen extends GameGui {
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(context);
|
||||
super.render(context, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
private String getNameOfParticle(){
|
||||
private Identifier getNameOfParticle(){
|
||||
CaveDustConfig config = CaveDust.getInstance().getConfig();
|
||||
config.load();
|
||||
try {
|
||||
return Registries.PARTICLE_TYPE.getEntry((ParticleType<?>) config.getParticleID()).getIdAsString();
|
||||
} catch (NoSuchElementException e){
|
||||
return Registries.PARTICLE_TYPE.getId((ParticleType<?>) config.getParticleID());
|
||||
} catch (NoSuchElementException e) {
|
||||
CaveDust.LOGGER.error(String.valueOf(e));
|
||||
return "null";
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.lizistired.cavedust.CaveDust.PARTICLE_AMOUNT;
|
||||
import static net.lizistired.cavedust.utils.ParticleSpawnUtil.shouldParticlesSpawn;
|
||||
|
||||
@Mixin(DebugHud.class)
|
||||
public abstract class MixinDebugScreenOverlay {
|
||||
|
||||
@Inject(
|
||||
method = "getRightText()Ljava/util/List;",
|
||||
at = @At("RETURN"),
|
||||
cancellable = true,
|
||||
require = 0
|
||||
)
|
||||
@Inject(method = "getRightText", at = @At("RETURN"))
|
||||
private void appendDebugText(CallbackInfoReturnable<List<String>> cir) {
|
||||
List<String> messages = cir.getReturnValue();
|
||||
if (messages == null) return;
|
||||
|
||||
// Evita modificar una lista inmutable/compartida
|
||||
List<String> out = new ArrayList<>(messages);
|
||||
|
||||
out.add("");
|
||||
out.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
|
||||
out.add("");
|
||||
|
||||
cir.setReturnValue(out);
|
||||
messages.add("");
|
||||
messages.add("Particle amount evaluated: " + PARTICLE_AMOUNT);
|
||||
messages.add("");
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package net.lizistired.cavedust.utils;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class KeybindingHelper {
|
||||
@@ -11,23 +10,19 @@ public class KeybindingHelper {
|
||||
public static KeyBinding keyBinding1;
|
||||
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(
|
||||
"key.cavedust.toggle",
|
||||
InputUtil.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_KP_ADD,
|
||||
CATEGORY
|
||||
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",
|
||||
InputUtil.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_KP_ENTER,
|
||||
CATEGORY
|
||||
"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.
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,14 @@ public class ParticleSpawnUtil {
|
||||
*/
|
||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
||||
|
||||
if (client.player == null) {
|
||||
timer = 0;
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// checks if the config is enabled, if the game isn't paused, if the world is valid,
|
||||
// if the dimension 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
|
||||
if (!config.getCaveDustEnabled()
|
||||
|| client.isPaused()
|
||||
|| client.world == null
|
||||
|| !client.world.getDimension().bedWorks()
|
||||
|| client.player.isSubmergedInWater()
|
||||
|| client.world.getBiome(client.player.getBlockPos()).matchesKey(LUSH_CAVES)) {
|
||||
|
||||
|| Objects.requireNonNull(client.player).isSubmergedInWater()
|
||||
|| client.world.getBiome(Objects.requireNonNull(client.player.getBlockPos())).matchesKey(LUSH_CAVES))
|
||||
{
|
||||
timer = 0;
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
@@ -45,18 +38,16 @@ public class ParticleSpawnUtil {
|
||||
World world = client.world;
|
||||
int seaLevel = world.getSeaLevel();
|
||||
|
||||
// 1.21.10: usar world directamente
|
||||
if (!world.isSkyVisible(client.player.getBlockPos())) {
|
||||
if (client.player.getBlockPos().getY() + 2 < seaLevel) {
|
||||
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
||||
if (client.player.getBlockPos().getY() + 2 < seaLevel){
|
||||
timer = timer + 1;
|
||||
if (timer > 10) {
|
||||
if (timer > 10){
|
||||
timer = 10;
|
||||
shouldParticlesSpawn = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
}
|
||||
@@ -70,27 +61,20 @@ public class ParticleSpawnUtil {
|
||||
*/
|
||||
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 dimension is valid and if the particle position isn't in lush caves
|
||||
//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().bedWorks()
|
||||
|| (client.world.getBottomY() > pos.getY())
|
||||
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES)) {
|
||||
|| client.world.getBiome(Objects.requireNonNull(pos)).matchesKey(LUSH_CAVES))
|
||||
|
||||
{
|
||||
timer = 0;
|
||||
shouldParticlesSpawn = 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()) {
|
||||
return false;
|
||||
}
|
||||
@@ -99,18 +83,16 @@ public class ParticleSpawnUtil {
|
||||
World world = client.world;
|
||||
int seaLevel = world.getSeaLevel();
|
||||
|
||||
// 1.21.10: usar world directamente
|
||||
if (!world.isSkyVisible(pos)) {
|
||||
if (pos.getY() + 2 < seaLevel) {
|
||||
if (!client.player.clientWorld.isSkyVisible(pos)) {
|
||||
if (pos.getY() + 2 < seaLevel){
|
||||
timer = timer + 1;
|
||||
if (timer > 10) {
|
||||
if (timer > 10){
|
||||
timer = 10;
|
||||
shouldParticlesSpawn = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shouldParticlesSpawn = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package net.lizistired.cavedust.utils;
|
||||
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) {
|
||||
public Text formatMaxX(AbstractSlider<Float> slider) {
|
||||
return Text.translatable("menu.cavedust.width", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatMaxHeight(AbstractSlider<Float> slider) {
|
||||
public Text formatMaxY(AbstractSlider<Float> slider) {
|
||||
return Text.translatable("menu.cavedust.height", (int)Math.floor(slider.getValue()));
|
||||
}
|
||||
public Text formatUpperLimit(AbstractSlider<Float> slider) {
|
||||
@@ -26,4 +28,12 @@ public class TranslatableTextHelper {
|
||||
public Text formatVelocityRandomness(AbstractSlider<Float> slider) {
|
||||
return Text.translatable("menu.cavedust.velocityrandomness", (int) Math.floor(slider.getValue()));
|
||||
}
|
||||
|
||||
public Text formatScaleLower(AbstractSlider<Float> slider) {
|
||||
return Text.translatable("menu.cavedust.scalelower", (int) Math.floor(slider.getValue()));
|
||||
}
|
||||
|
||||
public Text formatScaleHigher(AbstractSlider<Float> slider) {
|
||||
return Text.translatable("menu.cavedust.scalehigher", (int) Math.floor(slider.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 116 KiB |
@@ -28,6 +28,10 @@
|
||||
"menu.cavedust.superflatstatus.tooltip": "Should particles spawn on superflat worlds?",
|
||||
"menu.cavedust.particle": "Particle: ",
|
||||
"menu.cavedust.particle.tooltip": "Particle to spawn. Click to cycle.",
|
||||
"menu.cavedust.scalelower": "Minimum scale: %s",
|
||||
"menu.cavedust.scalelower.tooltip": "Minimum particle size to spawn.",
|
||||
"menu.cavedust.scalehigher": "Maximum scale: %s",
|
||||
"menu.cavedust.scalehigher.tooltip": "Maximum particle size to spawn.",
|
||||
|
||||
"key.cavedust.reload": "Reload Config",
|
||||
"key.cavedust.toggle": "Toggle Particles",
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "cavedustreforged",
|
||||
"id": "cavedust",
|
||||
"version": "${version}",
|
||||
"name": "Cave Dust Reforged",
|
||||
"name": "Cave Dust",
|
||||
"description": "Makes dust underground that scales with depth!",
|
||||
"authors": [
|
||||
"DekinDev"
|
||||
],
|
||||
"contributors": [
|
||||
"LizIsTired (Original mod)"
|
||||
"LizIsTired"
|
||||
],
|
||||
"contact": {
|
||||
"issues": "https://git.straice.com/DekinDev/cave_dust_reforged/issues",
|
||||
"sources": "https://git.straice.com/DekinDev/cave_dust_reforged",
|
||||
"homepage": "https://modrinth.com/project/cave-dust-reforged"
|
||||
"issues": "https://github.com/LizIsTired/dust/issues",
|
||||
"sources": "https://github.com/LizIsTired/dust"
|
||||
},
|
||||
"license": "MPL-2.0",
|
||||
"icon": "assets/cavedust/icon.png",
|
||||
@@ -23,7 +19,8 @@
|
||||
"net.lizistired.cavedust.CaveDust"
|
||||
],
|
||||
"main": [
|
||||
"net.lizistired.cavedust.CaveDustServer"],
|
||||
"net.lizistired.cavedust.CaveDustServer"
|
||||
],
|
||||
"modmenu": [
|
||||
"net.lizistired.cavedust.CaveDustModMenuFactory"
|
||||
]
|
||||
@@ -32,12 +29,19 @@
|
||||
"cavedust.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.17.2",
|
||||
"fabricloader": ">=0.14.5",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.21.9",
|
||||
"minecraft": "1.20.1",
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
"modmenu": ">=3.0.1"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"modmenu.discord": "https://discord.gg/4m6kQSX6bx"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user