Search in sources :

Example 6 with VanillaParticleMessage

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

the class ItemScrollColonyAreaTP method onUseTick.

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

Example 7 with VanillaParticleMessage

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

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 8 with VanillaParticleMessage

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

the class EntityCitizen method directPlayerInteraction.

/**
 * Direct interaction actions with a player
 *
 * @param player
 * @param hand
 * @return interaction result
 */
private ActionResultType directPlayerInteraction(final PlayerEntity player, final Hand hand) {
    final ItemStack usedStack = player.getItemInHand(hand);
    if (isInteractionItem(usedStack) && interactionCooldown > 0) {
        if (!level.isClientSide()) {
            playSound(SoundEvents.VILLAGER_NO, 0.5f, (float) SoundUtils.getRandomPitch(getRandom()));
            MessageUtils.format(WARNING_INTERACTION_CANT_DO_NOW, this.getCitizenData().getName()).with(TextFormatting.RED).sendTo(player);
        }
        return null;
    }
    if (usedStack.getItem() == Items.GOLDEN_APPLE && getCitizenDiseaseHandler().isSick()) {
        usedStack.shrink(1);
        player.setItemInHand(hand, usedStack);
        if (!level.isClientSide()) {
            if (getRandom().nextInt(3) == 0) {
                getCitizenDiseaseHandler().cure();
                playSound(SoundEvents.PLAYER_LEVELUP, 1.0f, (float) SoundUtils.getRandomPitch(getRandom()));
                Network.getNetwork().sendToTrackingEntity(new VanillaParticleMessage(getX(), getY(), getZ(), ParticleTypes.HAPPY_VILLAGER), this);
            }
        }
        interactionCooldown = 20 * 60 * 5;
        return ActionResultType.CONSUME;
    }
    if (getCitizenDiseaseHandler().isSick()) {
        return null;
    }
    if (ISFOOD.test(usedStack) && usedStack.getItem() != Items.GOLDEN_APPLE) {
        if (isBaby()) {
            childFoodInteraction(usedStack, player, hand);
        } else {
            eatFoodInteraction(usedStack, player, hand);
        }
        return ActionResultType.CONSUME;
    }
    if (usedStack.getItem() == Items.BOOK && isBaby()) {
        usedStack.shrink(1);
        player.setItemInHand(hand, usedStack);
        if (!level.isClientSide()) {
            getCitizenData().getCitizenSkillHandler().addXpToSkill(Skill.Intelligence, 50, getCitizenData());
        }
        interactionCooldown = 20 * 60 * 5;
        return ActionResultType.CONSUME;
    }
    if (usedStack.getItem() == Items.CACTUS) {
        usedStack.shrink(1);
        player.setItemInHand(hand, usedStack);
        if (!level.isClientSide()) {
            MessageUtils.format(MESSAGE_INTERACTION_OUCH, getCitizenData().getName()).sendTo(player);
            getNavigation().moveAwayFromLivingEntity(player, 5, 1);
            setJumping(true);
        }
        interactionCooldown = 20 * 60 * 5;
        return ActionResultType.CONSUME;
    }
    if (usedStack.getItem() == Items.GLOWSTONE_DUST) {
        usedStack.shrink(1);
        player.setItemInHand(hand, usedStack);
        if (!level.isClientSide()) {
            addEffect(new EffectInstance(Effects.GLOWING, 20 * 60 * 3));
        }
        interactionCooldown = 20 * 60 * 3;
        return ActionResultType.CONSUME;
    }
    return null;
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) ItemStack(net.minecraft.item.ItemStack) EffectInstance(net.minecraft.potion.EffectInstance)

Example 9 with VanillaParticleMessage

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

the class ItemScrollBuff method addRegenerationWithParticles.

/**
 * Adds a regeneration potion instance and displays particles
 *
 * @param entity entity to apply to
 */
private void addRegenerationWithParticles(final LivingEntity entity) {
    entity.addEffect(new EffectInstance(Effects.REGENERATION, TICKS_SECOND * 60));
    Network.getNetwork().sendToTrackingEntity(new VanillaParticleMessage(entity.getX(), entity.getY(), entity.getZ(), ParticleTypes.HEART), entity);
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) EffectInstance(net.minecraft.potion.EffectInstance)

Example 10 with VanillaParticleMessage

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

the class ItemScrollColonyTP 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.INSTANT_EFFECT), entity);
        Network.getNetwork().sendToPlayer(new VanillaParticleMessage(entity.getX(), entity.getY(), entity.getZ(), ParticleTypes.INSTANT_EFFECT), (ServerPlayerEntity) entity);
    }
}
Also used : VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage)

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