Search in sources :

Example 6 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class ItemScepterPermission method onItemUse.

/**
 * Used when clicking on block in world.
 *
 * @param playerIn the player
 * @param worldIn  the world
 * @param pos      the position
 * @param hand     the hand
 * @param facing   the facing hit
 * @param hitX     the x coordinate
 * @param hitY     the y coordinate
 * @param hitZ     the z coordinate
 * @return the result
 */
@Override
@NotNull
public EnumActionResult onItemUse(final EntityPlayer playerIn, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
    if (!worldIn.isRemote) {
        return EnumActionResult.SUCCESS;
    }
    final ItemStack scepter = playerIn.getHeldItem(hand);
    if (!scepter.hasTagCompound()) {
        scepter.setTagCompound(new NBTTagCompound());
    }
    final ColonyView colonyView = ColonyManager.getClosestColonyView(worldIn, pos);
    if (colonyView == null) {
        return EnumActionResult.FAIL;
    }
    final NBTTagCompound compound = scepter.getTagCompound();
    return handleItemAction(compound, playerIn, worldIn, pos, colonyView);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class RenderUtils method calculateColonyBorder.

/**
     * Calculate the colony border.
     * @param theWorld in the world.
     * @param thePlayer with the player.
     * @param colonyBorder the border.
     */
private static void calculateColonyBorder(final WorldClient theWorld, final EntityPlayerSP thePlayer, final List<BlockPos> colonyBorder) {
    final ColonyView colonyView = ColonyManager.getClosestColonyView(theWorld, thePlayer.getPosition());
    if (colonyView == null) {
        return;
    }
    final BlockPos center = colonyView.getCenter();
    final int radius = Configurations.workingRangeTownHall;
    for (double degrees = 0; degrees < WHOLE_CIRCLE; degrees += 1) {
        final double rads = degrees / HALF_A_CIRCLE * Math.PI;
        final double x = Math.round(center.getX() + radius * Math.sin(rads));
        final double z = Math.round(center.getZ() + radius * Math.cos(rads));
        colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(x, center.getY(), z), theWorld).up());
    }
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowTownHall method teleportToColony.

/**
 * On Button click teleport to the colony..
 *
 * @param button the clicked button.
 */
private void teleportToColony(@NotNull final Button button) {
    final int row = alliesList.getListElementIndexByPane(button);
    final ColonyView ally = allies.get(row);
    final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID())));
    Minecraft.getMinecraft().player.sendMessage(teleport);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 9 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowTownHall method updateFeuds.

/**
 * Clears and resets all feuds.
 */
private void updateFeuds() {
    feuds.clear();
    final ColonyView colony = building.getColony();
    for (final Player player : colony.getPermissions().getPlayersByRank(Rank.HOSTILE)) {
        final IColony col = ColonyManager.getIColonyByOwner(Minecraft.getMinecraft().world, player.getID());
        if (col instanceof ColonyView) {
            for (final Player owner : colony.getPermissions().getPlayersByRank(Rank.OWNER)) {
                if (col.getPermissions().getRank(owner.getID()) == Rank.HOSTILE) {
                    feuds.add((ColonyView) col);
                }
            }
        }
    }
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) Player(com.minecolonies.api.colony.permissions.Player) IColony(com.minecolonies.api.colony.IColony)

Example 10 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class ClientEventHandler method renderWorldLastEvent.

/**
 * Used to catch the renderWorldLastEvent in order to draw the debug nodes for pathfinding.
 *
 * @param event the catched event.
 */
@SubscribeEvent
public void renderWorldLastEvent(@NotNull final RenderWorldLastEvent event) {
    Pathfinding.debugDraw(event.getPartialTicks());
    final Structure structure = Settings.instance.getActiveStructure();
    final WorldClient world = Minecraft.getMinecraft().world;
    final EntityPlayer player = Minecraft.getMinecraft().player;
    if (structure != null) {
        final BlockPos position = Settings.instance.getPosition();
        if (Settings.instance.getStructureName().contains(AbstractEntityAIStructure.WAYPOINT_STRING)) {
            RenderUtils.renderWayPoints(position, world, event.getPartialTicks());
        } else {
            RenderUtils.renderColonyBorder(position, world, event.getPartialTicks(), player, colonyBorder);
        }
        return;
    } else {
        if (citizen != null) {
            final Entity entityCitizen = world.getEntityByID(citizen.getEntityId());
            if (entityCitizen instanceof EntityCitizen) {
                RenderUtils.renderSigns(world, event.getPartialTicks(), citizen, player, entityCitizen.getPosition());
                ticksPassed += event.getPartialTicks();
                if (ticksPassed > Constants.TICKS_SECOND * SECONDS_TO_SHOW) {
                    ticksPassed = 0;
                    citizen = null;
                }
            } else {
                citizen = null;
                ticksPassed = 0;
            }
            return;
        }
        final ColonyView colony = ColonyManager.getClosestColonyView(world, player.getPosition());
        if (colony != null && player != null && colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
            for (final CitizenDataView citizenDataView : new ArrayList<CitizenDataView>(colony.getCitizens().values())) {
                final Entity entityCitizen = world.getEntityByID(citizenDataView.getEntityId());
                if (entityCitizen instanceof EntityCitizen && entityCitizen.getPosition().distanceSq(player.getPosition()) <= 2) {
                    RenderUtils.renderSigns(world, event.getPartialTicks(), citizenDataView, player, entityCitizen.getPosition());
                    citizen = citizenDataView;
                    return;
                }
            }
        }
    }
    colonyBorder.clear();
}
Also used : Entity(net.minecraft.entity.Entity) ColonyView(com.minecolonies.coremod.colony.ColonyView) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) Structure(com.minecolonies.structures.helpers.Structure) AbstractEntityAIStructure(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) WorldClient(net.minecraft.client.multiplayer.WorldClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ColonyView (com.minecolonies.coremod.colony.ColonyView)13 BlockPos (net.minecraft.util.math.BlockPos)5 ItemStack (net.minecraft.item.ItemStack)4 IColony (com.minecolonies.api.colony.IColony)2 Player (com.minecolonies.api.colony.permissions.Player)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 Image (com.minecolonies.blockout.controls.Image)2 ItemIcon (com.minecolonies.blockout.controls.ItemIcon)2 Label (com.minecolonies.blockout.controls.Label)2 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)1 IRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver)1 IPlayerRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver)1 IRetryingRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)1 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)1 Constants (com.minecolonies.api.util.constant.Constants)1 Button (com.minecolonies.blockout.controls.Button)1 Box (com.minecolonies.blockout.views.Box)1