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);
}
}
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);
}
}
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;
}
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);
}
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);
}
}
Aggregations