Skip to content

Commit

Permalink
better arrow particle multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jul 17, 2024
1 parent 1702504 commit 07bd765
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private Material fall(Block instance) {
@ModifyConstant(method = "onDeathUpdate", constant = @Constant(intValue = 20, ordinal = 1))
private int multiplier(int constant) {
ParticleConfig config = OverflowParticles.INSTANCE.getConfigs().get(0);
if (config == null || config.getEntry().getMultiplier() == 1 || config.getId() == 28) return constant;
if (config == null || config.getEntry().getMultiplier() == 1) return constant;
return (int) (constant * config.getEntry().getMultiplier());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.polyfrost.overflowparticles.mixin.particles;

import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.EnumParticleTypes;
import org.polyfrost.overflowparticles.OverflowParticles;
import org.polyfrost.overflowparticles.config.ParticleConfig;
import org.polyfrost.overflowparticles.utils.UtilKt;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityArrow.class)
public class EntityArrowMixin {

@ModifyConstant(method = "onUpdate", constant = @Constant(intValue = 4, ordinal = 0))
private int multiplier(int constant) {
ParticleConfig config = OverflowParticles.INSTANCE.getConfigs().get(EnumParticleTypes.CRIT.getParticleID());
if (config == null || config.getEntry().getMultiplier() == 1) return constant;
return (int) (constant * config.getEntry().getMultiplier());
}

@ModifyConstant(method = "onUpdate", constant = @Constant(doubleValue = 4.0D))
private double multiplier1(double constant) {
ParticleConfig config = OverflowParticles.INSTANCE.getConfigs().get(EnumParticleTypes.CRIT.getParticleID());
if (config == null || config.getEntry().getMultiplier() == 1) return constant;
return (int) (constant * config.getEntry().getMultiplier());
}

@Inject(method = "onUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V", ordinal = 0))
private void cancel(CallbackInfo ci) {
UtilKt.setMultiplied(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class EntityParticleEmitterMixin {
@ModifyConstant(method = "onUpdate", constant = @Constant(intValue = 16))
private int multiplier(int constant) {
ParticleConfig config = OverflowParticles.INSTANCE.getConfigs().get(particleTypes.getParticleID());
if (config == null || config.getEntry().getMultiplier() == 1 || config.getId() == 28) return constant;
if (config == null || config.getEntry().getMultiplier() == 1) return constant;
return (int) (constant * config.getEntry().getMultiplier());
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/mixins.overflowparticles.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"oneconfig.ConfigSliderMixin",
"oneconfig.ModCardMixin",
"particles.BarrierMixin",
"particles.EntityArrowMixin",
"particles.EntityBreakingFXMixin",
"particles.EntityDiggingFXMixin",
"particles.EntityFootStepFXMixin",
Expand Down

0 comments on commit 07bd765

Please sign in to comment.