Search in sources :

Example 1 with ItemStackParticleEffect

use of net.minecraft.particle.ItemStackParticleEffect in project Sprout by Toadstool-Studios.

the class EatFoodGoal method tick.

@Override
public void tick() {
    super.tick();
    elephant.lookAt(elephant.getCommandSource().getEntityAnchor(), foodEntity.getPos());
    ServerWorld sWorld = (ServerWorld) elephant.world;
    sWorld.spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, foodStackCopy), elephant.getX(), elephant.getY() + 0.4, elephant.getZ(), 1, 0.2, 0, 0.2, 0.05);
    if (ticker == 0) {
        elephant.sendPickup(foodEntity, 1);
        if (foodEntity.getStack().getCount() == 1) {
            foodEntity.discard();
        }
        foodEntity.getStack().decrement(1);
    }
    if (ticker == EAT_TIME - 1) {
        if (elephant.getOwner() == null) {
            PlayerEntity nearPlayer = elephant.isNearPlayer();
            if (nearPlayer != null) {
                elephant.eatFoodAroundPlayer(nearPlayer);
            }
        }
        if (elephant.getHealth() < elephant.getMaxHealth()) {
            elephant.heal(2.0F);
            sWorld.spawnParticles(ParticleTypes.HAPPY_VILLAGER, elephant.getX(), elephant.getY(), elephant.getZ(), 4, 1, 1, 1, 1.4);
        }
    }
    ticker++;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with ItemStackParticleEffect

use of net.minecraft.particle.ItemStackParticleEffect in project friends-and-foes by Faboslav.

the class GlareEntity method tryToHealWithGlowBerries.

private boolean tryToHealWithGlowBerries(PlayerEntity player, ItemStack itemStack) {
    if (this.getHealth() == this.getMaxHealth()) {
        return false;
    }
    if (this.world.isClient) {
        return true;
    }
    Item glowBerries = itemStack.getItem();
    if (glowBerries.getFoodComponent() == null) {
        return false;
    }
    this.heal((float) glowBerries.getFoodComponent().getHunger());
    if (!player.getAbilities().creativeMode) {
        itemStack.decrement(1);
    }
    this.playEatSound(itemStack);
    ItemStackParticleEffect particleEffect = new ItemStackParticleEffect(ParticleTypes.ITEM, itemStack);
    this.spawnParticles(particleEffect, 7);
    return true;
}
Also used : Item(net.minecraft.item.Item) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect)

Example 3 with ItemStackParticleEffect

use of net.minecraft.particle.ItemStackParticleEffect in project friends-and-foes by Faboslav.

the class GlareEatGlowBerriesGoal method stop.

public void stop() {
    ItemStack itemStack = this.glare.getEquippedStack(EquipmentSlot.MAINHAND);
    Item itemInHand = this.glare.getEquippedStack(EquipmentSlot.MAINHAND).getItem();
    if (!this.hasGlareEmptyHand() && itemInHand == Items.GLOW_BERRIES) {
        ItemStackParticleEffect particleEffect = new ItemStackParticleEffect(ParticleTypes.ITEM, itemStack);
        this.glare.heal(itemStack.getItem().getFoodComponent().getHunger());
        this.glare.playEatSound(itemStack);
        this.glare.spawnParticles(particleEffect, 7);
        this.glare.equipStack(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
    }
    // Reset goal
    this.isRunning = false;
    this.foodItemToPickUp = null;
    // Update entity data
    this.glare.setTicksUntilCanEatGlowBerries(this.glare.generateRandomTicksUntilCanEatGlowBerries());
    this.glare.setGrumpy(false);
}
Also used : Item(net.minecraft.item.Item) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemStackParticleEffect

use of net.minecraft.particle.ItemStackParticleEffect in project Paradise-Lost by devs-immortal.

the class PoisonDartEntity method tick.

@Override
public void tick() {
    super.tick();
    if (this.victim != null) {
        if (!this.victim.isAlive() || this.poison.ticks == 0) {
            this.destroy();
            return;
        }
        if (this.getOwner() != null)
            if (this.getOwner().world instanceof ServerWorld)
                ((ServerWorld) this.getOwner().world).spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, new ItemStack(Items.RED_DYE)), this.victim.getX(), this.victim.getBoundingBox().minY + this.victim.getHeight() * 0.8D, this.victim.getZ(), 2, 0.0D, 0.0D, 0.0D, 0.0625D);
        this.removed = false;
        this.poison.onUpdate();
        this.setInvisible(true);
        this.updatePosition(this.victim.getX(), this.victim.getY(), this.victim.getZ());
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) ItemStackParticleEffect(net.minecraft.particle.ItemStackParticleEffect) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemStackParticleEffect

use of net.minecraft.particle.ItemStackParticleEffect 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)

Aggregations

ItemStackParticleEffect (net.minecraft.particle.ItemStackParticleEffect)5 ItemStack (net.minecraft.item.ItemStack)3 Item (net.minecraft.item.Item)2 ServerWorld (net.minecraft.server.world.ServerWorld)2 Random (java.util.Random)1 ParticlesMode (net.minecraft.client.options.ParticlesMode)1 Particle (net.minecraft.client.particle.Particle)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ParticleEffect (net.minecraft.particle.ParticleEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1