From e1ba0a14dc38c81d88bfc5d0ab5b2a583f420632 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sun, 29 May 2022 19:24:53 -0400 Subject: [PATCH] budding amethyst emits hex particles --- .../client/particles/ConjureParticle.java | 2 +- .../mixin/client/MixinClientLevel.java | 50 +++++++++++++++++++ Common/src/main/resources/hexplat.mixins.json | 17 +++++-- 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinClientLevel.java diff --git a/Common/src/main/java/at/petrak/hexcasting/client/particles/ConjureParticle.java b/Common/src/main/java/at/petrak/hexcasting/client/particles/ConjureParticle.java index 7269fa73..f96faf00 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/particles/ConjureParticle.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/particles/ConjureParticle.java @@ -42,7 +42,7 @@ public class ConjureParticle extends TextureSheetParticle { this.setAlpha(a / 255f * lightness); this.friction = 0.96F; - this.gravity = light ? -0.01F : 0F; + this.gravity = light && dy != 0 && dx != 0 && dz != 0 ? -0.01F : 0F; this.speedUpWhenYMotionIsBlocked = true; this.sprites = pSprites; diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinClientLevel.java b/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinClientLevel.java new file mode 100644 index 00000000..bc7a97c0 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinClientLevel.java @@ -0,0 +1,50 @@ +package at.petrak.hexcasting.mixin.client; + +import at.petrak.hexcasting.common.particles.ConjureParticleOptions; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.util.Mth; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Random; + +@Mixin(ClientLevel.class) +public abstract class MixinClientLevel { + + @Inject(method = "doAnimateTick", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;animateTick(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Ljava/util/Random;)V"), + locals = LocalCapture.CAPTURE_FAILSOFT) + public void addBuddingAmethystParticles(int baseX, int baseY, int baseZ, int range, Random rand, Block marked, BlockPos.MutableBlockPos pos, CallbackInfo ci, + int trueX, int trueY, int trueZ, BlockState state) { + ClientLevel self = ((ClientLevel) (Object) this); + + if (state.is(Blocks.BUDDING_AMETHYST)) { + ParticleOptions options = new ConjureParticleOptions(0x8932b8, true); + Vec3 center = Vec3.atCenterOf(pos); + for (Direction direction : Direction.values()) { + int dX = direction.getStepX(); + int dY = direction.getStepY(); + int dZ = direction.getStepZ(); + + int count = rand.nextInt(10) / 5; + for (int i = 0; i < count; i++) { + double pX = center.x + (dX == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dX * 0.55D); + double pY = center.y + (dY == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dY * 0.55D); + double pZ = center.z + (dZ == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dZ * 0.55D); + self.addParticle(options, pX, pY, pZ, 0, 0, 0); + } + } + } + } + +} diff --git a/Common/src/main/resources/hexplat.mixins.json b/Common/src/main/resources/hexplat.mixins.json index 33a3fd76..04b7b2e1 100644 --- a/Common/src/main/resources/hexplat.mixins.json +++ b/Common/src/main/resources/hexplat.mixins.json @@ -5,8 +5,19 @@ "refmap": "hexcasting.mixins.refmap.json", "package": "at.petrak.hexcasting.mixin", "mixins": [ - "MixinMob", "MixinRaider", "MixinReloadableServerResources", "MixinVillager", "MixinWitch", - "accessor.AccessorLivingEntity", "accessor.AccessorLootTable", "accessor.AccessorRecipeProvider", - "accessor.AccessorTagsProvider", "accessor.AccessorUseOnContext", "accessor.CriteriaTriggersAccessor" + "MixinMob", + "MixinRaider", + "MixinReloadableServerResources", + "MixinVillager", + "MixinWitch", + "accessor.AccessorLivingEntity", + "accessor.AccessorLootTable", + "accessor.AccessorRecipeProvider", + "accessor.AccessorTagsProvider", + "accessor.AccessorUseOnContext", + "accessor.CriteriaTriggersAccessor" + ], + "client": [ + "client.MixinClientLevel" ] }