Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew buildMod
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/Merged
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "io.github.pacifistmc.forgix" version "1.2.6"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ private void buildCategory() {
.setSaveConsumer(config::setWatermarkLifetime)
.build()
);
general.addEntry(entryBuilder
.startIntSlider(new TranslatableText("text.footprintparticle.option.lifeTimeAcc")
,config.getLifeTimeAcc()
,0
,10)
.setDefaultValue(0)
.setTooltip(new TranslatableText("text.footprintparticle.option.lifeTimeAcc.@Tooltip"))
.setSaveConsumer(config::setLifeTimeAcc)
.build()
);
general.addEntry(entryBuilder
.startIntSlider(new TranslatableText("text.footprintparticle.option.footprintAlpha")
,(int) (config.getFootprintAlpha() * 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class FPPConfig implements ConfigData {
private int waterSplashLevel = 1;
private List<String> customPrint = DEF_CUSTOM_PRINT;
private float hardnessGate = 0.7f;
private int lifeTimeAcc = 0;

public int isEnable() {return enableMod;}
public float getSecPerPrint() {return secPerPrint;}
Expand All @@ -129,6 +130,7 @@ public class FPPConfig implements ConfigData {
public int getFootprintSize() {return footprintSize;}
public List<String> getCustomPrint() {return customPrint;}
public float getHardnessGate() {return hardnessGate;}
public int getLifeTimeAcc() {return lifeTimeAcc;}

public void setEnableMod(int isEnable) {enableMod = isEnable;}
public void setSecPerPrint(float sec) {secPerPrint = sec;}
Expand All @@ -155,4 +157,5 @@ public class FPPConfig implements ConfigData {
public void setFootprintSize(int footprintSize) {this.footprintSize = footprintSize;}
public void setCustomPrint(List<String> customPrint) {this.customPrint = customPrint;}
public void setHardnessGate(float gate) {this.hardnessGate = gate;}
public void setLifeTimeAcc(int lifeTimeAcc) {this.lifeTimeAcc = lifeTimeAcc;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static com.rimo.footprintparticle.FPPClient.CONFIG;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity {
public LivingEntityMixin(EntityType<?> type, World world) {
Expand All @@ -32,7 +34,7 @@ public LivingEntityMixin(EntityType<?> type, World world) {
@Unique
private boolean fpp$wasOnGround = true;
@Unique
private int fpp$wetTimer = FPPClient.CONFIG.getWetDuration() * 20;
private int fpp$wetTimer = CONFIG.getWetDuration() * 20;

@Inject(method = "jump", at = @At("TAIL"))
protected void jump(CallbackInfo ci) {
Expand All @@ -56,14 +58,14 @@ public void tick(CallbackInfo ci) {

if (this.isTouchingWaterOrRain()) {
fpp$wetTimer = 0;
} else if (fpp$wetTimer <= FPPClient.CONFIG.getWetDuration() * 20){
} else if (fpp$wetTimer <= CONFIG.getWetDuration() * 20){
fpp$wetTimer++;
}

// Swim Pop
if (this.isSwimming() &&
(FPPClient.CONFIG.getSwimPopLevel() == 2 ||
(FPPClient.CONFIG.getSwimPopLevel() == 1 && this.isPlayer()))) {
(CONFIG.getSwimPopLevel() == 2 ||
(CONFIG.getSwimPopLevel() == 1 && this.isPlayer()))) {
float range = Util.getEntityScale((LivingEntity) (Object) this);
this.getWorld().addParticle(
ParticleTypes.BUBBLE,
Expand All @@ -79,17 +81,17 @@ public void tick(CallbackInfo ci) {

@Unique
public void fpp$footprintGenerator() {
if (FPPClient.CONFIG.isEnable() == 0 ||
(FPPClient.CONFIG.isEnable() == 1 && !this.isPlayer()))
if (CONFIG.isEnable() == 0 ||
(CONFIG.isEnable() == 1 && !this.isPlayer()))
return;
if (FPPClient.CONFIG.getExcludedMobs().contains(EntityType.getId(this.getType()).toString()))
if (CONFIG.getExcludedMobs().contains(EntityType.getId(this.getType()).toString()))
return;
if (!FPPClient.CONFIG.getCanGenWhenInvisible() && this.isInvisible())
if (! CONFIG.getCanGenWhenInvisible() && this.isInvisible())
return;

// Set Interval
fpp$timer = this.isSprinting() ? (int) (FPPClient.CONFIG.getSecPerPrint() * 13.33f) : (int) (FPPClient.CONFIG.getSecPerPrint() * 20);
for (String stream : FPPClient.CONFIG.getMobInterval()) {
fpp$timer = this.isSprinting() ? (int) (CONFIG.getSecPerPrint() * 13.33f) : (int) (CONFIG.getSecPerPrint() * 20);
for (String stream : CONFIG.getMobInterval()) {
String[] str = stream.split(",");
if (str[0].equals(EntityType.getId(this.getType()).toString())) {
try {
Expand All @@ -103,15 +105,15 @@ public void tick(CallbackInfo ci) {

// Fix pos...
var px = this.getX();
var py = this.getY() + 0.01f + FPPClient.CONFIG.getPrintHeight();
var py = this.getY() + 0.01f + CONFIG.getPrintHeight();
var pz = this.getZ();
var scale = Util.getEntityScale((LivingEntity) (Object) this);

// Horizontal Offset
// Front and back
var side = Math.random() > 0.5f ? 1 : -1;
var hOffset = 0.0625f;
for (String stream : FPPClient.CONFIG.getHorseLikeMobs()) {
for (String stream : CONFIG.getHorseLikeMobs()) {
String[] str = stream.split(",");
if (str[0].equals(EntityType.getId(this.getType()).toString())) {
hOffset = 0.75f;
Expand All @@ -130,7 +132,7 @@ public void tick(CallbackInfo ci) {
// Left and right
side = Math.random() > 0.5f ? 1 : -1;
hOffset = 0.125f;
for (String stream : FPPClient.CONFIG.getSpiderLikeMobs()) {
for (String stream : CONFIG.getSpiderLikeMobs()) {
String[] str = stream.split(",");
if (str[0].equals(EntityType.getId(this.getType()).toString())) {
hOffset = 0.9f;
Expand All @@ -156,7 +158,7 @@ public void tick(CallbackInfo ci) {
// Fix height by blocks if in...
try {
var block = this.getWorld().getBlockState(pos);
for (String str : FPPClient.CONFIG.getBlockHeight()) {
for (String str : CONFIG.getBlockHeight()) {
String[] str2 = str.split(",");
if (str2[0].charAt(0) == '#') {
for (TagKey<Block> tag : block.streamTags().toList()) {
Expand All @@ -173,8 +175,8 @@ public void tick(CallbackInfo ci) {

// Snow Dust
if (block.isOf(Blocks.SNOW) &&
(FPPClient.CONFIG.getSnowDustLevel() == 2 ||
(FPPClient.CONFIG.getSnowDustLevel() == 1 && this.isPlayer()))) {
(CONFIG.getSnowDustLevel() == 2 ||
(CONFIG.getSnowDustLevel() == 1 && this.isPlayer()))) {
int i = this.isSprinting() ? 4 : 2;
int v = this.isSprinting() ? 3 : 10;
while (--i >= 0) {
Expand Down Expand Up @@ -204,17 +206,17 @@ public void tick(CallbackInfo ci) {
if (canGen) { // footprint
FootprintParticleType footprint = FPPClient.FOOTPRINT.get();
this.getWorld().addParticle(footprint.setData((LivingEntity) (Object) this), px, py, pz, dx, 0, dz);
} else if (fpp$wetTimer <= FPPClient.CONFIG.getWetDuration() * 20) { // waterprint (gen when footprint not gen)
} else if (fpp$wetTimer <= CONFIG.getWetDuration() * 20) { // waterprint (gen when footprint not gen)
WatermarkParticleType watermark = FPPClient.WATERMARK.get();
var i = Math.random() > 0.5f ? 1 : -1;
this.getWorld().addParticle(watermark.setData((LivingEntity) (Object) this), px, py, pz, dx * i, fpp$wetTimer, dz * i); // push timer to calc alpha
}
// water splash (gen whatever print gen)
if (fpp$wetTimer <= FPPClient.CONFIG.getWetDuration() * 20 &&
(FPPClient.CONFIG.getWaterSplashLevel() == 2 ||
(FPPClient.CONFIG.getWaterSplashLevel() == 1 && this.isPlayer()))) {
if (fpp$wetTimer <= CONFIG.getWetDuration() * 20 &&
(CONFIG.getWaterSplashLevel() == 2 ||
(CONFIG.getWaterSplashLevel() == 1 && this.isPlayer()))) {
float range = Util.getEntityScale((LivingEntity) (Object) this);
int i = (int)((this.isSprinting() ? 18 : 10) * Math.max((0.7f - (float) fpp$wetTimer / (FPPClient.CONFIG.getWetDuration() * 20)), 0));
int i = (int)((this.isSprinting() ? 18 : 10) * Math.max((0.7f - (float) fpp$wetTimer / (CONFIG.getWetDuration() * 20)), 0));
int v = this.isSprinting() ? 3 : 6;
while (--i > 0) {
this.getWorld().addParticle(
Expand All @@ -233,21 +235,21 @@ public void tick(CallbackInfo ci) {
@Unique
private boolean fpp$isPrintCanGen(BlockPos pos) {
var block = this.getWorld().getBlockState(pos);
var canGen = FPPClient.CONFIG.getApplyBlocks().contains(block.getBlock().getRegistryEntry().getKey().get().getValue().toString());
var canGen = CONFIG.getApplyBlocks().contains(block.getBlock().getRegistryEntry().getKey().get().getValue().toString());
if (!canGen) {
for (TagKey<Block> tag : block.streamTags().toList()) {
canGen = FPPClient.CONFIG.getApplyBlocks().contains("#" + tag.id().toString());
canGen = CONFIG.getApplyBlocks().contains("#" + tag.id().toString());
if (canGen)
break;
}
if (!canGen) {
// Hardness Filter. See on https://minecraft.fandom.com/wiki/Breaking#Blocks_by_hardness
canGen = MathHelper.abs(block.getBlock().getHardness()) < FPPClient.CONFIG.getHardnessGate();
canGen = CONFIG.getLifeTimeAcc() > 0 && MathHelper.abs(block.getBlock().getHardness()) < CONFIG.getHardnessGate();
if (canGen) {
canGen = !FPPClient.CONFIG.getExcludedBlocks().contains(block.getBlock().getRegistryEntry().getKey().get().getValue().toString());
canGen = ! CONFIG.getExcludedBlocks().contains(block.getBlock().getRegistryEntry().getKey().get().getValue().toString());
if (canGen) {
for (TagKey<Block> tag : block.streamTags().toList()) {
canGen = !FPPClient.CONFIG.getExcludedBlocks().contains("#" + tag.id().toString());
canGen = ! CONFIG.getExcludedBlocks().contains("#" + tag.id().toString());
if (!canGen)
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
import net.minecraft.entity.EntityType;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.*;
import net.minecraft.world.Heightmap;

import java.util.List;

public class FootprintParticle extends SpriteBillboardParticle {
protected float startAlpha;
private final BlockPos pos;

protected FootprintParticle(ClientWorld clientWorld, double x, double y, double z, double vx, double vy, double vz, SpriteProvider spriteProvider, FootprintParticleType parameters, String defName) {
super(clientWorld, x, y, z, vx, vy, vz);
pos = new BlockPos(MathHelper.floor(this.x), MathHelper.floor(this.y - 0.02f), MathHelper.floor(this.z));

this.setVelocity(0, 0, 0);
this.setAlpha(FPPClient.CONFIG.getFootprintAlpha());
Expand Down Expand Up @@ -57,7 +60,10 @@ public void tick() {
if (this.age > this.maxAge / 2)
this.alpha -= this.startAlpha / this.maxAge * 2;

if (this.age++ >= this.maxAge || this.world.isAir(new BlockPos(MathHelper.floor(this.x), MathHelper.floor(this.y - 0.02f), MathHelper.floor(this.z))))
if (this.world.isRaining() && this.world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, pos).getY() <= this.y)
this.age += FPPClient.CONFIG.getLifeTimeAcc();

if (this.age++ >= this.maxAge || this.world.isAir(pos))
this.markDead();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
"text.footprintparticle.option.customPrint": "Custom Print Texture",
"text.footprintparticle.option.customPrint.@Tooltip": "Set a specific texture for a specific mob.\nFormat: §9§omodid:mobid,fileName1,fileName2,...§r\n§5file§r must be a PNG and located at\n§oassets/footprintparticle/textures/particle§r\nin your resourcepack.\nMeanwhile, you need to register it at\n§oassets/footprintparticle/particles/footprint.json§r or\n§oassets/footprintparticle/particles/watermark.json§r\nif you want to replace watermark at same time.\nMore see in wiki.",
"text.footprintparticle.option.hardnessGate": "Hardness Gate",
"text.footprintparticle.option.hardnessGate.@Tooltip": "Block which hardness smaller than gate will gen print.\nYou can set 0 to disable all blocks (whitelist), or 999 to allow all blocks (blacklist)\nDefault is 0.7"
"text.footprintparticle.option.hardnessGate.@Tooltip": "Block which hardness smaller than gate will gen print.\nYou can set 0 to disable all blocks (whitelist), or 999 to allow all blocks (blacklist)\nDefault is 0.7",
"text.footprintparticle.option.lifeTimeAcc": "Lifetime reduce when Rain",
"text.footprintparticle.option.lifeTimeAcc.@Tooltip": "How fast do particles disappear during rain compared to normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"text.footprintparticle.option.customPrint.@Tooltip": "为特定生物设置特定的脚印纹理。\n格式: §9§omodid:mobid,fileName1,fileName2,...§r\n§5file§r必须是一张PNG图片且放置于资源包中的\n§oassets/footprintparticle/textures/particle§r下。\n同时,你需要在\n§oassets/footprintparticle/particles/footprint.json§r或\n§oassets/footprintparticle/particles/watermark.json§r\n中注册你的纹理。\n更多信息请查阅wiki。",
"text.footprintparticle.option.hardnessGate": "方块硬度门限",
"text.footprintparticle.option.hardnessGate.@Tooltip": "硬度小于该值的方块将生成脚印。\n你可以将该值设为0来禁用所有方块,或者设为999来启用所有方块\n默认值为0.7",
"text.footprintparticle.option.lifeTimeAcc": "下雨时时间缩短",
"text.footprintparticle.option.lifeTimeAcc.@Tooltip": "下雨时粒子的消失速度会比正常快多少",

"modmenu.descriptionTranslation.footprintparticle": "一个简单地为生物和玩家添加脚印粒子的模组。"
}
8 changes: 4 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.johnrengelman.shadow" version "8.1.1"
}

architectury {
Expand Down Expand Up @@ -53,18 +53,18 @@ shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "fabric"
archiveClassifier.set "fabric"
}

jar {
classifier "dev"
archiveClassifier.set "dev"
}

sourcesJar {
Expand Down
8 changes: 4 additions & 4 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.johnrengelman.shadow" version "8.1.1"
}

architectury {
Expand Down Expand Up @@ -51,17 +51,17 @@ shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "forge"
archiveClassifier.set "forge"
}

jar {
classifier "dev"
archiveClassifier.set "dev"
}

sourcesJar {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ minecraft_version=1.18.2
enabled_platforms=fabric,forge

archives_base_name=footprintparticle
mod_version=0.5.3-mc1.18.2
mod_version=0.5.4-mc1.18.2
maven_group=com.rimo

architectury_version=4.11.93
cloth_config_version=6.4.90
pehkui_version=3.7.8
architectury_version=4.12.94
cloth_config_version=6.5.133
pehkui_version=3.8.3

fabric_loader_version=0.14.11
fabric_api_version=0.67.1+1.18.2
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists