use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractBuildingGuards method setRallyLocation.
@Override
public void setRallyLocation(final ILocation location) {
boolean reduceSaturation = false;
if (rallyLocation != null && location == null) {
reduceSaturation = true;
}
rallyLocation = location;
for (final ICitizenData iCitizenData : getAllAssignedCitizen()) {
if (reduceSaturation && iCitizenData.getSaturation() < LOW_SATURATION) {
// In addition to the scaled saturation reduction during rallying, stopping a rally
// will - if only LOW_SATURATION is left - set the saturation level to 0.
iCitizenData.decreaseSaturation(LOW_SATURATION);
}
}
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractBuildingGuards method startPatrolNext.
/**
* Starts the patrol to the next point
*/
private void startPatrolNext() {
getNextPatrolTarget(true);
patrolTimer = 5;
for (final ICitizenData curguard : getAllAssignedCitizen()) {
if (curguard.getEntity().isPresent()) {
if (curguard.getEntity().get().getCitizenJobHandler().getColonyJob() instanceof AbstractJobGuard) {
((AbstractEntityAIGuard<?, ?>) curguard.getEntity().get().getCitizenJobHandler().getColonyJob().getWorkerAI()).setNextPatrolTarget(lastPatrolPoint);
}
}
}
arrivedAtPatrol.clear();
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractBuildingGuards method serializeToView.
@Override
public void serializeToView(@NotNull final PacketBuffer buf) {
super.serializeToView(buf);
buf.writeInt(patrolTargets.size());
for (final BlockPos pos : patrolTargets) {
buf.writeBlockPos(pos);
}
buf.writeInt(this.getAllAssignedCitizen().size());
for (final ICitizenData citizen : this.getAllAssignedCitizen()) {
buf.writeInt(citizen.getId());
}
if (minePos != null) {
buf.writeBoolean(true);
buf.writeBlockPos(minePos);
} else {
buf.writeBoolean(false);
}
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AdjustSkillCitizenMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony) {
final ICitizenData citizenData = colony.getCitizenManager().getCivilian(citizenId);
if (citizenData == null) {
Log.getLogger().warn("AdjustSkillCitizenMessage citizenData is null");
return;
}
final Optional<AbstractEntityCitizen> optionalEntityCitizen = citizenData.getEntity();
if (!optionalEntityCitizen.isPresent()) {
Log.getLogger().warn("AdjustSkillCitizenMessage entity citizen is null");
return;
}
final PlayerEntity player = ctxIn.getSender();
if (player == null) {
return;
}
final boolean isCreative = player.isCreative();
if (!isCreative) {
Log.getLogger().warn("AdjustSkillCitizenMessage player must be creative.");
return;
}
citizenData.getCitizenSkillHandler().incrementLevel(skill, quantity);
citizenData.markDirty();
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class RecallSingleCitizenMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final IBuilding building) {
final ICitizenData citizenData = colony.getCitizenManager().getCivilian(citizenId);
citizenData.setLastPosition(building.getPosition());
Optional<AbstractEntityCitizen> optionalEntityCitizen = citizenData.getEntity();
if (!optionalEntityCitizen.isPresent()) {
citizenData.updateEntityIfNecessary();
optionalEntityCitizen = citizenData.getEntity();
}
if (optionalEntityCitizen.isPresent() && optionalEntityCitizen.get().getTicksExisted() == 0) {
citizenData.updateEntityIfNecessary();
}
final BlockPos loc = building.getID();
if (optionalEntityCitizen.isPresent() && !TeleportHelper.teleportCitizen(optionalEntityCitizen.get(), colony.getWorld(), loc)) {
final PlayerEntity player = ctxIn.getSender();
if (player == null) {
return;
}
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.workerhuts.recallFail");
}
}
Aggregations