Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/version/1.12' into feature/nasty…
Browse files Browse the repository at this point in the history
…-barbs
  • Loading branch information
Raycoms committed Sep 8, 2018
2 parents 8b5a6ce + 50b123a commit 92f1043
Show file tree
Hide file tree
Showing 10 changed files with 884 additions and 661 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/minecolonies/coremod/colony/Colony.java
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,15 @@ public boolean isValidAttackingGuard(final EntityCitizen entity)
return AttackingPlayer.isValidAttack(entity, this);
}

/**
* Check if the colony is currently under attack by another player.
* @return true if so.
*/
public boolean isColonyUnderAttack()
{
return !attackingPlayers.isEmpty();
}

/**
* Getter for the colony team color.
* @return the TextFormatting enum color.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ else if (this == KNIGHT)
/**
* The job of the guard, Any possible {@link GuardJob}.
*/
private GuardJob job = GuardJob.KNIGHT;
private GuardJob job = null;

/**
* The list of manual patrol targets.
Expand Down Expand Up @@ -220,7 +220,7 @@ public void readFromNBT(@NotNull final NBTTagCompound compound)
super.readFromNBT(compound);
task = GuardTask.values()[compound.getInteger(NBT_TASK)];
final int jobId = compound.getInteger(NBT_JOB);
job = jobId == -1 ? GuardJob.KNIGHT : GuardJob.values()[jobId];
job = jobId == -1 ? null : GuardJob.values()[jobId];
assignManually = compound.getBoolean(NBT_ASSIGN);
retrieveOnLowHealth = compound.getBoolean(NBT_RETRIEVE);
patrolManually = compound.getBoolean(NBT_PATROL);
Expand Down Expand Up @@ -301,7 +301,7 @@ public void serializeToView(@NotNull final ByteBuf buf)
buf.writeBoolean(patrolManually);
buf.writeBoolean(tightGrouping);
buf.writeInt(task.ordinal());
buf.writeInt(job == GuardJob.KNIGHT ? -1 : job.ordinal());
buf.writeInt(job == null ? -1 : job.ordinal());
buf.writeInt(patrolTargets.size());

for (final BlockPos pos : patrolTargets)
Expand Down Expand Up @@ -452,6 +452,11 @@ private Tuple<EnumFacing, EnumFacing> getRandomDirectionTuple(final Random rando
@Override
public void onUpgradeComplete(final int newLevel)
{
if (job == null)
{
job = new Random().nextBoolean() ? GuardJob.KNIGHT : GuardJob.RANGER;
}

if (getAssignedEntities() != null)
{
for (final Optional<EntityCitizen> optCitizen : getAssignedEntities())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ public DesiredActivity getDesiredActivity()
return DesiredActivity.WORK;
}

if (getCitizenColonyHandler().getColony() != null && !world.isRemote && (getCitizenColonyHandler().getColony().getBarbManager().getHorde((WorldServer) world).size() > 0) && !(citizenJobHandler.getColonyJob() instanceof AbstractJobGuard))
if (getCitizenColonyHandler().getColony() != null && !world.isRemote && (!getCitizenColonyHandler().getColony().getBarbManager().getHorde((WorldServer) world).isEmpty()) && !(citizenJobHandler.getColonyJob() instanceof AbstractJobGuard))
{
return DesiredActivity.SLEEP;
}
Expand Down
Loading

0 comments on commit 92f1043

Please sign in to comment.