Skip to content

Commit

Permalink
update 1.20.1_fabric with 3.0.0 features
Browse files Browse the repository at this point in the history
  • Loading branch information
LizIsTired committed Jun 3, 2024
1 parent 4f3e80b commit 31611ea
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 95 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down
16 changes: 8 additions & 8 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.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.24
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.11

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

# Dependencies
fabric_version=0.90.7+1.20.2
clothconfig_version=12.0.10
modmenu_version=8.0.0-beta.2
kirin_version=1.16.0+1.20.2
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
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 18 additions & 7 deletions 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/master/subprojects/plugins/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/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# 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"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
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=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
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, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand All @@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/net/lizistired/cavedust/CaveDust.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.lizistired.cavedust;

//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.ParticleTypes;
Expand Down Expand Up @@ -39,8 +40,7 @@ public CaveDust() {
public net.lizistired.cavedust.CaveDustConfig getConfig() {
return config;
}

public static int WHITE_ASH_ID = Registries.PARTICLE_TYPE.getRawId(ParticleTypes.WHITE_ASH);
public static int WHITE_ASH_ID = Registries.PARTICLE_TYPE.getRawId(CaveDustServer.CAVE_DUST);
public static int PARTICLE_AMOUNT = 0;


Expand All @@ -51,7 +51,7 @@ public void onInitializeClient() {
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
ClientTickEvents.END_CLIENT_TICK.register(this::createCaveDust);
}
Expand All @@ -78,20 +78,23 @@ private void createCaveDust(MinecraftClient client) {

for (int i = 0; i < PARTICLE_AMOUNT; i++) {
try {
int x = (int) (client.player.getPos().getX() + (int) generateRandomDouble(config.getDimensionsX() * -1, config.getDimensionsX()));
int y = (int) (client.player.getPos().getY() + (int) generateRandomDouble(config.getDimensionsY() * -1, config.getDimensionsY()));
int z = (int) (client.player.getPos().getZ() + (int) generateRandomDouble(config.getDimensionsZ() * -1, config.getDimensionsZ()));
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.addParticle(config.getParticle(), x, y, z, config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom(), config.getVelocityRandomnessRandom());
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);
//getConfig().setParticleID(WHITE_ASH_ID);
}
}
}
Expand Down
56 changes: 23 additions & 33 deletions src/main/java/net/lizistired/cavedust/CaveDustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ public class CaveDustConfig extends JsonFile {
private transient final net.lizistired.cavedust.CaveDust CaveDust;


private int dimensionX = 5;
private int dimensionY = 5;
private int dimensionZ = 5;
private int velocityRandomness = 1;
private int dimensionWidth = 10;
private int dimensionHeight = 10;
private int velocityRandomness = 0;

private boolean caveDustEnabled = true;
private boolean seaLevelCheck = true;
Expand All @@ -37,40 +36,29 @@ public CaveDustConfig(Path file, net.lizistired.cavedust.CaveDust caveDust) {
this.CaveDust = caveDust;
}

public float setDimensionsX(float size){
if (this.dimensionX != size) {
this.dimensionX = (int)size;
public float setDimensionWidth(float size){
if (this.dimensionWidth != size) {
this.dimensionWidth = (int)size;
save();
}
return getDimensionsX();
return getDimensionWidth();
}

public float setDimensionsY(float size){
if (this.dimensionY != size) {
this.dimensionY = (int)size;
public float setDimensionHeight(float size){
if (this.dimensionHeight != size) {
this.dimensionHeight = (int)size;
save();
}
return getDimensionsY();
return getDimensionHeight();
}

public float setDimensionsZ(float size){
if (this.dimensionZ != size) {
this.dimensionZ = (int)size;
save();
}
return getDimensionsZ();
}

public float getDimensionsX(){
return dimensionX;
public float getDimensionWidth(){
return dimensionWidth;
}

public float getDimensionsY(){
return dimensionY;
}

public float getDimensionsZ(){
return dimensionZ;
public float getDimensionHeight(){
return dimensionHeight;
}

public float setUpperLimit(float upperLimit){
Expand Down Expand Up @@ -145,10 +133,11 @@ public ParticleEffect getParticle(){
try {
return (ParticleEffect) Registries.PARTICLE_TYPE.get(new Identifier(Registries.PARTICLE_TYPE.getEntry(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
} catch (ClassCastException e) {
MinecraftClient.getInstance().player.sendMessage(Text.literal("Issue loading particle, defaulting to white ash particle!"), false);
setParticleID(WHITE_ASH_ID);
MinecraftClient.getInstance().player.sendMessage(Text.translatable("debug.cavedust.particleerror"), true);
LOGGER.error("Cannot spawn particle, check config.");
iterateParticle();
save();
return ParticleTypes.WHITE_ASH;
return getParticle();
}
}

Expand Down Expand Up @@ -210,16 +199,17 @@ public int getParticleID(){
}

public void resetConfig(){
dimensionX = 5;
dimensionY = 5;
dimensionZ = 5;
dimensionWidth = 10;
dimensionHeight = 10;

upperLimit = 64;
lowerLimit = -64;

particleMultiplier = 1;
particleMultiplierMultiplier = 10;

velocityRandomness = 0;

seaLevelCheck = true;
caveDustEnabled = true;
particleID = WHITE_ASH_ID;
Expand Down
54 changes: 54 additions & 0 deletions src/main/java/net/lizistired/cavedust/CaveDustParticleFactory.java
Original file line number Diff line number Diff line change
@@ -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.DefaultParticleType;

public class CaveDustParticleFactory extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
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.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<DefaultParticleType> {
private final SpriteProvider spriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}


public Particle createParticle(DefaultParticleType type, 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);
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/net/lizistired/cavedust/CaveDustServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.lizistired.cavedust;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class CaveDustServer implements ModInitializer {
public static final DefaultParticleType CAVE_DUST = FabricParticleTypes.simple();
/**
* Runs the mod initializer.
*/
@Override
public void onInitialize() {
Registry.register(Registries.PARTICLE_TYPE, new Identifier("cavedust", "cave_dust"), CAVE_DUST);
}
}
Loading

0 comments on commit 31611ea

Please sign in to comment.