Search in sources :

Example 1 with VanillaParticleMessage

use of com.minecolonies.coremod.network.messages.client.VanillaParticleMessage in project minecolonies by ldtteam.

the class ItemScrollBuff method onItemUseSuccess.

@Override
protected ItemStack onItemUseSuccess(final ItemStack itemStack, final World world, final ServerPlayerEntity player) {
    if (world.random.nextInt(8) > 0) {
        for (final LivingEntity entity : world.getLoadedEntitiesOfClass(EntityCitizen.class, player.getBoundingBox().inflate(15, 2, 15))) {
            addRegenerationWithParticles(entity);
        }
        addRegenerationWithParticles(player);
        // Send to player additionally, as players do not track themselves
        Network.getNetwork().sendToPlayer(new VanillaParticleMessage(player.getX(), player.getY(), player.getZ(), ParticleTypes.HEART), player);
        SoundUtils.playSoundForPlayer(player, SoundEvents.PLAYER_LEVELUP, 0.2f, 1.0f);
    } else {
        player.displayClientMessage(new TranslationTextComponent("minecolonies.scroll.failed" + (world.random.nextInt(FAIL_RESPONSES_TOTAL) + 1)).setStyle(Style.EMPTY.withColor(TextFormatting.GOLD)), true);
        player.addEffect(new EffectInstance(Effects.BLINDNESS, TICKS_SECOND * 10));
        SoundUtils.playSoundForPlayer(player, SoundEvents.TOTEM_USE, 0.04f, 1.0f);
    }
    itemStack.shrink(1);
    return itemStack;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) EffectInstance(net.minecraft.potion.EffectInstance)

Example 2 with VanillaParticleMessage

use of com.minecolonies.coremod.network.messages.client.VanillaParticleMessage in project minecolonies by ldtteam.

the class ItemScrollGuardHelp method onUseTick.

@Override
public void onUseTick(World worldIn, LivingEntity entity, ItemStack stack, int count) {
    if (!worldIn.isClientSide && worldIn.getGameTime() % 5 == 0) {
        Network.getNetwork().sendToTrackingEntity(new VanillaParticleMessage(entity.getX(), entity.getY(), entity.getZ(), ParticleTypes.ENCHANT), entity);
        Network.getNetwork().sendToPlayer(new VanillaParticleMessage(entity.getX(), entity.getY(), entity.getZ(), ParticleTypes.ENCHANT), (ServerPlayerEntity) entity);
    }
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage)

Example 3 with VanillaParticleMessage

use of com.minecolonies.coremod.network.messages.client.VanillaParticleMessage in project minecolonies by Minecolonies.

the class WindowTownHallColonyManage method onCreate.

/**
 * On create button
 */
public void onCreate() {
    final PlayerEntity player = Minecraft.getInstance().player;
    final ITextComponent colonyName = new TranslationTextComponent(DEFAULT_COLONY_NAME, player.getName());
    new VanillaParticleMessage(pos.getX(), pos.getY(), pos.getZ(), ParticleTypes.DRAGON_BREATH).onExecute(null, false);
    player.level.playSound(player, new BlockPos(Minecraft.getInstance().player.position()), SoundEvents.CAMPFIRE_CRACKLE, SoundCategory.AMBIENT, 2.5f, 0.8f);
    Network.getNetwork().sendToServer(new CreateColonyMessage(pos, colonyName.getString()));
    close();
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) CreateColonyMessage(com.minecolonies.coremod.network.messages.client.CreateColonyMessage) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 4 with VanillaParticleMessage

use of com.minecolonies.coremod.network.messages.client.VanillaParticleMessage in project minecolonies by Minecolonies.

the class CitizenSkillHandler method levelUp.

@Override
public void levelUp(final ICitizenData data) {
    // Show level-up particles
    if (data.getEntity().isPresent()) {
        final AbstractEntityCitizen citizen = data.getEntity().get();
        citizen.playSound(SoundEvents.PLAYER_LEVELUP, 1.0f, (float) SoundUtils.getRandomPitch(citizen.getRandom()));
        Network.getNetwork().sendToTrackingEntity(new VanillaParticleMessage(citizen.getX(), citizen.getY(), citizen.getZ(), ParticleTypes.HAPPY_VILLAGER), data.getEntity().get());
    }
    if (data.getJob() != null) {
        data.getJob().onLevelUp();
    }
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen)

Example 5 with VanillaParticleMessage

use of com.minecolonies.coremod.network.messages.client.VanillaParticleMessage in project minecolonies by Minecolonies.

the class ItemScrollBuff method onItemUseSuccess.

@Override
protected ItemStack onItemUseSuccess(final ItemStack itemStack, final World world, final ServerPlayerEntity player) {
    if (world.random.nextInt(8) > 0) {
        for (final LivingEntity entity : world.getLoadedEntitiesOfClass(EntityCitizen.class, player.getBoundingBox().inflate(15, 2, 15))) {
            addRegenerationWithParticles(entity);
        }
        addRegenerationWithParticles(player);
        // Send to player additionally, as players do not track themselves
        Network.getNetwork().sendToPlayer(new VanillaParticleMessage(player.getX(), player.getY(), player.getZ(), ParticleTypes.HEART), player);
        SoundUtils.playSoundForPlayer(player, SoundEvents.PLAYER_LEVELUP, 0.2f, 1.0f);
    } else {
        player.displayClientMessage(new TranslationTextComponent("minecolonies.scroll.failed" + (world.random.nextInt(FAIL_RESPONSES_TOTAL) + 1)).setStyle(Style.EMPTY.withColor(TextFormatting.GOLD)), true);
        player.addEffect(new EffectInstance(Effects.BLINDNESS, TICKS_SECOND * 10));
        SoundUtils.playSoundForPlayer(player, SoundEvents.TOTEM_USE, 0.04f, 1.0f);
    }
    itemStack.shrink(1);
    return itemStack;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) EffectInstance(net.minecraft.potion.EffectInstance)

Aggregations

VanillaParticleMessage (com.minecolonies.coremod.network.messages.client.VanillaParticleMessage)15 EffectInstance (net.minecraft.potion.EffectInstance)5 LivingEntity (net.minecraft.entity.LivingEntity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 CreateColonyMessage (com.minecolonies.coremod.network.messages.client.CreateColonyMessage)2 Entity (net.minecraft.entity.Entity)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 ItemStack (net.minecraft.item.ItemStack)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1