Search in sources :

Example 6 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project MCDungeonsWeapons by chronosacaria.

the class PersistentProjectileEntityMixin method changeParticles.

@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V", ordinal = 0))
private void changeParticles(World world, ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
    ItemStack sourceStack = dataTracker.get(ORIGIN_STACK);
    double d = posContext.x;
    double e = posContext.y;
    double g = posContext.z;
    // Check if the source bow has a preferred particle to display
    if (!sourceStack.isEmpty() && sourceStack.getItem() instanceof McdwBow) {
        McdwBow bow = (McdwBow) sourceStack.getItem();
        ParticleEffect bowParticles = bow.getArrowParticles();
        if (bowParticles != null) {
            this.world.addParticle(bowParticles, this.getX() + d * (double) iteration / 4.0D, this.getY() + e * (double) iteration / 4.0D, this.getZ() + g * (double) iteration / 4.0D, -d, -e + 0.2D, -g);
            return;
        }
    }
    // Display default crit particles
    this.world.addParticle(ParticleTypes.CRIT, this.getX() + d * (double) iteration / 4.0D, this.getY() + e * (double) iteration / 4.0D, this.getZ() + g * (double) iteration / 4.0D, -d, -e + 0.2D, -g);
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) McdwBow(chronosacaria.mcdw.bases.McdwBow) ItemStack(net.minecraft.item.ItemStack) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 7 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project visuality by PinkGoosik.

the class HitParticleRegistry method reload.

public static void reload() {
    ENTRIES.clear();
    ArrayList<Entry> entries = new ArrayList<>();
    VisualityMod.CONFIG.getStringsArray("hit_particles_entries").forEach(entry -> {
        String[] args = entry.split("\\|");
        EntityType<?> entity = getEntityFromString(args[0]);
        ParticleEffect particle = getParticleFromString(args[1]);
        if (entity != null && particle != null) {
            entries.add(new Entry(entity, particle));
        }
    });
    ENTRIES.addAll(entries);
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) ArrayList(java.util.ArrayList)

Example 8 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project meteor-client by MeteorDevelopment.

the class ParticleTypeListSetting method parseImpl.

@Override
protected List<ParticleType<?>> parseImpl(String str) {
    String[] values = str.split(",");
    List<ParticleType<?>> particleTypes = new ArrayList<>(values.length);
    try {
        for (String value : values) {
            ParticleType<?> particleType = parseId(Registry.PARTICLE_TYPE, value);
            if (particleType instanceof ParticleEffect)
                particleTypes.add(particleType);
        }
    } catch (Exception ignored) {
    }
    return particleTypes;
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) ArrayList(java.util.ArrayList) ParticleType(net.minecraft.particle.ParticleType) NbtString(net.minecraft.nbt.NbtString)

Example 9 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project Biome-Makeover by Lemonszz.

the class S2C_DoLightningBottleParticles method receive.

@Override
public void receive(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
    final boolean doBottleBreak = buf.readBoolean();
    BlockPos pos = buf.readBlockPos();
    client.execute(() -> {
        Vec3d dir = Vec3d.ofBottomCenter(pos);
        Random random = client.world.random;
        World world = client.world;
        if (doBottleBreak) {
            for (int i = 0; i < 8; ++i) {
                world.addParticle(new ItemStackParticleEffect(ParticleTypes.ITEM, new ItemStack(BMItems.LIGHTNING_BOTTLE)), dir.x, dir.y, dir.z, random.nextGaussian() * 0.15D, random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D);
            }
            world.playSound(null, pos, SoundEvents.ENTITY_SPLASH_POTION_BREAK, SoundCategory.NEUTRAL, 1.0F, random.nextFloat() * 0.1F + 0.9F);
        }
        ParticleEffect particleEffect = BMEffects.LIGHTNING_SPARK;
        ParticlesMode mode = MinecraftClient.getInstance().options.particles;
        int particleCount = mode == ParticlesMode.ALL ? 100 : mode == ParticlesMode.DECREASED ? 50 : 10;
        for (int i = 0; i < particleCount; ++i) {
            double direction = random.nextDouble() * 4.0D;
            double ac = random.nextDouble() * Math.PI * 2.0D;
            double xVel = (Math.cos(ac) * direction) * 0.1D;
            double yVel = 0.01D + random.nextDouble() * 0.5D;
            double zVel = (Math.sin(ac) * direction) * 0.1D;
            Particle particle = ClientUtil.spawnParticle(particleEffect, particleEffect.getType().shouldAlwaysSpawn(), true, dir.x + xVel * 0.01D, dir.y + 0.3D, dir.z + zVel * 0.01D, xVel, yVel, zVel);
            if (particle != null) {
                particle.move((float) direction);
            }
        }
    });
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect) Particle(net.minecraft.client.particle.Particle) Random(java.util.Random) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect) BlockPos(net.minecraft.util.math.BlockPos) ParticlesMode(net.minecraft.client.options.ParticlesMode) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d)

Example 10 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project Client by MatHax.

the class ParticleTypeListSetting method parseImpl.

@Override
protected List<ParticleType<?>> parseImpl(String str) {
    String[] values = str.split(",");
    List<ParticleType<?>> particleTypes = new ArrayList<>(values.length);
    try {
        for (String value : values) {
            ParticleType<?> particleType = parseId(Registry.PARTICLE_TYPE, value);
            if (particleType instanceof ParticleEffect)
                particleTypes.add(particleType);
        }
    } catch (Exception ignored) {
    }
    return particleTypes;
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) ArrayList(java.util.ArrayList) ParticleType(net.minecraft.particle.ParticleType) NbtString(net.minecraft.nbt.NbtString)

Aggregations

ParticleEffect (net.minecraft.particle.ParticleEffect)12 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 Entity (net.minecraft.entity.Entity)3 Box (net.minecraft.util.math.Box)3 Vec3d (net.minecraft.util.math.Vec3d)3 Particle (net.minecraft.client.particle.Particle)2 ItemStack (net.minecraft.item.ItemStack)2 NbtString (net.minecraft.nbt.NbtString)2 ItemStackParticleEffect (net.minecraft.particle.ItemStackParticleEffect)2 ParticleType (net.minecraft.particle.ParticleType)2 McdwBow (chronosacaria.mcdw.bases.McdwBow)1 ParticlesMode (net.minecraft.client.options.ParticlesMode)1 LivingEntity (net.minecraft.entity.LivingEntity)1 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)1 ItemFrameEntity (net.minecraft.entity.decoration.ItemFrameEntity)1 Fluid (net.minecraft.fluid.Fluid)1 ParticleS2CPacket (net.minecraft.network.packet.s2c.play.ParticleS2CPacket)1 DustParticleEffect (net.minecraft.particle.DustParticleEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1