Search in sources :

Example 16 with Colony

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

the class AddOfficerCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
    final Colony colony = actionMenu.getColonyForArgument("colony");
    final EntityPlayer player = actionMenu.getPlayerForArgument("player");
    executeShared(server, sender, colony, player.getName());
}
Also used : Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 17 with Colony

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

the class TeleportToColony method teleportPlayer.

/**
 * Method used to teleport the player.
 *
 * @param colID            the senders colony ID.
 * @param playerToTeleport the player which shall be teleported.
 */
private static void teleportPlayer(final EntityPlayer playerToTeleport, final int colID, final ICommandSender sender) {
    final Colony colony = ColonyManager.getColony(colID);
    final BuildingTownHall townHall = colony.getBuildingManager().getTownHall();
    if (townHall == null) {
        sender.sendMessage(new TextComponentString(NO_TOWNHALL));
        return;
    }
    playerToTeleport.sendMessage(new TextComponentString("We got places to go, kid..."));
    final BlockPos position = townHall.getLocation();
    final int dimension = playerToTeleport.getEntityWorld().provider.getDimension();
    final int colonyDimension = townHall.getColony().getDimension();
    if (colID < MIN_COLONY_ID) {
        playerToTeleport.sendMessage(new TextComponentString(CANT_FIND_COLONY));
        return;
    }
    final EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
    if (dimension != colonyDimension) {
        playerToTeleport.sendMessage(new TextComponentString("Buckle up buttercup, this ain't no joy ride!!!"));
        final MinecraftServer server = sender.getEntityWorld().getMinecraftServer();
        final WorldServer worldServer = server.getWorld(colonyDimension);
        // Vanilla does that as well.
        entityPlayerMP.connection.sendPacket(new SPacketEffect(SOUND_TYPE, BlockPos.ORIGIN, 0, false));
        entityPlayerMP.addExperience(0);
        entityPlayerMP.setPlayerHealthUpdated();
        playerToTeleport.sendMessage(new TextComponentString("Hold onto your pants, we're going Inter-Dimensional!"));
        worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, colonyDimension, new Teleporter(worldServer));
        if (dimension == 1) {
            worldServer.spawnEntity(playerToTeleport);
            worldServer.updateEntityWithOptionalForce(playerToTeleport, false);
        }
    }
    entityPlayerMP.connection.setPlayerLocation(position.getX(), position.getY() + 2.0, position.getZ(), entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch);
}
Also used : SPacketEffect(net.minecraft.network.play.server.SPacketEffect) Teleporter(net.minecraft.world.Teleporter) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) BuildingTownHall(com.minecolonies.coremod.colony.buildings.BuildingTownHall) TextComponentString(net.minecraft.util.text.TextComponentString) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 18 with Colony

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

the class BlockHutTownHall method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    if (worldIn.isRemote) {
        return;
    }
    if (placer.getActiveHand().equals(EnumHand.MAIN_HAND)) {
        final Colony colony = ColonyManager.getClosestColony(worldIn, pos);
        String style = Constants.DEFAULT_STYLE;
        final TileEntity tileEntity = worldIn.getTileEntity(pos);
        if (tileEntity instanceof TileEntityColonyBuilding && !((TileEntityColonyBuilding) tileEntity).getStyle().isEmpty()) {
            style = ((TileEntityColonyBuilding) tileEntity).getStyle();
        }
        if (colony == null || !ColonyManager.isTooCloseToColony(worldIn, pos)) {
            ColonyManager.createColony(worldIn, pos, (EntityPlayer) placer, style);
        } else {
            colony.setStyle(style);
        }
    }
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityColonyBuilding(com.minecolonies.coremod.tileentities.TileEntityColonyBuilding) Colony(com.minecolonies.coremod.colony.Colony)

Example 19 with Colony

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

the class BlockMinecoloniesRack method onBlockActivated.

@Override
public boolean onBlockActivated(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer playerIn, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
    final Colony colony = ColonyManager.getColony(worldIn, pos);
    final TileEntity tileEntity = worldIn.getTileEntity(pos);
    if ((colony == null || colony.getPermissions().hasPermission(playerIn, Action.ACCESS_HUTS)) && tileEntity instanceof TileEntityRack) {
        if (!worldIn.isRemote) {
            playerIn.openGui(MineColonies.instance, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRack(com.minecolonies.coremod.tileentities.TileEntityRack) Colony(com.minecolonies.coremod.colony.Colony)

Example 20 with Colony

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

the class AbstractBlockHut method onBlockPlacedBy.

/**
 * Event-Handler for placement of this block.
 * <p>
 * Override for custom logic.
 *
 * @param worldIn the word we are in.
 * @param pos     the position where the block was placed.
 * @param state   the state the placed block is in.
 * @param placer  the player placing the block.
 * @param stack   the itemstack from where the block was placed.
 * @see Block#onBlockPlacedBy(World, BlockPos, IBlockState,
 * EntityLivingBase, ItemStack)
 */
@Override
public void onBlockPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    /*
        Only work on server side
        */
    if (worldIn.isRemote) {
        return;
    }
    final TileEntity tileEntity = worldIn.getTileEntity(pos);
    if (placer instanceof EntityPlayer && tileEntity instanceof TileEntityColonyBuilding) {
        @NotNull final TileEntityColonyBuilding hut = (TileEntityColonyBuilding) tileEntity;
        @Nullable final Colony colony = ColonyManager.getColony(worldIn, hut.getPosition());
        if (colony != null) {
            colony.getBuildingManager().addNewBuilding(hut, worldIn);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityColonyBuilding(com.minecolonies.coremod.tileentities.TileEntityColonyBuilding) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Colony (com.minecolonies.coremod.colony.Colony)81 TextComponentString (net.minecraft.util.text.TextComponentString)29 IColony (com.minecolonies.api.colony.IColony)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 BlockPos (net.minecraft.util.math.BlockPos)19 Nullable (org.jetbrains.annotations.Nullable)16 CitizenData (com.minecolonies.coremod.colony.CitizenData)13 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)13 NotNull (org.jetbrains.annotations.NotNull)11 ItemStack (net.minecraft.item.ItemStack)9 Entity (net.minecraft.entity.Entity)8 TileEntity (net.minecraft.tileentity.TileEntity)8 World (net.minecraft.world.World)6 List (java.util.List)5 UUID (java.util.UUID)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)4 Delivery (com.minecolonies.api.colony.requestsystem.requestable.Delivery)4 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)4 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)4