Skip to content

Commit

Permalink
fix sprinting soul sand particles
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Dec 4, 2024
1 parent bbc5537 commit e58b654
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 25 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.8-SNAPSHOT"
id "fabric-loom" version "1.9-SNAPSHOT"
}

version = project.mod_version
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx2G
org.gradle.parallel = true

# Mod Properties
mod_version = 0.7.8+1.21.3
mod_version = 0.7.9+1.21.4
maven_group = ru.pinkgoosik
archives_base_name = visuality

Expand All @@ -12,10 +12,10 @@ modrinth_id = rI0hvYcd
curseforge_id = 521126

# Dependencies | Check these on https://fabricmc.net/develop
minecraft_version = 1.21.3
yarn_mappings = 1.21.3+build.2
fabric_loader = 0.16.8
fabric_api = 0.107.0+1.21.3
minecraft_version = 1.21.4
yarn_mappings = 1.21.4+build.1
fabric_loader = 0.16.9
fabric_api = 0.110.5+1.21.4

cloth_config = 16.0.141
modmenu_version = 12.0.0-beta.1
modmenu_version = 13.0.0-beta.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 0 additions & 15 deletions src/main/java/visuality/mixin/BlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemConvertible;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
Expand All @@ -26,20 +25,6 @@ public BlockMixin(Settings settings) {
super(settings);
}

@Inject(method = "onLandedUpon", at = @At("TAIL"))
void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance, CallbackInfo ci) {
if(VisualityMod.config.soulEnabled) {
if(state.isIn(BlockTags.WITHER_SUMMON_BASE_BLOCKS)) {
for(int i = 0; i <= world.random.nextInt(5) + 1; i++) {
double x = entity.getX();
double y = entity.getY() + 0.1;
double z = entity.getZ();
ParticleUtils.add(world, VisualityParticles.SOUL, x, y, z);
}
}
}
}

@Inject(method = "randomDisplayTick", at = @At("TAIL"))
void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo ci) {
if(VisualityMod.config.soulEnabled && state.isIn(BlockTags.WITHER_SUMMON_BASE_BLOCKS)) {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/visuality/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package visuality.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import visuality.VisualityMod;
import visuality.registry.VisualityParticles;
import visuality.util.ParticleUtils;

@Mixin(Entity.class)
abstract class EntityMixin {

@Shadow
public abstract World getWorld();

@Inject(method = "spawnSprintingParticles", at = @At("TAIL"))
void spawnSprintingParticles(CallbackInfo ci, @Local BlockState state) {
Entity entity = Entity.class.cast(this);
World world = getWorld();

if(world.isClient() && VisualityMod.config.soulEnabled && state.isIn(BlockTags.WITHER_SUMMON_BASE_BLOCKS)) {
if(world.random.nextInt(5) == 0) {
double x = entity.getX();
double y = entity.getY() + 0.1;
double z = entity.getZ();
ParticleUtils.add(world, VisualityParticles.SOUL, x, y, z);
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/visuality/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity {
@Unique
LivingEntity self = LivingEntity.class.cast(this);

@Shadow
public abstract boolean isAlive();

@Unique
int ticksDelay = 0;

public LivingEntityMixin(EntityType<?> type, World world) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/visuality/particle/WaterCircleParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void tick() {
}

@Override
public void buildGeometry(VertexConsumer buffer, Camera camera, float ticks) {
public void render(VertexConsumer buffer, Camera camera, float ticks) {
Vec3d vec3 = camera.getPos();
float x = (float) (MathHelper.lerp(ticks, this.prevPosX, this.x) - vec3.getX());
float y = (float) (MathHelper.lerp(ticks, this.prevPosY, this.y) - vec3.getY());
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/visuality.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"CreeperEntityMixin",
"LivingEntityMixin",
"SlimeEntityMixin",
"BlockMixin"
"BlockMixin",
"EntityMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit e58b654

Please sign in to comment.