use of com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage in project minecolonies by Minecolonies.
the class EntityAIWorkPupil method study.
/**
* Sit down a bit and study. If has paper consume it.
*
* @return next state to go to.
*/
private IAIState study() {
if (studyPos == null) {
return DECIDE;
}
if (walkToBlock(studyPos)) {
return getState();
}
if (!world.getLoadedEntitiesOfClass(EntityCitizen.class, new AxisAlignedBB(studyPos.getX(), studyPos.getY(), studyPos.getZ(), studyPos.getX(), studyPos.getY(), studyPos.getZ())).isEmpty()) {
studyPos = null;
return DECIDE;
}
if (sittingTicks == 0 || worker.vehicle == null) {
// Sit for 60-120 seconds.
maxSittingTicks = worker.getRandom().nextInt(120 / 2) + 60;
SittingEntity.sitDown(studyPos, worker, maxSittingTicks * 20);
}
final int slot = InventoryUtils.findFirstSlotInItemHandlerWith(worker.getInventoryCitizen(), PAPER);
if (slot != -1) {
worker.setItemSlot(EquipmentSlotType.MAINHAND, worker.getInventoryCitizen().getStackInSlot(slot));
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 1, 0), ParticleTypes.ENCHANT, sittingTicks), worker);
} else {
worker.setItemSlot(EquipmentSlotType.MAINHAND, ItemStack.EMPTY);
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 1, 0), ParticleTypes.HAPPY_VILLAGER, sittingTicks), worker);
}
sittingTicks++;
if (sittingTicks < maxSittingTicks) {
return getState();
}
worker.setItemSlot(EquipmentSlotType.MAINHAND, ItemStack.EMPTY);
if (worker.vehicle != null) {
worker.stopRiding();
worker.setPos(worker.getX(), worker.getY() + 1, worker.getZ());
}
if (slot != -1) {
InventoryUtils.reduceStackInItemHandler(worker.getInventoryCitizen(), new ItemStack(Items.PAPER), 1);
final double bonus = 50.0 * (1 + worker.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(TEACHING));
worker.getCitizenData().getCitizenSkillHandler().addXpToSkill(Skill.Intelligence, bonus, worker.getCitizenData());
}
worker.decreaseSaturationForContinuousAction();
maxSittingTicks = 0;
sittingTicks = 0;
return null;
}
use of com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage in project minecolonies by Minecolonies.
the class EntityAIWorkHealer method freeCure.
/**
* Do free cure magic.
*
* @return the next state to go to.
*/
private IAIState freeCure() {
if (currentPatient == null) {
return DECIDE;
}
final ICitizenData data = getOwnBuilding().getColony().getCitizenManager().getCivilian(currentPatient.getId());
if (data == null || !data.getEntity().isPresent() || !data.getEntity().get().getCitizenDiseaseHandler().isSick()) {
currentPatient = null;
return DECIDE;
}
final EntityCitizen citizen = (EntityCitizen) data.getEntity().get();
if (walkToBlock(citizen.blockPosition())) {
progressTicks = 0;
return FREE_CURE;
}
progressTicks++;
if (progressTicks < MAX_PROGRESS_TICKS) {
Network.getNetwork().sendToTrackingEntity(new StreamParticleEffectMessage(worker.position().add(0, 2, 0), citizen.position(), ParticleTypes.HEART, progressTicks % MAX_PROGRESS_TICKS, MAX_PROGRESS_TICKS), worker);
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 2, 0), ParticleTypes.HEART, progressTicks), worker);
return getState();
}
progressTicks = 0;
worker.getCitizenExperienceHandler().addExperience(BASE_XP_GAIN);
citizen.getCitizenDiseaseHandler().cure();
currentPatient.setState(Patient.PatientState.TREATED);
currentPatient = null;
return DECIDE;
}
use of com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage in project minecolonies by Minecolonies.
the class EntityAISickTask method applyCure.
/**
* Actual action of eating.
*
* @return the next state to go to, if successful idle.
*/
private DiseaseState applyCure() {
if (checkForCure() != APPLY_CURE) {
return CHECK_FOR_CURE;
}
final List<ItemStack> list = IColonyManager.getInstance().getCompatibilityManager().getDisease(citizen.getCitizenDiseaseHandler().getDisease()).getCure();
citizen.setItemInHand(Hand.MAIN_HAND, list.get(citizen.getRandom().nextInt(list.size())));
citizen.swing(Hand.MAIN_HAND);
citizen.playSound(SoundEvents.NOTE_BLOCK_HARP, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPentatonic(citizen.getRandom()));
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(citizen.position().add(0, 2, 0), ParticleTypes.HAPPY_VILLAGER, waitingTicks), citizen);
waitingTicks++;
if (waitingTicks < REQUIRED_TIME_TO_CURE) {
return APPLY_CURE;
}
cure();
return IDLE;
}
use of com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage in project minecolonies by Minecolonies.
the class EntityAIWorkHealer method wander.
/**
* Wander around in the colony from citizen to citizen.
*
* @return the next state to go to.
*/
private IAIState wander() {
if (remotePatient == null || !remotePatient.getEntity().isPresent()) {
return DECIDE;
}
final EntityCitizen citizen = (EntityCitizen) remotePatient.getEntity().get();
if (walkToBlock(remotePatient.getEntity().get().blockPosition())) {
return getState();
}
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(remotePatient.getEntity().get().position(), ParticleTypes.HEART, 1), worker);
citizen.heal(citizen.getMaxHealth() - citizen.getHealth() - 5 - getOwnBuilding().getBuildingLevel());
citizen.markDirty();
worker.getCitizenExperienceHandler().addExperience(1);
remotePatient = null;
return START_WORKING;
}
use of com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage in project minecolonies by Minecolonies.
the class EntityAIWorkEnchanter method enchant.
/**
* Actually do the enchanting. Making some great effects for some time and then apply a random enchantment. Reduce own levels depending on the found enchantment.
*
* @return the next state to go to.
*/
private IAIState enchant() {
// this assumes that the only empty-output (pure loot table) recipes are for ancient tome -> enchanted book
currentRecipeStorage = getOwnBuilding().getFirstModuleOccurance(BuildingEnchanter.CraftingModule.class).getFirstFulfillableRecipe(ItemStackUtils::isEmpty, 1, false);
if (currentRecipeStorage == null) {
progressTicks = 0;
return DECIDE;
}
if (progressTicks++ < MAX_ENCHANTMENT_TICKS / getOwnBuilding().getBuildingLevel()) {
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 2, 0), ParticleTypes.ENCHANT, progressTicks), worker);
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 1.5, 0), ParticleTypes.ENCHANT, progressTicks), worker);
Network.getNetwork().sendToTrackingEntity(new CircleParticleEffectMessage(worker.position().add(0, 1, 0), ParticleTypes.ENCHANT, progressTicks), worker);
if (worker.getRandom().nextBoolean()) {
worker.swing(Hand.MAIN_HAND);
} else {
worker.swing(Hand.OFF_HAND);
}
return getState();
}
final ICitizenData data = worker.getCitizenData();
if (data != null) {
final List<ItemStack> loot = currentRecipeStorage.fullfillRecipeAndCopy(getLootContext(), getOwnBuilding().getHandlers());
if (loot != null) {
final int enchantmentLevel = loot.stream().mapToInt(EntityAIWorkEnchanter::getEnchantedBookLevel).max().orElse(0);
// Decrement mana.
data.getCitizenSkillHandler().incrementLevel(Skill.Mana, -enchantmentLevel);
incrementActionsDoneAndDecSaturation();
}
}
currentRecipeStorage = null;
progressTicks = 0;
return IDLE;
}
Aggregations