use of com.minecolonies.coremod.entity.citizen.VisitorCitizen in project minecolonies by ldtteam.
the class VisitorManager method spawnOrCreateCivilian.
@Override
public IVisitorData spawnOrCreateCivilian(ICivilianData data, final World world, final BlockPos spawnPos, final boolean force) {
if (!WorldUtil.isEntityBlockLoaded(world, spawnPos)) {
return (IVisitorData) data;
}
if (data == null) {
data = createAndRegisterCivilianData();
}
VisitorCitizen citizenEntity = (VisitorCitizen) ModEntities.VISITOR.create(colony.getWorld());
if (citizenEntity == null) {
return (IVisitorData) data;
}
citizenEntity.setPos(spawnPos.getX() + HALF_A_BLOCK, spawnPos.getY() + SLIGHTLY_UP, spawnPos.getZ() + HALF_A_BLOCK);
world.addFreshEntity(citizenEntity);
citizenEntity.getCitizenColonyHandler().registerWithColony(data.getColony().getID(), data.getId());
return (IVisitorData) data;
}
use of com.minecolonies.coremod.entity.citizen.VisitorCitizen in project minecolonies by ldtteam.
the class EventListener method onUpdateEntityRadar.
@SubscribeEvent
public void onUpdateEntityRadar(@NotNull final EntityRadarUpdateEvent event) {
final WrappedEntity wrapper = event.getWrappedEntity();
final LivingEntity entity = wrapper.getEntityLivingRef().get();
if (entity instanceof AbstractEntityCitizen) {
final boolean isVisitor = entity instanceof VisitorCitizen;
TextComponent jobName;
if (isVisitor) {
if (!JourneymapOptions.getShowVisitors(this.jmap.getOptions())) {
wrapper.setDisable(true);
return;
}
jobName = new TranslationTextComponent(COM_MINECOLONIES_JMAP_PREFIX + "visitor");
} else {
final String jobId = entity.getEntityData().get(DATA_JOB);
final JobEntry jobEntry = IJobRegistry.getInstance().getValue(new ResourceLocation(jobId));
final IJob<?> job = jobEntry == null ? null : jobEntry.produceJob(null);
if (job instanceof AbstractJobGuard ? !JourneymapOptions.getShowGuards(this.jmap.getOptions()) : !JourneymapOptions.getShowCitizens(this.jmap.getOptions())) {
wrapper.setDisable(true);
return;
}
jobName = new TranslationTextComponent(jobEntry == null ? COM_MINECOLONIES_JMAP_PREFIX + "unemployed" : jobEntry.getTranslationKey());
}
if (JourneymapOptions.getShowColonistTooltip(this.jmap.getOptions())) {
ITextComponent name = entity.getCustomName();
if (name != null) {
wrapper.setEntityToolTips(Arrays.asList(name, jobName.setStyle(JOB_TOOLTIP)));
}
}
final boolean showName = event.getActiveUiState().ui.equals(Context.UI.Minimap) ? JourneymapOptions.getShowColonistNameMinimap(this.jmap.getOptions()) : JourneymapOptions.getShowColonistNameFullscreen(this.jmap.getOptions());
if (!showName) {
wrapper.setCustomName("");
}
if (!isVisitor && JourneymapOptions.getShowColonistTeamColour(this.jmap.getOptions())) {
wrapper.setColor(entity.getTeamColor());
}
}
}
use of com.minecolonies.coremod.entity.citizen.VisitorCitizen in project minecolonies by Minecolonies.
the class EventListener method onUpdateEntityRadar.
@SubscribeEvent
public void onUpdateEntityRadar(@NotNull final EntityRadarUpdateEvent event) {
final WrappedEntity wrapper = event.getWrappedEntity();
final LivingEntity entity = wrapper.getEntityLivingRef().get();
if (entity instanceof AbstractEntityCitizen) {
final boolean isVisitor = entity instanceof VisitorCitizen;
TextComponent jobName;
if (isVisitor) {
if (!JourneymapOptions.getShowVisitors(this.jmap.getOptions())) {
wrapper.setDisable(true);
return;
}
jobName = new TranslationTextComponent(PARTIAL_JOURNEY_MAP_INFO + "visitor");
} else {
final String jobId = entity.getEntityData().get(DATA_JOB);
final JobEntry jobEntry = IJobRegistry.getInstance().getValue(new ResourceLocation(jobId));
final IJob<?> job = jobEntry == null ? null : jobEntry.produceJob(null);
if (job instanceof AbstractJobGuard ? !JourneymapOptions.getShowGuards(this.jmap.getOptions()) : !JourneymapOptions.getShowCitizens(this.jmap.getOptions())) {
wrapper.setDisable(true);
return;
}
jobName = new TranslationTextComponent(jobEntry == null ? PARTIAL_JOURNEY_MAP_INFO + "unemployed" : jobEntry.getTranslationKey());
}
if (JourneymapOptions.getShowColonistTooltip(this.jmap.getOptions())) {
ITextComponent name = entity.getCustomName();
if (name != null) {
wrapper.setEntityToolTips(Arrays.asList(name, jobName.setStyle(JOB_TOOLTIP)));
}
}
final boolean showName = event.getActiveUiState().ui.equals(Context.UI.Minimap) ? JourneymapOptions.getShowColonistNameMinimap(this.jmap.getOptions()) : JourneymapOptions.getShowColonistNameFullscreen(this.jmap.getOptions());
if (!showName) {
wrapper.setCustomName("");
}
if (!isVisitor && JourneymapOptions.getShowColonistTeamColour(this.jmap.getOptions())) {
wrapper.setColor(entity.getTeamColor());
}
} else if (entity instanceof AbstractEntityMinecoloniesMob) {
final JourneymapOptions.RaiderColor color = JourneymapOptions.getRaiderColor(this.jmap.getOptions());
if (JourneymapOptions.RaiderColor.NONE.equals(color)) {
wrapper.setDisable(true);
} else if (!JourneymapOptions.RaiderColor.HOSTILE.equals(color)) {
wrapper.setColor(color.getColor().getValue());
}
}
}
use of com.minecolonies.coremod.entity.citizen.VisitorCitizen in project minecolonies by Minecolonies.
the class VisitorManager method spawnOrCreateCivilian.
@Override
public IVisitorData spawnOrCreateCivilian(ICivilianData data, final World world, final BlockPos spawnPos, final boolean force) {
if (!WorldUtil.isEntityBlockLoaded(world, spawnPos)) {
return (IVisitorData) data;
}
if (data == null) {
data = createAndRegisterCivilianData();
}
VisitorCitizen citizenEntity = (VisitorCitizen) ModEntities.VISITOR.create(colony.getWorld());
if (citizenEntity == null) {
return (IVisitorData) data;
}
citizenEntity.setPos(spawnPos.getX() + HALF_A_BLOCK, spawnPos.getY() + SLIGHTLY_UP, spawnPos.getZ() + HALF_A_BLOCK);
world.addFreshEntity(citizenEntity);
citizenEntity.getCitizenColonyHandler().registerWithColony(data.getColony().getID(), data.getId());
return (IVisitorData) data;
}
Aggregations