-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Particles! Gotta finish the colors tho
- Loading branch information
Showing
10 changed files
with
231 additions
and
43 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/ed966a455c4849743f9bad7f661ea201bfb98470
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package dev.enjarai.blahajtotem; | ||
|
||
public record BlahajType(String name, int... colors) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/dev/enjarai/blahajtotem/mixin/ClientPlayNetworkHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dev.enjarai.blahajtotem.mixin; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import dev.enjarai.blahajtotem.particle.BlahajParticleEffect; | ||
import dev.enjarai.blahajtotem.particle.ModParticles; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.util.Hand; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Mixin(ClientPlayNetworkHandler.class) | ||
public abstract class ClientPlayNetworkHandlerMixin { | ||
@ModifyArg( | ||
method = "onEntityStatus", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/particle/ParticleManager;addEmitter(Lnet/minecraft/entity/Entity;Lnet/minecraft/particle/ParticleEffect;I)V" | ||
), | ||
index = 1 | ||
) | ||
private ParticleEffect modifyTotemParticle(ParticleEffect original, @Local Entity entity) { | ||
if (entity instanceof LivingEntity livingEntity) { | ||
var colors = BlahajParticleEffect.getColorsForShork(getActiveTotemOfUndyingForAnyEntity(livingEntity)); | ||
|
||
if (colors.length > 0) { | ||
return new BlahajParticleEffect(ModParticles.BLAHAJ_OF_UNDYING, colors); | ||
} | ||
} | ||
|
||
return original; | ||
} | ||
|
||
@Unique | ||
private static ItemStack getActiveTotemOfUndyingForAnyEntity(LivingEntity entity) { | ||
for (Hand hand : Hand.values()) { | ||
ItemStack itemStack = entity.getStackInHand(hand); | ||
if (itemStack.isOf(Items.TOTEM_OF_UNDYING)) { | ||
return itemStack; | ||
} | ||
} | ||
|
||
return new ItemStack(Items.TOTEM_OF_UNDYING); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/dev/enjarai/blahajtotem/particle/BlahajParticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.enjarai.blahajtotem.particle; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.particle.AnimatedParticle; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleFactory; | ||
import net.minecraft.client.particle.SpriteProvider; | ||
import net.minecraft.client.world.ClientWorld; | ||
|
||
public class BlahajParticle extends AnimatedParticle { | ||
protected BlahajParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, int[] colors, SpriteProvider spriteProvider) { | ||
super(world, x, y, z, spriteProvider, 1.25F); | ||
this.velocityMultiplier = 0.6F; | ||
this.velocityX = velocityX; | ||
this.velocityY = velocityY; | ||
this.velocityZ = velocityZ; | ||
this.scale *= 0.75F; | ||
this.maxAge = 60 + this.random.nextInt(12); | ||
this.setSpriteForAge(spriteProvider); | ||
|
||
if (colors.length >= 1) { | ||
this.setColor(colors[this.random.nextInt(colors.length)]); | ||
} | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static class Factory implements ParticleFactory<BlahajParticleEffect> { | ||
private final SpriteProvider spriteProvider; | ||
|
||
public Factory(SpriteProvider spriteProvider) { | ||
this.spriteProvider = spriteProvider; | ||
} | ||
|
||
public Particle createParticle(BlahajParticleEffect effect, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) { | ||
return new BlahajParticle(clientWorld, d, e, f, g, h, i, effect.colors(), this.spriteProvider); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/dev/enjarai/blahajtotem/particle/BlahajParticleEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.enjarai.blahajtotem.particle; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import dev.enjarai.blahajtotem.BlahajTotem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.particle.ParticleType; | ||
import net.minecraft.registry.Registries; | ||
|
||
public record BlahajParticleEffect(ParticleType<BlahajParticleEffect> type, int[] colors) implements ParticleEffect { | ||
@SuppressWarnings("deprecation") | ||
public static final ParticleEffect.Factory<BlahajParticleEffect> PARAMETERS_FACTORY = new ParticleEffect.Factory<>() { | ||
@Override | ||
public BlahajParticleEffect read(ParticleType<BlahajParticleEffect> type, StringReader reader) throws CommandSyntaxException { | ||
return new BlahajParticleEffect(type, new int[0]); // This doesn't actually need to work with commands, so dummy impl it is | ||
} | ||
|
||
@Override | ||
public BlahajParticleEffect read(ParticleType<BlahajParticleEffect> type, PacketByteBuf buf) { | ||
return new BlahajParticleEffect(type, buf.readIntArray()); | ||
} | ||
}; | ||
|
||
@Override | ||
public ParticleType<?> getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public void write(PacketByteBuf buf) { | ||
buf.writeIntArray(colors); | ||
} | ||
|
||
@Override | ||
public String asString() { | ||
return Registries.PARTICLE_TYPE.getId(getType()) + ""; | ||
} | ||
|
||
public static int[] getColorsForShork(ItemStack shorkStack) { | ||
var type = BlahajTotem.getShorkType(shorkStack); | ||
if (type != null) { | ||
return type.colors(); | ||
} | ||
return new int[0]; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/dev/enjarai/blahajtotem/particle/ModParticles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.enjarai.blahajtotem.particle; | ||
|
||
import dev.enjarai.blahajtotem.BlahajTotem; | ||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; | ||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; | ||
import net.minecraft.particle.ParticleType; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
|
||
public class ModParticles { | ||
public static final ParticleType<BlahajParticleEffect> BLAHAJ_OF_UNDYING = FabricParticleTypes.complex(BlahajParticleEffect.PARAMETERS_FACTORY); | ||
|
||
public static void register() { | ||
Registry.register(Registries.PARTICLE_TYPE, BlahajTotem.id("blahaj_of_undying"), BLAHAJ_OF_UNDYING); | ||
ParticleFactoryRegistry.getInstance().register(BLAHAJ_OF_UNDYING, BlahajParticle.Factory::new); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/assets/blahaj_totem/particles/blahaj_of_undying.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"textures": [ | ||
"minecraft:glitter_7", | ||
"minecraft:glitter_6", | ||
"minecraft:glitter_5", | ||
"minecraft:glitter_4", | ||
"minecraft:glitter_3", | ||
"minecraft:glitter_2", | ||
"minecraft:glitter_1", | ||
"minecraft:glitter_0" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
}, | ||
"client": [ | ||
"BipedEntityModelMixin", | ||
"ClientPlayNetworkHandlerMixin", | ||
"PlayerEntityRendererMixin" | ||
] | ||
} |