|
| 1 | +package cqb13.Numby.utils; |
| 2 | + |
| 3 | +import meteordevelopment.meteorclient.MeteorClient; |
| 4 | +import meteordevelopment.meteorclient.events.entity.EntityAddedEvent; |
| 5 | +import meteordevelopment.meteorclient.events.world.TickEvent; |
| 6 | +import meteordevelopment.orbit.EventHandler; |
| 7 | +import net.minecraft.client.network.AbstractClientPlayerEntity; |
| 8 | +import net.minecraft.client.option.Perspective; |
| 9 | +import net.minecraft.entity.EntityType; |
| 10 | +import net.minecraft.entity.LightningEntity; |
| 11 | +import net.minecraft.entity.player.PlayerEntity; |
| 12 | +import net.minecraft.particle.ParticleEffect; |
| 13 | +import net.minecraft.particle.ParticleTypes; |
| 14 | +import net.minecraft.sound.SoundCategory; |
| 15 | +import net.minecraft.sound.SoundEvents; |
| 16 | +import org.jetbrains.annotations.NotNull; |
| 17 | + |
| 18 | +import java.util.*; |
| 19 | + |
| 20 | +import static meteordevelopment.meteorclient.MeteorClient.mc; |
| 21 | + |
| 22 | +public class PlayerParticle { |
| 23 | + |
| 24 | + public Map<UUID, ParticleEffect> playerEffects; |
| 25 | + private boolean lightningHasStruck = false; |
| 26 | + private Random random; |
| 27 | + public List<UUID> lightningUUIDs; |
| 28 | + |
| 29 | + public PlayerParticle() { |
| 30 | + setup(); |
| 31 | + MeteorClient.EVENT_BUS.subscribe(this); |
| 32 | + } |
| 33 | + |
| 34 | + private void setup() { |
| 35 | + this.random = new Random(); |
| 36 | + this.playerEffects = new HashMap<>(); |
| 37 | + this.lightningUUIDs = new ArrayList<>(); |
| 38 | + // --- Lighting --- |
| 39 | + //cqb13 |
| 40 | + this.lightningUUIDs.add(UUID.fromString("408fb01f-3ac5-4fa7-aa65-9fba051c9c51")); |
| 41 | + //IcatIcatI |
| 42 | + this.lightningUUIDs.add(UUID.fromString("ff8a62c2-b2d7-4334-8794-e0af3b9ad8c2")); |
| 43 | + // Number81 |
| 44 | + this.lightningUUIDs.add(UUID.fromString("bc48b56d-d2e2-4838-ae6d-bd26559c1267")); |
| 45 | + |
| 46 | + // --- Particle --- |
| 47 | + //cqb13 |
| 48 | + this.playerEffects.put(UUID.fromString("408fb01f-3ac5-4fa7-aa65-9fba051c9c51"), ParticleTypes.NAUTILUS); |
| 49 | + //IcatIcatI |
| 50 | + this.playerEffects.put(UUID.fromString("ff8a62c2-b2d7-4334-8794-e0af3b9ad8c2"), ParticleTypes.NAUTILUS); |
| 51 | + // Number81 |
| 52 | + this.playerEffects.put(UUID.fromString("bc48b56d-d2e2-4838-ae6d-bd26559c1267"), ParticleTypes.HAPPY_VILLAGER); |
| 53 | + |
| 54 | + |
| 55 | + } |
| 56 | + |
| 57 | + @EventHandler |
| 58 | + private void onPostTickEvent(TickEvent.Post post) { |
| 59 | + if (mc.world == null || mc.player == null) { |
| 60 | + return; |
| 61 | + } |
| 62 | + |
| 63 | + for (AbstractClientPlayerEntity player : mc.world.getPlayers()) { |
| 64 | + var uuid = player.getUuid(); |
| 65 | + |
| 66 | + if (uuid.equals(mc.player.getUuid()) && mc.options.getPerspective() == Perspective.FIRST_PERSON) { |
| 67 | + continue; |
| 68 | + } |
| 69 | + |
| 70 | + var effect = this.playerEffects.get(uuid); |
| 71 | + if (effect == null) { |
| 72 | + continue; |
| 73 | + } |
| 74 | + |
| 75 | + this.displayParticleEffect(player, effect); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + private void displayParticleEffect(PlayerEntity player, ParticleEffect effect) { |
| 80 | + assert mc.player != null; |
| 81 | + assert mc.world != null; |
| 82 | + |
| 83 | + if (effect == ParticleTypes.SOUL) { |
| 84 | + double x = player.getX() + (this.random.nextDouble() - 0.5D) * (double) player.getWidth(); |
| 85 | + double y = player.getY() + 0.1D; |
| 86 | + double z = player.getZ() + (this.random.nextDouble() - 0.5D) * (double) player.getHeight(); |
| 87 | + double velocityX = player.getVelocity().getX() * -0.2D; |
| 88 | + double velocityY = 0.1D; |
| 89 | + double velocityZ = player.getVelocity().getZ() * -0.2D; |
| 90 | + mc.world.addParticle(effect, x, y, z, velocityX, velocityY, velocityZ); |
| 91 | + } else if (effect == ParticleTypes.HEART) { |
| 92 | + if (mc.player.age % 2 == 0) { |
| 93 | + var particleX = player.getParticleX(1.0D); |
| 94 | + var particleY = player.getRandomBodyY() + 0.5D; |
| 95 | + var particleZ = player.getParticleZ(1.0D); |
| 96 | + double velocityX = this.random.nextGaussian() * 0.02D; |
| 97 | + double velocityY = this.random.nextGaussian() * 0.02D; |
| 98 | + double velocityZ = this.random.nextGaussian() * 0.02D; |
| 99 | + mc.world.addParticle(effect, particleX, particleY, particleZ, velocityX, velocityY, velocityZ); |
| 100 | + } |
| 101 | + } else { |
| 102 | + for (int i = 0; i < 2; ++i) { |
| 103 | + double particleX = player.getParticleX(0.5D); |
| 104 | + double particleY = player.getRandomBodyY() - 0.25D; |
| 105 | + double particleZ = player.getParticleZ(0.5D); |
| 106 | + double velocityX = (this.random.nextDouble() - 0.5D) * 2.0D; |
| 107 | + double velocityY = -this.random.nextDouble(); |
| 108 | + double velocityZ = (this.random.nextDouble() - 0.5D) * 2.0D; |
| 109 | + mc.world.addParticle(effect, particleX, particleY, particleZ, velocityX, velocityY, velocityZ); |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + @EventHandler |
| 115 | + private void onEntityAdded(@NotNull EntityAddedEvent event) { |
| 116 | + assert mc.world != null; |
| 117 | + |
| 118 | + if (!this.lightningUUIDs.contains(event.entity.getUuid())) { |
| 119 | + return; |
| 120 | + } |
| 121 | + |
| 122 | + double x = event.entity.getX(); |
| 123 | + double y = event.entity.getY(); |
| 124 | + double z = event.entity.getZ(); |
| 125 | + |
| 126 | + var effect = new LightningEntity(EntityType.LIGHTNING_BOLT, mc.world); |
| 127 | + effect.setPosition(x, y, z); |
| 128 | + effect.refreshPositionAfterTeleport(x, y, z); |
| 129 | + |
| 130 | + mc.world.addEntity(effect.getId(), effect); |
| 131 | + |
| 132 | + if (!this.lightningHasStruck) { |
| 133 | + mc.world.playSound(mc.player, x, y, z, SoundEvents.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.16000001F); |
| 134 | + mc.world.playSound(mc.player, x, y, z, SoundEvents.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.1F); |
| 135 | + this.lightningHasStruck = true; |
| 136 | + } |
| 137 | + } |
| 138 | +} |
0 commit comments