Search in sources :

Example 1 with BlockStateParticleEffect

use of net.minecraft.particle.BlockStateParticleEffect in project EdenClient by HahaOO7.

the class BarrierDisplay method onTick.

private void onTick(ClientPlayerEntity player) {
    if (!enabled)
        return;
    if (player.getInventory().getMainHandStack().getItem() == Items.BARRIER)
        return;
    for (int i = 0; i < counter; i++) {
        BlockPos pos = player.getBlockPos().add(rand.nextGaussian() * dist, rand.nextGaussian() * dist, rand.nextGaussian() * dist);
        if (player.clientWorld.getBlockState(pos).getBlock() != Blocks.BARRIER)
            continue;
        var effect = new BlockStateParticleEffect(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.getDefaultState());
        MinecraftClient.getInstance().particleManager.addParticle(new BlockMarkerParticle.Factory().createParticle(effect, player.clientWorld, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, 0, 0, 0));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlockStateParticleEffect(net.minecraft.particle.BlockStateParticleEffect)

Example 2 with BlockStateParticleEffect

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

the class GlareFlyToDarkSpotGoal method tick.

@Override
public void tick() {
    this.runTicks++;
    EntityNavigation navigation = this.glare.getNavigation();
    double distanceToDarkSpot = this.glare.getPos().squaredDistanceTo(this.darkSpot.getX(), this.darkSpot.getY(), this.darkSpot.getZ());
    this.currentPath = navigation.findPathTo(this.darkSpot.getX(), this.darkSpot.getY(), this.darkSpot.getZ(), 0);
    if (this.currentPath != null) {
        this.glare.getNavigation().startMovingAlong(this.currentPath, this.glare.getMovementSpeed());
    }
    if (distanceToDarkSpot >= 1.0D) {
        if (this.glare.isGrumpy()) {
            this.glare.setGrumpy(false);
        }
        return;
    }
    LivingEntity owner = this.glare.getOwner();
    if (owner == null) {
        return;
    }
    this.grumpyTicks++;
    if (!this.glare.isGrumpy()) {
        this.glare.setGrumpy(true);
    }
    if (grumpyTicks == 10) {
        this.glare.playGrumpinessSound();
    }
    if (grumpyTicks % 5 == 0) {
        this.glare.playRustleSound();
    }
    if (grumpyTicks % 10 == 0) {
        this.glare.spawnParticles(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.AZALEA.getDefaultState()), 7);
    }
    this.glare.getLookControl().lookAt(owner.getPos());
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityNavigation(net.minecraft.entity.ai.pathing.EntityNavigation) BlockStateParticleEffect(net.minecraft.particle.BlockStateParticleEffect)

Example 3 with BlockStateParticleEffect

use of net.minecraft.particle.BlockStateParticleEffect in project Interdimensional by QuiltServerTools.

the class PortalBlock method randomDisplayTick.

@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
    if (random.nextInt(100) == 0) {
        world.playSound((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
    }
    for (int i = 0; i < 4; ++i) {
        double d = (double) pos.getX() + random.nextDouble();
        double e = (double) pos.getY() + random.nextDouble();
        double f = (double) pos.getZ() + random.nextDouble();
        double g = ((double) random.nextFloat() - 0.5D) * 0.5D;
        double h = ((double) random.nextFloat() - 0.5D) * 0.5D;
        double j = ((double) random.nextFloat() - 0.5D) * 0.5D;
        int k = random.nextInt(2) * 2 - 1;
        if (!world.getBlockState(pos.west()).isOf(this) && !world.getBlockState(pos.east()).isOf(this)) {
            d = (double) pos.getX() + 0.5D + 0.25D * (double) k;
            g = random.nextFloat() * 2.0F * (float) k;
        } else {
            f = (double) pos.getZ() + 0.5D + 0.25D * (double) k;
            j = random.nextFloat() * 2.0F * (float) k;
        }
        world.addParticle(new BlockStateParticleEffect(InterdimensionalPortalsClient.CUSTOMPORTALPARTICLE, state), d, e, f, g, h, j);
    }
}
Also used : BlockStateParticleEffect(net.minecraft.particle.BlockStateParticleEffect)

Example 4 with BlockStateParticleEffect

use of net.minecraft.particle.BlockStateParticleEffect in project wildmod by Osmiooo.

the class AbstractBlockMixin method onUse.

@Inject(at = @At("HEAD"), method = "onUse")
private void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
    if (world.getBlockState(hit.getBlockPos()).getBlock() == Blocks.DIRT) {
        ItemStack itemStack = player.getStackInHand(hand);
        if (itemStack.isItemEqual(Items.POTION.getDefaultStack())) {
            if (PotionUtil.getPotion(itemStack) == Potions.WATER) {
                world.setBlockState(pos, RegisterBlocks.MUD_BLOCK.getDefaultState());
                if (!world.isClient) {
                    world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1f, 1f);
                    ((ServerWorld) world).spawnParticles(new BlockStateParticleEffect(ParticleTypes.BLOCK, RegisterBlocks.MUD_BLOCK.getDefaultState()), hit.getBlockPos().getX() + 0.5, hit.getBlockPos().getY() + 0.5, hit.getBlockPos().getZ() + 0.5, 100, 0.2, 0.2, 0.2, 10);
                }
                if (player.canModifyBlocks()) {
                    if (!player.isCreative()) {
                        ItemStack removeItem = new ItemStack(Items.GLASS_BOTTLE);
                        player.setStackInHand(hand, removeItem);
                    }
                }
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) BlockStateParticleEffect(net.minecraft.particle.BlockStateParticleEffect) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

BlockStateParticleEffect (net.minecraft.particle.BlockStateParticleEffect)4 LivingEntity (net.minecraft.entity.LivingEntity)1 EntityNavigation (net.minecraft.entity.ai.pathing.EntityNavigation)1 ItemStack (net.minecraft.item.ItemStack)1 ServerWorld (net.minecraft.server.world.ServerWorld)1 BlockPos (net.minecraft.util.math.BlockPos)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1