Search in sources :

Example 1 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project beebuddy by queenofthebees.

the class BeeEntityMixin method tameEffect.

@Override
protected void tameEffect(byte status, CallbackInfo cbi) {
    if (status == 6 || status == 7) {
        ParticleEffect p = status == 7 ? ParticleTypes.HEART : ParticleTypes.SMOKE;
        for (int i = 0; i < 7; i++) {
            double d = this.random.nextGaussian() * 0.02;
            double e = this.random.nextGaussian() * 0.02;
            double f = this.random.nextGaussian() * 0.02;
            this.world.addParticle(p, this.getParticleX(1.0D), this.getRandomBodyY() + 0.5D, this.getParticleZ(1.0D), d, e, f);
        }
    }
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect)

Example 2 with ParticleEffect

use of net.minecraft.particle.ParticleEffect in project ArmorStandEditor by Patbox.

the class ServerPlayerEntityMixin method showInvisible.

@Inject(method = "playerTick", at = @At("HEAD"))
private void showInvisible(CallbackInfo ci) {
    try {
        if (ConfigManager.getConfig().configData.holdingToolSpawnsParticles) {
            tickTimer++;
            if (tickTimer > 10 && this.getMainHandStack().getItem() == ConfigManager.getConfig().armorStandTool) {
                tickTimer = 0;
                List<ArmorStandEntity> armorStands = this.world.getEntitiesByClass(ArmorStandEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect = new DustParticleEffect(0.8f, 0.2f, 0.2f, 1f);
                for (ArmorStandEntity armorStand : armorStands) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect, false, armorStand.getX(), armorStand.getY() + armorStand.getHeight() / 2, armorStand.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
                List<ItemFrameEntity> itemFrames = this.world.getEntitiesByClass(ItemFrameEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect2 = new DustParticleEffect(0.2f, 0.8f, 0.2f, 1f);
                for (ItemFrameEntity itemFrame : itemFrames) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect2, false, itemFrame.getX(), itemFrame.getY() + itemFrame.getHeight() / 2, itemFrame.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DustParticleEffect(net.minecraft.particle.DustParticleEffect) ParticleEffect(net.minecraft.particle.ParticleEffect) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) DustParticleEffect(net.minecraft.particle.DustParticleEffect) Box(net.minecraft.util.math.Box) ParticleS2CPacket(net.minecraft.network.packet.s2c.play.ParticleS2CPacket) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with ParticleEffect

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

the class S2C_DoEntityParticle method receive.

@Override
public void receive(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
    int entityID = buf.readInt();
    Entity entity = client.world.getEntityById(entityID);
    if (entity == null)
        return;
    int particleID = buf.readInt();
    ParticleEffect particleType = (ParticleEffect) Registry.PARTICLE_TYPE.get(particleID);
    if (!(particleType instanceof ParticleEffect))
        return;
    int count = buf.readInt();
    float offset = buf.readFloat();
    float velX = buf.readFloat();
    float velY = buf.readFloat();
    float velZ = buf.readFloat();
    client.execute(() -> {
        Random random = client.world.random;
        for (int i = 0; i < count; ++i) {
            Box bb = entity.getBoundingBox();
            double xx = RandomUtil.randomRange(bb.minX - offset, bb.maxX + offset);
            double yy = RandomUtil.randomRange(bb.minY - offset, bb.maxY + offset);
            double zz = RandomUtil.randomRange(bb.minZ - offset, bb.maxZ + offset);
            client.world.addParticle(particleType, xx, yy, zz, velX, velY, velZ);
        }
    });
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) Entity(net.minecraft.entity.Entity) Random(java.util.Random) Box(net.minecraft.util.math.Box)

Example 4 with ParticleEffect

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

the class S2C_DoEntityParticleCentered method receive.

@Override
public void receive(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
    int entityID = buf.readInt();
    Entity entity = client.world.getEntityById(entityID);
    if (entity == null)
        return;
    int particleID = buf.readInt();
    ParticleEffect particleType = (ParticleEffect) Registry.PARTICLE_TYPE.get(particleID);
    if (!(particleType instanceof ParticleEffect))
        return;
    int count = buf.readInt();
    boolean varyY = buf.readBoolean();
    float velX = buf.readFloat();
    float velY = buf.readFloat();
    float velZ = buf.readFloat();
    client.execute(() -> {
        for (int i = 0; i < count; ++i) {
            Box bb = entity.getBoundingBox();
            double xx = bb.getCenter().x;
            double zz = bb.getCenter().z;
            double yy;
            if (varyY)
                yy = RandomUtil.randomRange(bb.minY, bb.maxY);
            else
                yy = bb.minY;
            client.world.addParticle(particleType, xx, yy, zz, velX, velY, velZ);
        }
    });
}
Also used : ParticleEffect(net.minecraft.particle.ParticleEffect) Entity(net.minecraft.entity.Entity) Box(net.minecraft.util.math.Box)

Example 5 with ParticleEffect

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

the class S2C_DoLightningEntityParticles method receive.

@Override
public void receive(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
    int entityID = buf.readInt();
    int count = buf.readInt();
    client.execute(() -> {
        Entity e = client.world.getEntityById(entityID);
        if (e == null || !(e instanceof LivingEntity))
            return;
        Random random = ((LivingEntity) e).getRandom();
        Vec3d entityPos = e.getPos();
        ParticleEffect particleEffect = BMEffects.LIGHTNING_SPARK;
        for (int i = 0; i < count; ++i) {
            double speed = random.nextDouble() * 1.0D;
            double ac = random.nextDouble() * Math.PI * 2.0D;
            double xVel = ((Math.cos(ac) * speed) * 0.1D) / 10F;
            double yVel = 0.01D + random.nextDouble() * 0.5D;
            double zVel = ((Math.sin(ac) * speed) * 0.1D) / 10F;
            Particle particle = ClientUtil.spawnParticle(particleEffect, particleEffect.getType().shouldAlwaysSpawn(), true, entityPos.x + xVel * 0.01D, entityPos.y + 0.3D, entityPos.z + zVel * 0.01D, xVel, yVel, zVel);
            if (particle != null) {
                particle.move((float) speed);
            }
        }
    });
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ParticleEffect(net.minecraft.particle.ParticleEffect) Particle(net.minecraft.client.particle.Particle) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) Random(java.util.Random) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

ParticleEffect (net.minecraft.particle.ParticleEffect)11 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 Entity (net.minecraft.entity.Entity)3 Box (net.minecraft.util.math.Box)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 Vec3d (net.minecraft.util.math.Vec3d)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 ParticleS2CPacket (net.minecraft.network.packet.s2c.play.ParticleS2CPacket)1 DustParticleEffect (net.minecraft.particle.DustParticleEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1