Search in sources :

Example 1 with VisitorCitizen

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;
}
Also used : IVisitorData(com.minecolonies.api.colony.IVisitorData) VisitorCitizen(com.minecolonies.coremod.entity.citizen.VisitorCitizen)

Example 2 with VisitorCitizen

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());
        }
    }
}
Also used : AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) WrappedEntity(journeymap.client.api.model.WrappedEntity) VisitorCitizen(com.minecolonies.coremod.entity.citizen.VisitorCitizen) LivingEntity(net.minecraft.entity.LivingEntity) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with VisitorCitizen

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());
        }
    }
}
Also used : AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) WrappedEntity(journeymap.client.api.model.WrappedEntity) VisitorCitizen(com.minecolonies.coremod.entity.citizen.VisitorCitizen) LivingEntity(net.minecraft.entity.LivingEntity) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractEntityMinecoloniesMob(com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with VisitorCitizen

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;
}
Also used : IVisitorData(com.minecolonies.api.colony.IVisitorData) VisitorCitizen(com.minecolonies.coremod.entity.citizen.VisitorCitizen)

Aggregations

VisitorCitizen (com.minecolonies.coremod.entity.citizen.VisitorCitizen)4 IVisitorData (com.minecolonies.api.colony.IVisitorData)2 JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 AbstractJobGuard (com.minecolonies.coremod.colony.jobs.AbstractJobGuard)2 WrappedEntity (journeymap.client.api.model.WrappedEntity)2 LivingEntity (net.minecraft.entity.LivingEntity)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 AbstractEntityMinecoloniesMob (com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob)1